On Dec 11, 2008, at 2:04 PM, Ross Vandegrift wrote:

>
> Hi guys,
>
> I'm somewhat confused about the different lifecycle states of objects
> that are backed by the SA ORM.
>
> According to the SA docs (FWIW, I'm on 0.4), an object is in the
> Persistent state when it is present in the session and has a record in
> the database.
>
> So if I do something like this:
>
> p = meta.session.query(model.Pool)
> pool = p.get(7)
> meta.session.refresh(pool)
> InvalidRequestError: Instance 'p...@0xa6aca8c' is not persistent  
> within this Session

um thats kind of weird.   that sort of looks like meta.session is  
being closed out at some point (i.e. not illustrated in the example)  
and being recreated later on is that possible ?

heres a test

from sqlalchemy import *
from sqlalchemy.orm import *

e = create_engine('sqlite://', echo=True)
m = MetaData(e)
t = Table('t', m, Column('id', Integer, primary_key=True))
t.create()

class C(object):
     pass
mapper(C, t)
s = sessionmaker()()

s.save(C())
s.flush()
s.clear()

c1 = s.query(C)
c1 = c1.get(1)
s.refresh(c1)



--~--~---------~--~----~------------~-------~--~----~
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 
sqlalchemy+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to