Alan Franzoni ha scritto:

    The problem is that it requires the explicit use of the session.
    In my case this means that I can not delete the object inside a method
    of my class.

    class A(object):
        def enableB(enable=True):
           if enable:
              self.b = B(...)
           else:
              del self.b


    Not a big problem, however.


There's the 'threadlocal' that should let you work as you like, but I've read its use is discouraged because it could lead to strange bugs.

BTW, couldn't you just pass your session to the methods requiring it?

class A(object):
    def enableB(enable=True, session):
       if enable:
          self.b = B(...)
       else:
          session.delete(self.b)


A better solution is to do
sess = object_session(self)



Regards  Manlio Perillo

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