On Monday 12 November 2007 23:11:25 Michael Bayer wrote:
> On Nov 12, 2007, at 2:07 PM, [EMAIL PROTECTED] wrote:
> > hi
> > 1st one:  i am saving some object; the mapperExtension of the
> > object fires additional atomic updates of other things elsewhere
> > (aggregator).
> > These things has to be expired/refreshed... if i only knew them.
> > For certain cases, the object knows exactly which are these
> > target things. How (when) is best to expire these instances, i.e.
> > assure that nexttime they are used they will be re-fetched?
> > a) in the mapperext - this would be before the flush?
> > b) later, after flush, marking them somehow ?
>
> the "public" way to mark an instance as expired is
> session.expire(instance).  if you wanted to do this inside the
> mapper extension, i think its OK as long as you do the expire
> *after* the object has been inserted/updated (i.e. in
> after_insert() or after_update()).
lets say A points to B and A.price is accumulated in the B, and that B 
needs be expired.
i've done expire in the A.mapExt.after_insert(). 
but A trouble comes when creating both A and B: they are not not yet 
persistent and the expire() (as well as the refresh() hits this:
    session.refresh( g)
  File "sqlalchemy/orm/session.py", line 725, in refresh
    if self.query(obj.__class__)._get(obj._instance_key, reload=True) 
is None:
AttributeError: _instance_key

i'm not sure if i am doing proper thing at all.
Something like i need intermediate flush() to get B in the database 
first; then the insert of A will update that B and expire it 
eventualy.
i.e. i need to have the B record in the DB in order to have the 
aggregation /update working; else i am updating nothing...

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to