jeff emminger wrote:
> 
> is SA not calling __init__ or am i doing something wrong?
> thanks,

As of 0.2, SA uses __new__ to create instances instead of __init__ (this is 
mainly to allow code that only needs to run once - when the object is first 
created, not every time an instance is constructed from the db). Mike 
elaborated 
on this in answer to a question of mine:

Michael Bayer wrote:
 > calling __new__ is more equivalent to your objects being "pickled" and
 > restored from their "pickled" state.  in theory whatever state you set
 > up in your __init__ method when you first create the object, should have
 > been stored to the database, and then loaded back.  having it use
 > __new__ instead of __init__ allows objects to differentiate between
 > construction and loading.   thats why your __init__ no longer needs its
 > arguments to be optional.
 >
 > if you need customized things to be done when the instance is loaded
 > back from the database, the idea is that youd make a MapperExtension
 > with create_instance() overridden, which returns a new instance with
 > whatever else you wanted (i.e. it can just create the object normally):
 >
 > class MyExt(MapperExtension):
 >     def create_instance(self, mapper, session, row, imap, class_):
 >         return MyObject()
 >
 > mapper(MyObject, table, extension=MyExt())


HTH

Robert

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Sqlalchemy-users mailing list
Sqlalchemy-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users

Reply via email to