Hello everyone,
P.S.
I create session in another module like this:
Session=sessionmaker(bind=eng)
session=Session()
Then I import 'session' from that module in a main web app.
P.P.S. Backend is Postgres 8.1
I have added part for updating objects in my (web) application and get
very weird effect: if I update the same object several times, say, e.g.
add and delete some Hosts from Reservation.hosts (many to many
relation), on subsequent reads I get either a new value or one of the
old values.
I have checked that on updating the object the correct value gets
written to the backend db. It's just subsequent queries to the current
session randomly return one of the former object attribute values.
This lasts until the restart of the webserver, upon which the correct
value is read into session again.
To put it in more concrete terms, I have:
rsv = session.query(Reservation).filter(Reservation.id == int(rid)).first()
rhost =
session.query(Host).filter(Host.id.in_(rhostsel)).order_by(Host.ip).first()
host =
session.query(Host).filter(Host.id.in_(hostsel)).order_by(Host.ip).first()
for h in rsv.hosts:
if h.id == host.id:
rsv.hosts.remove(h)
rsv.hosts.append(rhost)
session.save_or_update(rsv)
session.flush()
session.commit()
session.expire(rsv, ['hosts'])
On subsequent refreshing, rsv.hosts is (randomly) one of the previous lists.
As you can see I have tried just about anything in the above code to
make session forget the previous value and read it from the db again.
All to no avail.
Python 2.6 / SQLA 0.5.3, but Python 2.4 / SQLA 0.5.2 exhibited the same
behavior. I'm using mod_python (3.3.1).
I would be very, very grateful if somebody helped out with this, I'm
pulling my hair out here.
Regards,
mk
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---