that error only occurs when you hit a lazy loader on an object thats not in a session. so, any kind of session.clear(), session.expunge(), pickling/depickling, etc. before hitting the lazy loader can cause that to happen. once you identify that, put the object back into a session somehow, either via update(), merge(), etc.
On Jan 6, 2008, at 4:13 PM, Brendan Arnold wrote: > > Hi there, > > I have an object which has another sqlalchemy object joined to it and > that has a series of sqlalchemy objects joined to that. > > i.e. > > obj1 -> obj2 -> [obj3, obj4, obj5..] > > However when I try to access the list joined to object 2 I get the > following error, > > Traceback (most recent call last): > File "/usr/lib/python2.4/site-packages/Paste-1.4-py2.4.egg/paste/ > evalexception/evalcontext.py", > line 37, in exec_expr > exec code in self.namespace, self.globs > File "<web>", line 1, in ? > File "/usr/lib/python2.4/site-packages/SQLAlchemy-0.4.1-py2.4.egg/ > sqlalchemy/orm/attributes.py", > line 40, in __get__ > return self.impl.get(obj._state) > File "/usr/lib/python2.4/site-packages/SQLAlchemy-0.4.1-py2.4.egg/ > sqlalchemy/orm/attributes.py", > line 215, in get > value = callable_() > File "/usr/lib/python2.4/site-packages/SQLAlchemy-0.4.1-py2.4.egg/ > sqlalchemy/orm/strategies.py", > line 331, in lazyload > raise exceptions.InvalidRequestError("Parent instance %s is not > bound to a Session, and no contextual session is established; lazy > load operation of attribute '%s' cannot proceed" % > (instance.__class__, self.key)) > > This occurs even if I ensure obj2 lazy loads first i.e. > >>>> obj.obj2_attr and obj.obj2_attr.obj_list_attr > > What am I doing wrong? > > Brendan > > > --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---