The error goes away when I make the session expire_on_commit=False., But its
a nice feature to have, how can I fix the exception below retaining this
feature?

---------- Forwarded message ----------
From: Harish K Vishwanath <[EMAIL PROTECTED]>
Date: Fri, Aug 22, 2008 at 11:04 AM
Subject: Facing Invalid Request Error in 0.5beta4r5051
To: sqlalchemy@googlegroups.com


Hello,

I am getting a sa.exc.InvalidRequestError in SALA 0.5beta4, which never
happened in SQLA 0.4.6

SQLA 0.4.6 : sqlalchemy.orm.sessionmaker(bind=None, autoflush=False,
transactional=True)
SQLA 0.5beta4 : sqlalchemy.orm.sessionmaker(bind=None, autoflush=False,
autocommit=False)

Apart from this, as per the documentation the SQLA 0.5 session is
autoexpire=True, which expires all objects after a commit call. Below is the
traceback of the exception :


  File "SchemaTest.py", line 193, in ?
    user = myDB.CreateTestUser(msg)
  File "d:\recogsys\src\python\RSITerm\SQLConvert\SqlDB.py", line 633, in
Create
TestUser
    oiUser.SetAuthority('Authority', self)
  File "d:\recogsys\src\python\RSITerm\SQLConvert\SqlUser.py", line 154, in
SetA
uthority
    self.PostInteraction(rsiDB, 'Authority', str(val), targetUserID)
  File "d:\recogsys\src\python\RSITerm\SQLConvert\SqlUser.py", line 1056, in
Pos
tInteraction
    rsiDB.AddInteraction(iao)
  File "d:\recogsys\src\python\RSITerm\SQLConvert\SqlDB.py", line 418, in
AddInt
eraction
    return interaction.InteractionID
  File
"c:\python24\lib\site-packages\SQLAlchemy-0.5.0beta4dev_r5051-py2.4.egg\s
qlalchemy\orm\attributes.py", line 135, in __get__
    return self.impl.get(instance_state(instance))
  File
"c:\python24\lib\site-packages\SQLAlchemy-0.5.0beta4dev_r5051-py2.4.egg\s
qlalchemy\orm\attributes.py", line 319, in get
    value = callable_()
  File
"c:\python24\lib\site-packages\SQLAlchemy-0.5.0beta4dev_r5051-py2.4.egg\s
qlalchemy\orm\attributes.py", line 877, in __call__
    class_manager.deferred_scalar_loader(self, [
  File
"c:\python24\lib\site-packages\SQLAlchemy-0.5.0beta4dev_r5051-py2.4.egg\s
qlalchemy\orm\mapper.py", line 1701, in _load_scalar_attributes
    result = session.query(mapper)._get(identity_key, refresh_state=state,
only_
load_props=attribute_names)
  File
"c:\python24\lib\site-packages\SQLAlchemy-0.5.0beta4dev_r5051-py2.4.egg\s
qlalchemy\orm\query.py", line 1181, in _get
    return q.all()[0]
  File
"c:\python24\lib\site-packages\SQLAlchemy-0.5.0beta4dev_r5051-py2.4.egg\s
qlalchemy\orm\query.py", line 979, in all
    return list(self)
  File
"c:\python24\lib\site-packages\SQLAlchemy-0.5.0beta4dev_r5051-py2.4.egg\s
qlalchemy\orm\query.py", line 1044, in __iter__
    return self._execute_and_instances(context)
  File
"c:\python24\lib\site-packages\SQLAlchemy-0.5.0beta4dev_r5051-py2.4.egg\s
qlalchemy\orm\query.py", line 1047, in _execute_and_instances
    result = self.session.execute(querycontext.statement,
params=self._params, m
apper=self._mapper_zero_or_none(), _state=self._refresh_state)
  File
"c:\python24\lib\site-packages\SQLAlchemy-0.5.0beta4dev_r5051-py2.4.egg\s
qlalchemy\orm\session.py", line 744, in execute
    return self.__connection(engine, close_with_result=True).execute(
  File
"c:\python24\lib\site-packages\SQLAlchemy-0.5.0beta4dev_r5051-py2.4.egg\s
qlalchemy\orm\session.py", line 711, in __connection
    return self.transaction._connection_for_bind(engine)
  File
"c:\python24\lib\site-packages\SQLAlchemy-0.5.0beta4dev_r5051-py2.4.egg\s
qlalchemy\orm\session.py", line 309, in _connection_for_bind
    self._assert_is_active()
  File
"c:\python24\lib\site-packages\SQLAlchemy-0.5.0beta4dev_r5051-py2.4.egg\s
qlalchemy\orm\session.py", line 243, in _assert_is_active
    raise sa_exc.InvalidRequestError(
sqlalchemy.exc.InvalidRequestError: The transaction is inactive due to a
rollbac
k in a subtransaction.  Issue rollback() to cancel the transaction.

The line rsiDB.AddInteraction(iao), calls a commit() after adding the
object. In SQLA0.5beta4, the object which was attached to the session is
expired after commit? The next statment which is trying to return object.id,
is issuing another query but is getting an inactive transaction and hence
the error. Correct?

This doesn't happen in SQLA 0.4.6. How can I fix this error? Please note
that I am handling all exceptions that can be raised by a commit() call ,
issuing a rollback and reporting them. But I dont seen any rollbacks at all,
but even then the exception says so. Appreciate any inputs.

Thanks,
Harish




-- 
Regards,
Harish

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