[Grok-dev] zope.sqlalchemy explodes because of new SQLAlchemy

Brandon Craig Rhodes brandon at rhodesmill.org
Thu Jun 26 15:07:12 EDT 2008

In case this helps any of the rest of you, especially those who might be
using megrok.rdb (which uses zope.sqlalchemy, right?): they seem to have
released some SQLAlchemy eggs for the upcoming 0.5 beta, which when
combined with zope.sqlalchemy break non-deterministicly.  One symptom is:

  File "/home/brandon/IamAPI/test/eggs/SQLAlchemy-0.5.0beta1-py2.5.egg/sqlalchemy/orm/session.py", line 329, in _connection_for_bind
    self.session.extension.after_begin(self.session, self, conn)
  File "/home/brandon/IamAPI/test/eggs/zope.sqlalchemy-0.1-py2.5.egg/zope/sqlalchemy/datamanager.py", line 184, in after_begin
    join_transaction(session, self.initial_state)
  File "/home/brandon/IamAPI/test/eggs/zope.sqlalchemy-0.1-py2.5.egg/zope/sqlalchemy/datamanager.py", line 165, in join_transaction
    zope_transaction.get().join(DataManager(session, initial_state))
  File "/home/brandon/IamAPI/test/eggs/zope.sqlalchemy-0.1-py2.5.egg/zope/sqlalchemy/datamanager.py", line 46, in __init__
    if session.transactional:
AttributeError: 'Session' object has no attribute 'transactional'

Another symptom is:

  File "/home/brandon/IamAPI/test/eggs/SQLAlchemy-0.5.0beta1-py2.5.egg/sqlalchemy/orm/session.py", line 1392, in flush
    self.extension.after_flush(self, flush_context)
  File "/home/brandon/IamAPI/test/eggs/zope.sqlalchemy-0.1-py2.5.egg/zope/sqlalchemy/datamanager.py", line 187, in after_flush
  File "/home/brandon/IamAPI/test/eggs/zope.sqlalchemy-0.1-py2.5.egg/zope/sqlalchemy/datamanager.py", line 170, in invalidate
    assert _SESSION_STATE[id(session)] is not STATUS_READONLY
KeyError: 3049156876L

If you see these errors, as I did today, then the solution seems to be
editing the setup.py of your application and writing:

                         # Add extra requirements here

That way, before zope.sqlalchemy is consulted for its dependencies,
buildout (or setuptools?) will go ahead and download and install a
version of SQLAlchemy that works with zope.sqlalchemy.

Having downgraded SQLAlchemy to 0.4.6, I have now seen more than an hour
of stable operation.  Should that change, and it wasn't the version
difference that broke me, then I'll reply to this email with a
retraction; but the version difference was the only difference I could
find between to instances I had of my installation, one of which worked
and the other of which did not.

Brandon Craig Rhodes   brandon at rhodesmill.org   http://rhodesmill.org/brandon

More information about the Grok-dev mailing list