Alexandre CONRAD wrote: > Don't forget to answer my question: "What are the benefits of > instantiating a Session object ?". Actually, I just feel better working > *with* a instantiated object.
Hey, I just set my code to instantiate the session, and I get the following error when I delete a client (which has a bunch of cascading "all, delete-orphan" rules). session = Session() NB: I've mapped the session.delete function to my "model" object for convenience: model.delete = session.delete File '<string>', line 1 in <lambda> File '/var/www/html/dev/tlv/mp/mp/lib/base.py', line 71 in wrapper return check(func, *args, **kwargs) File '/var/www/html/dev/tlv/mp/mp/lib/base.py', line 68 in check return func(*args, **kwargs) File '/var/www/html/dev/tlv/mp/mp/controllers/clients.py', line 89 in delete model.delete(client) File '/usr/lib/python2.4/site-packages/SQLAlchemy-0.4.0dev_r3224-py2.4.egg/sqlalchemy/orm/session.py', line 621 in delete self.uow.register_deleted(c) File '/usr/lib/python2.4/site-packages/SQLAlchemy-0.4.0dev_r3224-py2.4.egg/sqlalchemy/orm/unitofwork.py', line 156 in register_deleted self._validate_obj(obj) File '/usr/lib/python2.4/site-packages/SQLAlchemy-0.4.0dev_r3224-py2.4.egg/sqlalchemy/orm/unitofwork.py', line 121 in _validate_obj raise exceptions.InvalidRequestError("Instance '%s' is not attached or pending within this session" % repr(obj)) InvalidRequestError: Instance '<mp.model.clients.Client object at 0x18fd9d0>' is not attached or pending within this session I changed my code back to normal non-instantiated session: session = Session And it works fine. Regards, Alex --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---