105 return 0 |
105 return 0 |
106 |
106 |
107 depth = self._scope_logic.logic.getScopeDepth() |
107 depth = self._scope_logic.logic.getScopeDepth() |
108 return None if (depth is None) else (depth + 1) |
108 return None if (depth is None) else (depth + 1) |
109 |
109 |
110 def _updateField(self, entity, name, value): |
|
111 """Hook called when a field is updated. |
|
112 |
|
113 Base classes should override if any special actions need to be |
|
114 taken when a field is updated. The field is not updated if the |
|
115 method does not return a True value. |
|
116 |
|
117 Args: |
|
118 entity: the unaltered entity |
|
119 name: the name of the field to be changed |
|
120 value: the new value |
|
121 """ |
|
122 |
|
123 if not entity: |
|
124 raise NoEntityError |
|
125 |
|
126 if not entity_properties or (name not in entity_properties): |
|
127 raise InvalidArgumentError |
|
128 |
|
129 return True |
|
130 |
|
131 def _onCreate(self, entity): |
|
132 """Called when an entity has been created. |
|
133 |
|
134 Classes that override this can use it to do any post-creation operations. |
|
135 """ |
|
136 |
|
137 if not entity: |
|
138 raise NoEntityError |
|
139 |
|
140 sidebar.flush() |
|
141 |
|
142 def _onUpdate(self, entity): |
|
143 """Called when an entity has been updated. |
|
144 |
|
145 Classes that override this can use it to do any post-update operations. |
|
146 """ |
|
147 |
|
148 if not entity: |
|
149 raise NoEntityError |
|
150 |
|
151 def _onDelete(self, entity): |
|
152 """Called when an entity has been deleted. |
|
153 |
|
154 Classes that override this can use it to do any post-deletion operations. |
|
155 """ |
|
156 |
|
157 if not entity: |
|
158 raise NoEntityError |
|
159 |
|
160 def getKeyNameFromFields(self, fields): |
110 def getKeyNameFromFields(self, fields): |
161 """Returns the KeyName constructed from fields dict for this type of entity. |
111 """Returns the KeyName constructed from fields dict for this type of entity. |
162 |
112 |
163 The KeyName is in the following format: |
113 The KeyName is in the following format: |
164 <key_value1>/<key_value2>/.../<key_valueN> |
114 <key_value1>/<key_value2>/.../<key_valueN> |
467 """ |
417 """ |
468 |
418 |
469 entity.delete() |
419 entity.delete() |
470 # entity has been deleted call _onDelete |
420 # entity has been deleted call _onDelete |
471 self._onDelete(entity) |
421 self._onDelete(entity) |
|
422 |
|
423 def _updateField(self, entity, name, value): |
|
424 """Hook called when a field is updated. |
|
425 |
|
426 Base classes should override if any special actions need to be |
|
427 taken when a field is updated. The field is not updated if the |
|
428 method does not return a True value. |
|
429 |
|
430 Args: |
|
431 entity: the unaltered entity |
|
432 name: the name of the field to be changed |
|
433 value: the new value |
|
434 """ |
|
435 |
|
436 if not entity: |
|
437 raise NoEntityError |
|
438 |
|
439 if not entity_properties or (name not in entity_properties): |
|
440 raise InvalidArgumentError |
|
441 |
|
442 return True |
|
443 |
|
444 def _onCreate(self, entity): |
|
445 """Called when an entity has been created. |
|
446 |
|
447 Classes that override this can use it to do any post-creation operations. |
|
448 """ |
|
449 |
|
450 if not entity: |
|
451 raise NoEntityError |
|
452 |
|
453 sidebar.flush() |
|
454 |
|
455 def _onUpdate(self, entity): |
|
456 """Called when an entity has been updated. |
|
457 |
|
458 Classes that override this can use it to do any post-update operations. |
|
459 """ |
|
460 |
|
461 if not entity: |
|
462 raise NoEntityError |
|
463 |
|
464 def _onDelete(self, entity): |
|
465 """Called when an entity has been deleted. |
|
466 |
|
467 Classes that override this can use it to do any post-deletion operations. |
|
468 """ |
|
469 |
|
470 if not entity: |
|
471 raise NoEntityError |