On Tue, Jul 29, 2008 at 10:54 AM, James Henstridge <[EMAIL PROTECTED]> wrote: > On Tue, Jul 29, 2008 at 10:37 AM, James Henstridge <[EMAIL PROTECTED]> wrote: >>> I don't have zope installed on my system and for repoze.tm2 I just >>> need the zope transaction package. >>> (from zope.testing.cleanup import addCleanUp and from >> >> Is zope.testing such a bad dependency? > > Looking at some of the Zope code there are things like: > > try: > from zope.testing.cleanup import addCleanUp > except ImportError: > # don't have that part of Zope > pass > else: > addCleanUp(_clear) > del addCleanUp > > If making zope.testing an optional dependency makes code reuse easier, > then we should probably do it.
The attached patch should make the storm.zope package usable with just zope.interface and transaction, while retaining all the other functionality when a more complete Zope is available. With this patch, are you able to use storm.zope.zstorm.global_zstorm directly for your wsgi app? James.
=== modified file 'storm/zope/__init__.py' --- storm/zope/__init__.py 2008-07-24 13:27:05 +0000 +++ storm/zope/__init__.py 2008-07-29 10:11:16 +0000 @@ -19,20 +19,27 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. # from zope.interface import classImplements -from zope.security.checker import NoProxy, BasicTypes, _available_by_default from storm.info import ObjectInfo from storm.store import EmptyResultSet, ResultSet from storm.zope.interfaces import IResultSet, ISQLObjectResultSet from storm import sqlobject as storm_sqlobject -# The following is required for storm.info.get_obj_info() to have -# access to a proxied object which is already in the store (IOW, has -# the object info set already). With this, Storm is able to -# gracefully handle situations when a proxied object is passed to a -# Store. -_available_by_default.append("__storm_object_info__") -BasicTypes[ObjectInfo] = NoProxy + classImplements(storm_sqlobject.SQLObjectResultSet, ISQLObjectResultSet) classImplements(ResultSet, IResultSet) classImplements(EmptyResultSet, IResultSet) + +try: + from zope.security.checker import NoProxy, BasicTypes, _available_by_default +except ImportError: + # We don't have zope.security installed. + pass +else: + # The following is required for storm.info.get_obj_info() to have + # access to a proxied object which is already in the store (IOW, has + # the object info set already). With this, Storm is able to + # gracefully handle situations when a proxied object is passed to a + # Store. + _available_by_default.append("__storm_object_info__") + BasicTypes[ObjectInfo] = NoProxy === modified file 'storm/zope/zstorm.py' --- storm/zope/zstorm.py 2008-06-26 11:57:22 +0000 +++ storm/zope/zstorm.py 2008-07-29 10:12:49 +0000 @@ -27,12 +27,14 @@ import threading import weakref -from zope.testing.cleanup import addCleanUp from zope.interface import implements import transaction from transaction.interfaces import IDataManager, ISynchronizer -from ZODB.POSException import TransactionFailedError +try: + from transaction.interfaces import TransactionFailedError +except ImportError: + from ZODB.POSException import TransactionFailedError from storm.zope.interfaces import IZStorm, ZStormError from storm.database import create_database @@ -286,4 +288,11 @@ global_zstorm = ZStorm() -addCleanUp(global_zstorm._reset) +try: + from zope.testing.cleanup import addCleanUp +except ImportError: + # We don't have zope.testing installed. + pass +else: + addCleanUp(global_zstorm._reset) + del addCleanUp
-- storm mailing list [email protected] Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/storm
