Hi Michael, On Tue, 2012-01-31 at 10:26 -0500, Michael Bayer wrote:
> If you're using new_instance() to create the instance, then you are > deserializing data from somewhere, why isn't the discriminator value, > which is after all one of the column values in the table, not present > in this deserialization ? Because I considered the value of the "type" column an implementation detail and it was managed automatically by SQLAlchemy so far. Further, the serialized format is not that close to the database format (it is actually XML). > Right now the event in question is emitted only from the __init__() > method of your object, which is obviously what you don't call when > deserializing. The discriminator value is now considered to be just > another instance variable that you can change freely - a default for > it is configured from __init__(). I actually think about diverging from my original approach. In case anybody cares: So far, I am using __init__ to initialize some required columns from context (for example, the creator column is initialized from the current user). During deserialization this should not happen as the current user will probably be different from the creator of the received instance. Probably it will be more pythonic by changing the implementation that it is possible to create an empty instance for every class and catch missing information at the database level. > Anyway the event here is the "init" event which you can emit from > classmanager: > > manager.dispatch.init(state, args, kw) > > where "args", "kw" are what would normally be sent to __init__, but can just > be blank here. > > Invoking the events is not entirely public API, though. Thanks for the information. Therefore, I will probably go to set the discriminator column manually while deserialization can not go via __init__. Greetings, Torsten -- DYNAmore Gesellschaft fuer Ingenieurdienstleistungen mbH Torsten Landschoff Office Dresden Tel: +49-(0)351-4519587 Fax: +49-(0)351-4519561 mailto:[email protected] http://www.dynamore.de Registration court: Stuttgart, HRB 733694 Managing director: Prof. Dr. Karl Schweizerhof, Dipl.-Math. Ulrich Franz -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
