demitri schrieb:
> Hi Diez,
> 
> Thanks for the reply. I'm still not sure about how this should work.
> The result of scoped_session is a class, not an instantiated session.
> The documentation says I should take the result of that and create a
> session object, e.g.
> 
> Session = scoped_session(sessionmaker(...))
> 
> session = Session()
> 
> If I do as you suggest, e.g. Session.query(...), I get this error:
> 
> TypeError: unbound method query() must be called with Session instance
> as first argument (got DeclarativeMeta instance instead)
> 
> which doesn't surprise me. But when I create a brand new project via
> paster, nowhere is Session() being called?
> 
> What am I missing??

This is strange. We do this:

DBSession = scoped_session(sessionmaker(
     autoflush=True,
     autocommit=False,
     ))

And we use it directly as this:

     def test_documents(self):
         immutable = db.Immutable(uid=random_uid(), mime_type="LiveSet", 
size=100000)
         imm_child = db.Immutable(uid=random_uid(), mime_type="FLAC", 
size=100000)
         immutable.children.append(imm_child)
         DBSession.flush() #...@undefinedvariable



I can't tell you why the direct use doesn't work. But what for sure is 
wrong is to instantiate the session in __init__ - because that creates 
*one session to rule them all* - which won't work. You don't want only 
one global transaction for the whole lifetime of your program...

Try then instantiating the session on demand - e.g. in controllers.

Diez

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"TurboGears" 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/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to