Hi Michael,
This is a complete traceback produced by removing my checking code against attribute modification.
Original code is then as simple as this:
@ajax.handler
def updateOrderMenuItemBO(self):
session = getSession(SESSION_NAME)
ids = [ int(id) for id in self.request.form.get('ids') ]
for menu in session.query(MenuItemBO).filter(MenuItemBO.id.in_(ids)):
menu.rang = index
return getUtility(IJSONWriter).write({ 'status': 'OK' })
File '/var/local/env/rdf/lib/python2.5/site-packages/Paste-1.7.5.1-py2.5.egg/paste/evalexception/middleware.py', line 306 in respond
app_iter = self.application(environ, detect_start_response)
File '/var/local/env/rdf/webapp/src/webapp/startup.py', line 33 in wrapper
return app(environ, start_response)
File '/var/local/env/rdf/webapp/eggs/zope.app.wsgi-3.4.3-py2.5.egg/zope/app/wsgi/__init__.py', line 55 in __call__
request = publish(request, handle_errors=handle_errors)
File '/var/local/env/rdf/webapp/eggs/zope.publisher-3.4.10-py2.5.egg/zope/publisher/publish.py', line 138 in publish
publication.afterCall(request, obj)
File '/var/local/env/rdf/webapp/eggs/zope.app.publication-3.4.4-py2.5.egg/zope/app/publication/browser.py', line 78 in afterCall
super(BrowserPublication, self).afterCall(request, ob)
File '/var/local/env/rdf/webapp/eggs/zope.app.publication-3.4.4-py2.5.egg/zope/app/publication/zopepublication.py', line 175 in afterCall
txn.commit()
File '/var/local/env/rdf/webapp/eggs/ZODB3-3.8.5-py2.5-linux-x86_64.egg/transaction/_transaction.py', line 325 in commit
self._commitResources()
File '/var/local/env/rdf/webapp/eggs/ZODB3-3.8.5-py2.5-linux-x86_64.egg/transaction/_transaction.py', line 432 in _commitResources
rm.tpc_finish(self)
File '/var/local/src/ztfy/ztfy.alchemy/ztfy/alchemy/datamanager.py', line 148 in tpc_finish
self.tx.commit()
File '/var/local/env/rdf/webapp/eggs/SQLAlchemy-0.7.3-py2.5-linux-x86_64.egg/sqlalchemy/orm/session.py', line 317 in commit
t[1].commit()
File '/var/local/eggs-2.5/SQLAlchemy-0.7.3-py2.5-linux-x86_64.egg/sqlalchemy/engine/base.py', line 1971 in commit
self._do_commit()
File '/var/local/eggs-2.5/SQLAlchemy-0.7.3-py2.5-linux-x86_64.egg/sqlalchemy/engine/base.py', line 2059 in _do_commit
self.connection._commit_twophase_impl(self.xid, self._is_prepared)
File '/var/local/eggs-2.5/SQLAlchemy-0.7.3-py2.5-linux-x86_64.egg/sqlalchemy/engine/base.py', line 1290 in _commit_twophase_impl
self.engine.dialect.do_commit_twophase(self, xid, is_prepared)
File '/var/local/eggs-2.5/SQLAlchemy-0.7.3-py2.5-linux-x86_64.egg/sqlalchemy/dialects/oracle/cx_oracle.py', line 720 in do_commit_twophase
self.do_commit(connection.connection)
File '/var/local/env/rdf/webapp/eggs/SQLAlchemy-0.7.3-py2.5-linux-x86_64.egg/sqlalchemy/engine/default.py', line 306 in do_commit
connection.commit()
DatabaseError: ORA-24756: la transaction n'existe pas
SA integration in Zope in done throught my own "ztfy.alchemy" package, which is mainly a copy of "zope.alchemy" package to which I added several utility tools to facilitate engines definition via persistent utilities. But the transaction machinery is unchanged.
Session definition in getSession function is globally done as follows (simplified):
def getSession(dsn, status=STATUS_ACTIVE):
engine = sqlalchemy.create_engine(dsn,echo,pool_size,pool_recycle,encoding,convert_unicode,strategy='threadlocal')
factory = scoped_session(sessionmaker(bind=engine, twophase=True, extension=ZopeTransactionExtension()))
session = factory()
if join:
join_transaction(session, initial_state=status)
return session
Adding a few traces in ZopeTransactionException class also add these messages on the console:
>>> after begin
2012-11-20T10:01:12 INFO sqlalchemy.engine.threadlocal.TLEngine SELECT consultbo."MENU_ITEM_BO".id AS "consultbo_MENU_ITEM_BO_id", consultbo."MENU_ITEM_BO".id_app AS "consultbo_MENU_ITEM_BO_id_app", consultbo."MENU_ITEM_BO".id_appapp AS "consultbo_MENU_ITEM_BO_i_1", consultbo."MENU_ITEM_BO".niveau AS "consultbo_MENU_ITEM_BO_niveau", consultbo."MENU_ITEM_BO".libelle AS "consultbo_MENU_ITEM_BO_libelle", consultbo."MENU_ITEM_BO".rang AS "consultbo_MENU_ITEM_BO_rang", consultbo."MENU_ITEM_BO".nature AS "consultbo_MENU_ITEM_BO_nature"
FROM consultbo."MENU_ITEM_BO"
WHERE consultbo."MENU_ITEM_BO".id IN (:id_1, :id_2, :id_3, :id_4, :id_5, :id_6, :id_7, :id_8, :id_9)
2012-11-20 10:01:12,266 INFO sqlalchemy.engine.threadlocal.TLEngine {'id_2': 8, 'id_3': 1, 'id_1': 11, 'id_6': 12, 'id_7': 13, 'id_4': 10, 'id_5': 5, 'id_8': 14, 'id_9': 15}
------
>>> after flush
>>> before commit
------
2012-11-20T10:01:12 CRITICAL txn.139760315672320 A storage error occurred during the second phase of the two-phase commit. Resources may be in an inconsistent state.
>>> after rollback
Hope this can help to understand the problem; any advise is greatly welcome...
Best regards,
Thierry