[Checkins] SVN: Products.SQLAlchemyDA/trunk/da.py try to unregister
wrapper utility in case of a DSN change
Andreas Jung
andreas at andreas-jung.com
Thu Jun 7 05:46:16 EDT 2007
Log message for revision 76451:
try to unregister wrapper utility in case of a DSN change
Changed:
U Products.SQLAlchemyDA/trunk/da.py
-=-
Modified: Products.SQLAlchemyDA/trunk/da.py
===================================================================
--- Products.SQLAlchemyDA/trunk/da.py 2007-06-07 09:45:55 UTC (rev 76450)
+++ Products.SQLAlchemyDA/trunk/da.py 2007-06-07 09:46:16 UTC (rev 76451)
@@ -60,13 +60,16 @@
def __init__(self, id, title=''):
self.id = id
self.title = title
+ self._new_utilid()
+
+ def _new_utilid(self):
self.util_id = '%s.%s' % (time.time(), random.random())
@property
def _wrapper(self):
if self.dsn:
try:
- return getSAWrapper(self.dsn)
+ return getSAWrapper(self.util_id)
except ValueError:
return createSAWrapper(self.dsn, forZope=True, name=self.util_id)
return None
@@ -243,6 +246,13 @@
""" Intercept changed properties in order to perform
further actions.
"""
+ if REQUEST.get('dsn') != self.dsn:
+ try:
+ from zope.component import unregisterUtility
+ unregisterUtility(name=self.util_id)
+ except ImportError:
+ self._new_utilid()
+
return PropertyManager.manage_editProperties(self, REQUEST)
More information about the Checkins
mailing list