Changeset 3398
- Timestamp:
- 07/29/07 14:40:04 (1 year ago)
- Files:
-
- trunk/Schevo/doc/SchevoTransactionHookMethods.txt (modified) (2 diffs)
- trunk/Schevo/schevo/entity.py (modified) (1 diff)
- trunk/Schevo/schevo/test/test_transaction_cdu_subclass.py (added)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/Schevo/doc/SchevoTransactionHookMethods.txt
r3189 r3398 12 12 ======== 13 13 14 When overriding the default implementations of Create, Delete, and Update 15 transactions for entity classes in a schema, there are hooks that make it 16 easy to change specific behavior. 14 Transaction hooks make it easy to change specific behavior of default 15 transaction classes. You can customize the following behaviors: 16 17 * Setup of a transaction instance. 18 19 * What happens just before standard transaction execution. 20 21 * What happens just after standard transaction execution. 17 22 18 23 … … 45 50 46 51 class _Update(T.Update): 52 ... 53 54 You can also create custom transactions that have names that differ 55 from the standard ones shown above. Remember to set up a `t` method 56 so you can create instances of your new transaction:: 57 58 class Foo(E.Entity): 59 60 bar = f.unicode() 61 count = f.integer() 62 63 def t_custom_update(self, **kw): 64 return E.Foo._CustomUpdate(self, **kw) 65 66 class _CustomUpdate(T.Update): 47 67 ... 48 68 trunk/Schevo/schevo/entity.py
r3306 r3398 202 202 # Fields in a transaction class defined in the schema appear 203 203 # below the fields that come from the entity field spec. 204 for name in ('_Create', '_Delete', '_Update'): 205 # Create a subclass. 204 for name in dir(cls): 206 205 OldClass = getattr(cls, name) 206 if not isinstance(OldClass, type): 207 continue 208 if not issubclass(OldClass, (transaction.Create, 209 transaction.Delete, 210 transaction.Update)): 211 continue 207 212 NewClass = type(name, (OldClass,), {}) 208 213 NewClass._EntityClass = cls
