Michael Bayer [EMAIL PROTECTED] writes:
easy enough to build yourself a generic MapperExtension that scans
incoming objects for a _pre_commit() method.
Yeah indeed. I used this:
--
class HookExtension(MapperExtension):
Extention to add pre-commit hooks.
On 5/15/08, Yannick Gingras [EMAIL PROTECTED] wrote:
Michael Bayer [EMAIL PROTECTED] writes:
easy enough to build yourself a generic MapperExtension that scans
incoming objects for a _pre_commit() method.
Yeah indeed. I used this:
--
class
speed wise, this is better: hasattr is implemented as getattr + try
except. i would do it even:
f = getattr(instance, _pre_insert, None)
if f: f()
Thus the func name is spelled only once - avoids stupid mistakes.
On Thursday 15 May 2008 17:36:52 Roger Demetrescu wrote:
On 5/15/08, Yannick
On 5/15/08, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:
speed wise, this is better: hasattr is implemented as getattr + try
except. i would do it even:
f = getattr(instance, _pre_insert, None)
if f: f()
Thus the func name is spelled only once - avoids stupid mistakes.
Good point...
[EMAIL PROTECTED] writes:
speed wise, this is better: hasattr is implemented as getattr + try
except. i would do it even:
f = getattr(instance, _pre_insert, None)
if f: f()
Thus the func name is spelled only once - avoids stupid mistakes.
Spelling only once is the killer feature of
On May 14, 2008, at 11:07 AM, Yannick Gingras wrote:
Greetings Alchemists,
Is it possible to define a hook in a mapped class that will be called
to test the sanity of an instance before it gets committed?
As an example:
class Item(object):
def _pre_commit(self):
assert
Yannick Gingras wrote:
Greetings Alchemists,
Is it possible to define a hook in a mapped class that will
be called
to test the sanity of an instance before it gets committed?
As an example:
class Item(object):
def _pre_commit(self):
assert (self.dry_weight +