opensubscriber
   Find in this group all groups
 
Unknown more information…

z : zope@zope.org 17 August 2009 • 9:54PM -0400

[Zope] problem with commits in SQLAlchemyDA
by Maric Michaud

REPLY TO AUTHOR
 
REPLY TO GROUP




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) :
zope.sqlalchemy-0.4-py2.4.egg
z3c.sqlalchemy-1.3.10.1-py2.4.egg
SQLAlchemy-0.5.5-py2.4.egg
Products.SQLAlchemyDA-0.4.1-py2.4.egg

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 :

http://www.mail-archive.com/turbogears-trunk@goog.../msg07302.html

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
             commit."""
             from zope.sqlalchemy.datamanager import STATUS_INVALIDATED
             if self.dsn:
                 try:
                     return getSAWrapper(self.util_id)
                 except ValueError:
                     return createSAWrapper(
                       self.dsn, forZope=True,
                       transactional=self.transactional,
                       engine_options={'convert_unicode' :
                                             self.convert_unicode,
                                       'encoding' : self.encoding},
                       extension_options={'initial_state': # the whole
                                                        # point is here
                                             STATUS_INVALIDATED},
                       name=self.util_id)
             return None

         da.SAWrapper._wrapper = property(_always_invalidated_wrapper)

except ImportError :
     pass


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

_______________________________________________
Zope maillist  -  Zope@zope...
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists -
http://mail.zope.org/mailman/listinfo/zope-announce
http://mail.zope.org/mailman/listinfo/zope-dev )

Bookmark with:

Delicious   Digg   reddit   Facebook   StumbleUpon

Related Messages

opensubscriber is not affiliated with the authors of this message nor responsible for its content.