thanks a lot, that cleared some mist. btw u can make a entry on the FAQ from this... e.g. "lifetimes and usage patterns" - or similar.
> > The other rule inferred from above problem is > > b) objects lifetime should be shorter than mappers (ORM); else > > one needs to delete o._instance_key and o.db_id to be able to > > reuse them > > do you mean, when you say clear_mappers() ? im not sure what the > use case for that is. It is that objects exist fot their own sake; than at certain time some db mapping is made, they are saved to a database, then all that db-related stuff (+mappers) is dropped, and objects keep living. Next time it might be different db/mapping/etc - but eventualy same objects. As i understand it, the ORMapping makes some irreversible changes to the objects/classes (e.g. Instrumented descriptors, __init__ etc), so the above scenario will never be without side effects, and it will be preferable to make some deep copy of the structure (class- and instance wise) and do all the ORmapping over the copies. and as i understand, i can delay metadata engine-binding and .create_data() until really required (1st db-operation). Right? now i meant this one: > > or (current links/nodes case) > > 1. objects (instances) > > 2. engine > > 3. metadata + createall() > > 4. mappers > > 5. drop everything > > repeat 2,3,4,5 > > if by "objects" you mean "instances" and not "classes", and you > mean "create new mappers each time", tricky. differerent mappers > define different attributes for the objects. what happens to the > state of the old attributes ? just gets thrown away ? if you can > ignore that issue, just remove the _instance_key from the objects > and save() them into a new session. i needed this just for testing, so mappers are all same over and over, and attributes gets overwriten anyway. yeah, if mappers are different everytime it becomes a mess. But if mapping is same every time, just remade a new, then it's a non-optimized variant of the following case: > > or (probably better way of doing it, make type-info stuff once) > > 1. engine > > 2. metadata + createall() > > 3. mappers > > 4. objects > > 5. metadata.drop_all() + metadata.create_all() > > 6. save same objects > > repeat 5,6 > > yes, if you clear out the _instance_key on the objects and save() > them into a new session. ok that works. And i may keep a track of all these objects in some weakref list, and wash them each time. ciao svil --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
