Thanks for the pointer to the source. My confusion came from the Zope docs (and other sources e.g. this answer: https://stackoverflow.com/a/58567212/123033 ) that seemed to suggest *EITHER* from zope.sqlalchemy import ZopeTransactionExtension, register *OR* changing all instances of ZopeTransactionExtension to ZopeTransactionEvents and using: from zope.sqlalchemy import register then DBSession = scoped_session(sessionmaker(**options)) but the below - i.e. no parameters to sessionmaker() - got past the errors in the end (so far so good, anyway):
from zope.sqlalchemy import register # . . . DBSession = scoped_session(sessionmaker()) register(DBSession) Feel free to point out anything glaringly obvious. I've not been in this territory before, and it's a codebase in which I'm still finding my way (written by a codev) and yes, I might not spot what's taken for granted by anyone more familiar with SQLAlchemy etc. - I've often been in the reverse situation! On Saturday, October 24, 2020 at 6:55:42 PM UTC+1 Jonathan Vanasco wrote: > The extract code you posted is incorrect. > > You were given a step towards the right answer - you MUST invoke > `register`. > > I say a step, because there may be other factors going on. > > However as you can see from the source code ( > https://github.com/zopefoundation/zope.sqlalchemy/blob/master/src/zope/sqlalchemy/datamanager.py#L293-L329), > > the call to `register` is required because it invokes the > ZopeTransactionExtenstion AND sets up the transaction events. > > On Saturday, October 24, 2020 at 10:47:27 AM UTC-4 dever...@gmail.com > wrote: > >> I'm updating a working Pyramid app that uses sqlalchemy and have some >> success by replacing ZopeTransactionExtension with ZopeTransactionEvents. >> >> On running initialise with my local .ini file, All goes well, the >> database tables (MariaDB) are all written, but these errors occur: >> >> Traceback (most recent call last): >> "[...]sqlalchemy/util/_collections.py", line 1055, in __call__ return >> self.registry.value AttributeError: '_thread._local' object has no >> attribute 'value' During handling of the above exception, another exception >> occurred: >> >> [cruft omitted] >> "[...]sqlalchemy/orm/deprecated_interfaces.py", line 367, in >> _adapt_listener ls_meth = getattr(listener, meth) AttributeError: >> 'ZopeTransactionEvents' object has no attribute 'after_commit' >> >> For more code details, I've posted extracts from the models and main app >> code on StackOverflow <https://stackoverflow.com/q/64486574/123033>, but >> with no joy so far. >> > -- SQLAlchemy - The Python SQL Toolkit and Object Relational Mapper http://www.sqlalchemy.org/ To post example code, please provide an MCVE: Minimal, Complete, and Verifiable Example. See http://stackoverflow.com/help/mcve for a full description. --- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/sqlalchemy/f9e9fe92-7f61-43b8-8473-78cb204a74bcn%40googlegroups.com.