14 May 17:06
Pre-commit hooks
From: Yannick Gingras <ygingras <at> ygingras.net>
Subject: Pre-commit hooks
Newsgroups: gmane.comp.python.sqlalchemy.user
Date: 2008-05-14 15:07:00 GMT
Subject: Pre-commit hooks
Newsgroups: gmane.comp.python.sqlalchemy.user
Date: 2008-05-14 15:07:00 GMT
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 + self.fluids) < 50
mapper(Item, items_table)
I don't want to put the test mutators of dry_weight or fluids since
it's OK to have a temporary inconsistent state as long as the state is
consistent at commit time.
I see that some of this functionality if covered by MapperExtention
but since the test is only related to Item I'd rather put the test in
it.
--
--
Yannick Gingras
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "sqlalchemy" group.
To post to this group, send email to sqlalchemy <at> googlegroups.com
To unsubscribe from this group, send email to sqlalchemy-unsubscribe <at> googlegroups.com
For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---
(Continue reading)
RSS Feed