Browse Source

Doxyfile changes, adding comments to EmFieldType

Yann Weber 9 years ago
parent
commit
b48b0799eb
2 changed files with 76 additions and 26 deletions
  1. 6
    6
      Doxyfile
  2. 70
    20
      EditorialModel/fieldtypes.py

+ 6
- 6
Doxyfile View File

@@ -207,7 +207,7 @@ QT_AUTOBRIEF           = NO
207 207
 # not recognized any more.
208 208
 # The default value is: NO.
209 209
 
210
-MULTILINE_CPP_IS_BRIEF = NO
210
+MULTILINE_CPP_IS_BRIEF = YES
211 211
 
212 212
 # If the INHERIT_DOCS tag is set to YES then an undocumented member inherits the
213 213
 # documentation from any documented member that it re-implements.
@@ -1418,7 +1418,7 @@ ECLIPSE_DOC_ID         = org.doxygen.Project
1418 1418
 # The default value is: NO.
1419 1419
 # This tag requires that the tag GENERATE_HTML is set to YES.
1420 1420
 
1421
-DISABLE_INDEX          = NO
1421
+DISABLE_INDEX          = YES
1422 1422
 
1423 1423
 # The GENERATE_TREEVIEW tag is used to specify whether a tree-like index
1424 1424
 # structure should be generated to display hierarchical information. If the tag
@@ -1435,7 +1435,7 @@ DISABLE_INDEX          = NO
1435 1435
 # The default value is: NO.
1436 1436
 # This tag requires that the tag GENERATE_HTML is set to YES.
1437 1437
 
1438
-GENERATE_TREEVIEW      = NO
1438
+GENERATE_TREEVIEW      = YES
1439 1439
 
1440 1440
 # The ENUM_VALUES_PER_LINE tag can be used to set the number of enum values that
1441 1441
 # doxygen will group on one line in the generated HTML documentation.
@@ -2129,7 +2129,7 @@ DIA_PATH               =
2129 2129
 # and usage relations if the target is undocumented or is not a class.
2130 2130
 # The default value is: YES.
2131 2131
 
2132
-HIDE_UNDOC_RELATIONS   = YES
2132
+HIDE_UNDOC_RELATIONS   = NO
2133 2133
 
2134 2134
 # If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is
2135 2135
 # available from the path. This tool is part of Graphviz (see:
@@ -2189,7 +2189,7 @@ CLASS_GRAPH            = YES
2189 2189
 # The default value is: YES.
2190 2190
 # This tag requires that the tag HAVE_DOT is set to YES.
2191 2191
 
2192
-COLLABORATION_GRAPH    = YES
2192
+COLLABORATION_GRAPH    = NO
2193 2193
 
2194 2194
 # If the GROUP_GRAPHS tag is set to YES then doxygen will generate a graph for
2195 2195
 # groups, showing the direct groups dependencies.
@@ -2225,7 +2225,7 @@ UML_LIMIT_NUM_FIELDS   = 10
2225 2225
 # The default value is: NO.
2226 2226
 # This tag requires that the tag HAVE_DOT is set to YES.
2227 2227
 
2228
-TEMPLATE_RELATIONS     = NO
2228
+TEMPLATE_RELATIONS     = YES
2229 2229
 
2230 2230
 # If the INCLUDE_GRAPH, ENABLE_PREPROCESSING and SEARCH_INCLUDES tags are set to
2231 2231
 # YES then doxygen will generate a graph for each documented file showing the

+ 70
- 20
EditorialModel/fieldtypes.py View File

@@ -10,11 +10,15 @@ import importlib
10 10
 import re
11 11
 import copy
12 12
 
13
-## @file fieldtypes.py
14
-# This file contains classes about SQL column (EmFieldType)
15
-# and their values (EmFieldValue)
16
-# For the moment the code is in quick & dirty version and is
17
-# more like a proof of concept
13
+## @namespace EditorialModel.fieldtypes
14
+# @brief This file contains classes about SQL column (EmFieldType) and their values (EmFieldValue)
15
+# 
16
+# The underlying concept is to handle two differents objects, one for handling an SQL column definition (EmFieldType)
17
+# and another one to handle values (EmFieldValue). This organisation allows to have large, flexible and powerfull mains objects and to
18
+# specialise them by inheritance ( EmFieldType -> EmField_char -> EmField_MlString ) ( EmFieldValue -> EmFieldValue_int )
19
+#
20
+# @note For the moment the code is a bit in quick and dirty mode.
21
+#
18 22
 
19 23
 ## @brief Handles SQL types
20 24
 # This class handles SQL types and their options.
@@ -89,13 +93,23 @@ class EmFieldSQLType(object):
89 93
         return cl._names[name]['sql'](**kwargs)
90 94
         
91 95
         
92
-
96
+## @brief Characterise fields for LeObject and EmComponent
97
+# This class handles values rules for LeObject and EmComponents.
98
+# 
99
+# It allows to EmFieldValue classes family to have rules to cast, validate and save values.
100
+# 
101
+# There is exposed methods that allows LeObject and EmType to run a save sequence. This methods are :
102
+# - EmFieldType.to_value() That cast a value to an EmFieldType internal storage
103
+# - EmFieldType.is_valid() That indicates wether or not a value is valid
104
+# - EmFieldType.pre_save() That returns weighted SQL request that must be run before any value save @ref EditorialModel::types::EmType.save_values()
105
+# - EmFieldType.to_sql() That returns a value that can be inserted in database.
106
+# - EmFieldType.post_save() That returns weighted SQL request that must be run after any value save @ref EditorialModel::types::EmType.save_values()
107
+#
93 108
 class EmFieldType(object):
94 109
  
95 110
     ## Stores options and default value for EmFieldType
96 111
     # options list : 
97 112
     # - type (str|None) : if None will make an 'abstract' fieldtype (with no value assignement possible)
98
-    # - size (int) : The size for this type
99 113
     # - nullable (bool) : tell whether or not a fieldType accept NULL value
100 114
     # - default (mixed) : The default value for a FieldType
101 115
     # - primarykey (bool) : If true the fieldType represent a PK
@@ -105,11 +119,11 @@ class EmFieldType(object):
105 119
     # - doc (str) : FieldType documentation
106 120
     # - onupdate (callable) : A callback to call on_update
107 121
     # - valueobject (EmFieldValue or childs) : An object that represent values for this fieldType
108
-    # - type_* (mixed) : Use to construct an options dictinnary for a type (exemple : type_length => nnewColumn(lenght= [type_lenght VALUE] ))
122
+    # - type_* (mixed) : Use to construct an options dictinnary for a type (exemple : type_length => nnewColumn(lenght= [type_lenght VALUE] )) @ref EmFieldSQLType
123
+    #
109 124
     _opt = {
110 125
         'name' : None,
111 126
         'type' : None,
112
-        'size': None,
113 127
         'nullable': True,
114 128
         'default' : None,
115 129
         'primarykey': False,
@@ -124,6 +138,7 @@ class EmFieldType(object):
124 138
 
125 139
     ## Instanciate an EmFieldType
126 140
     # For arguments see @ref EmFieldType::_opt
141
+    # @see EmFieldType::_opt
127 142
     def __init__(self, **kwargs):
128 143
         self._init(kwargs)
129 144
         self.type_options = dict()
@@ -246,6 +261,30 @@ class EmFieldType(object):
246 261
             raise NotImplementedError("This EmFieldType is abstract")
247 262
         return value
248 263
 
264
+    ## Return wether or not a value is valid for this EmFieldType
265
+    # @note This function always return True and is here for being overloaded by childs objects
266
+    # @return A boolean, True if valid else False
267
+    def is_valid(self, value):
268
+        if self.abstract:
269
+            raise NotImplementedError("This EmFieldType is abstract")
270
+        return True
271
+
272
+    ## @brief Return a list of (priority, SqlRequest) tuples designed to be executed before saving values in Db
273
+    # @note This function return an empty array and is here for being overloaded by childs objects
274
+    # @return A list of (priority, SqlRequest) tuples
275
+    def pre_save(self):
276
+        if self.abstract:
277
+            raise NotImplementedError("This EmFieldType is abstract")
278
+        return []
279
+
280
+    ## @brief Return a list of (priority, SqlRequest) tuples designed to be executed after values were saved in Db
281
+    # @note This function return an empty array and is here for being overloaded by childs objects
282
+    # @return A list of (priority, SqlRequest) tuples
283
+    def post_save(self):
284
+        if self.abstract:
285
+            raise NotImplementedError("This EmFieldType is abstract")
286
+        return []
287
+
249 288
     @classmethod
250 289
     ## Function designed to be called by child class to enforce a type
251 290
     # @param args dict: The kwargs argument of __init__
@@ -280,6 +319,9 @@ class EmFieldType(object):
280 319
         return args
281 320
 
282 321
 
322
+## @brief Handles EmFieldType values
323
+# This class is designed to be linked with an EmFieldType and to handles values according to the linked EmFieldType rules
324
+# @see EmFieldType
283 325
 class EmFieldValue(object):
284 326
 
285 327
     ## Instanciate a EmFieldValue
@@ -346,7 +388,7 @@ class EmFieldValue(object):
346 388
         return super(EmFieldValue, self).__getattribute__(name)
347 389
 
348 390
         
349
-    ## @brief Return an sql valid value
391
+    ## @brief Return a valid SQL value
350 392
     #
351 393
     # Can be used to convert any value (giving one positionnal argument) or to return the current value
352 394
     # @param *value list: If a positionnal argument is given return it and not the instance value 
@@ -358,7 +400,7 @@ class EmFieldValue(object):
358 400
             return self.fieldtype.to_sql(value[0])
359 401
         return self.fieldtype.to_sql(self.value)
360 402
 
361
-## @brief Designed to handle values that has common arithmetic operations
403
+## @brief Represents values with common arithmetic operations
362 404
 class EmFieldValue_int(EmFieldValue):
363 405
        
364 406
     def __int__(self):
@@ -394,16 +436,20 @@ class EmFieldValue_int(EmFieldValue):
394 436
     def __idiv__(self, other):
395 437
         self.value = int(self.value / other)
396 438
         return self
397
-        
439
+
440
+## @brief Handles integer fields
441
+# @note Enforcing type to be int
442
+# @note Default name is 'integer' and default 'valueobject' is EmFieldValue_int
398 443
 class EmField_integer(EmFieldType):
399 444
     def __init__(self, **kwargs):
400 445
         self._init(kwargs)
401 446
         #Default name
402 447
         kwargs = self.__class__._argDefault(kwargs, 'name', 'integer')
448
+        #Default value object
449
+        kwargs = self.__class__._argDefault(kwargs, 'valueobject', EmFieldValue_int)
403 450
         #Type enforcing
404 451
         kwargs = self.__class__._setType(kwargs, 'int')
405 452
         super(EmField_integer, self).__init__(**kwargs)
406
-        self.valueobject = EmFieldValue_int
407 453
         pass
408 454
     ##
409 455
     # @todo catch cast error ?
@@ -415,9 +461,9 @@ class EmField_integer(EmFieldType):
415 461
             return super(EmField_integer, self).to_value(value)
416 462
         return int(value)
417 463
 
418
-## EmField_boolean (Class)
419
-#
420
-# Boolean field type
464
+## @brief Handles boolean fields
465
+# @note Enforce type to be 'boolean'
466
+# @note Default name is 'boolean'
421 467
 class EmField_boolean(EmFieldType):
422 468
     def __init__(self, **kwargs):
423 469
         self._init(kwargs)
@@ -435,9 +481,10 @@ class EmField_boolean(EmFieldType):
435 481
         self.value = bool(value)
436 482
         return self.value
437 483
 
438
-## EmField_char (Class)
439
-#
440
-# Varchar field type
484
+## @brief Handles string fields
485
+# @note Enforce type to be (varchar)
486
+# @note Default 'name' is 'char'
487
+# @note Default 'type_length' is 76
441 488
 class EmField_char(EmFieldType):
442 489
     default_length = 76
443 490
     def __init__(self, **kwargs):
@@ -449,7 +496,8 @@ class EmField_char(EmFieldType):
449 496
         super(EmField_char, self).__init__(**kwargs)
450 497
     def to_sql(self, value):
451 498
         return str(value)
452
-##
499
+## @brief Handles date fields
500
+# @note Enforce type to be 'datetime'
453 501
 # @todo rename to EmField_datetime
454 502
 # @todo timezones support
455 503
 class EmField_date(EmFieldType):
@@ -472,6 +520,7 @@ class EmField_date(EmFieldType):
472 520
         if isinstance(value, datetime.datetime):
473 521
             return value
474 522
 
523
+## @brief Handles strings with translations
475 524
 class EmField_mlstring(EmField_char):
476 525
     
477 526
     def __init__(self, **kwargs):
@@ -491,6 +540,7 @@ class EmField_mlstring(EmField_char):
491 540
             return value
492 541
         raise TypeError("<class str> or <class MlString> excepted. But got "+str(type(value)))
493 542
 
543
+## @brief Handles lodel uid fields
494 544
 class EmField_uid(EmField_integer):
495 545
     def __init__(self, **kwargs):
496 546
         self._init(kwargs)

Loading…
Cancel
Save