Hello,

I'm having a problem whereby one of my ORM objects seems to wind up
with outdated values.  First some background...

In the application I'm working on, all the inserts and updates are
done directly with cx_Oracle, while I'm using SQLAlchemy only to fetch
the data from the database.  (This is not necessarily a good design,
but for practical purposes I'm stuck with the direct cx_Oracle code).

Another factor, perhaps -- I have several objects that have relations
between parent and child in two directions, for example:

        mapper(Thing1, thing1Table,
               properties=dict(thing2=relation(Thing2, ...,
cascade='save-update,merge,refresh-expire' ...

        mapper(Thing2, thing2Table,
               properties=dict(thing1=relation(Thing1, ...,
cascade='save-update,merge,refresh-expire' ...

because in some situations I'd like to show the user all the thing2's
in a particular thing1, and sometimes all the thing1's in a particular
thing2.

Yet another factor, perhaps -- although the tutorial says that
sessions are something you should treat as a local workspace and you
should instantiate and close them often, the objects I want to show
the user are long-lived.  So it doesn't seem practical to keep closing
the session.

So the problem is, I do the query and show the object to the user, say
thing1. Then using cx_Oracle, I change thing1.thing2.someAttribute in
the database.  Then I expire thing1.  But when I show the user thing1
again, thing1.thing2.someAttribute contains the old value.

Shouldn't the 'refresh-expire' argument cause
thing1.thing2.someAttribute to be re-fetched automatically?

Is it ok to have these two-way relations (without a backref?)

Is it ok to have one long session for the life the application?  (It's
a thick app, not a web app).  If not, won't my objects go away when I
close the session?

Although explicitly expiring thing1 doesn't seem to help, explicitly
refreshing it seems to fix the problem.  Aren't those essentially the
same thing?

ActiveState Python 2.4.1
SQLAlchemy 0.5.0beta2
WinXP

Any help greatly appreciated,
Matthew

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to