[Zope] problem with commits in SQLAlchemyDA

Maric Michaud maric at aristote.info
Mon Aug 17 09:54:10 EDT 2009

Hi all,

I wanted to use SQALchemyDA with a standalone Zope 2.11 (we only depends 
on CMFCore).

i tried to get it up using easy_install, which is pretty 
straightforward, once removed the incompatible zope.component package 
needed in the dependencies.

It ends up with the following installed packages (skipping zope 3 
components) :

At first glance, this works well, but the DA actually can't manage to 
commit any sql requests (I try only for insert in Mysql and postgres but 
I'm sure it's always true).

This is quite an unexpectable behavior for a DA.

I think the problem is related to this thread I found on tg-trunk 
newsgroup :


There is a misleading comment in the docstring of 
zope.sqlalchemy.datamanager.join_transaction speaking of a 
DirtyAfterFlush SessionExtension, which I never seen except in plone code.

In the last I finally manage to make it work by monkey patching 
SQLAlchemyDA itself this way :

try :
     from Products.SQLAlchemyDA import da
     from z3c.sqlalchemy import getSAWrapper, createSAWrapper
     if '0.4.1' in da.__file__ and not hasattr(da.SAWrapper,
                               '_patched__wrapper_property') :
         da.SAWrapper._patched__wrapper_property = da.SAWrapper._wrapper

         def _always_invalidated_wrapper(self):
             """The property '_wrapper' patched by CFENet to correct what
             seems to be a bug in SQLAlchemyDA which prevents any
             from zope.sqlalchemy.datamanager import STATUS_INVALIDATED
             if self.dsn:
                     return getSAWrapper(self.util_id)
                 except ValueError:
                     return createSAWrapper(
                       self.dsn, forZope=True,
                       engine_options={'convert_unicode' : 	
                                       'encoding' : self.encoding},
                       extension_options={'initial_state': # the whole
                                                        # point is here
             return None

         da.SAWrapper._wrapper = property(_always_invalidated_wrapper)

except ImportError :

Anyone has any insights about this problem, any comments on my solution, 
did it have been reported and corrected, or am I simply missing something ?


Maric Michaud

More information about the Zope mailing list