[z3-checkins] r26204 - z3/sqlos/trunk/src/sqlos
jinty at codespeak.net
jinty at codespeak.net
Mon Apr 24 01:31:40 CEST 2006
Author: jinty
Date: Mon Apr 24 01:31:35 2006
New Revision: 26204
Added:
z3/sqlos/trunk/src/sqlos/zsqlobject.py
- copied unchanged from r26203, z3/sqlos/trunk/src/sqlos/_sqlos.py
Removed:
z3/sqlos/trunk/src/sqlos/_sqlos.py
Log:
Forgotten in the last commit
Deleted: /z3/sqlos/trunk/src/sqlos/_sqlos.py
==============================================================================
--- /z3/sqlos/trunk/src/sqlos/_sqlos.py Mon Apr 24 01:31:35 2006
+++ (empty file)
@@ -1,85 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2004 Enfold Systems LLC. All rights reserved.
-#
-# This software is distributed under the terms of the Zope Public
-# License (ZPL) v2.1. See COPYING.txt for more information.
-#
-##############################################################################
-"""
-$Id: __init__.py 5216 2004-06-21 18:33:07Z dreamcatcher $
-"""
-
-from zope.interface import implements
-from sqlobject.main import SQLObject
-from sqlobject import StringCol
-
-from sqlos.connection import ConnectionDescriptor
-from sqlos.interfaces import ISQLObject
-
-class SQLOS(SQLObject):
- """Subclass SQLObject to enable ``lazy updates`` by default,
- as well as adding knowledge to register ``dirty`` objects
- with SQLObjectTransactionManager so they get sync'd on transaction
- boundaries.
-
- First, make a test data base:
-
- >>> from sqlos import testing
- >>> testdb = testing.TestDB([SQLOS])
-
- Test the interface:
-
- >>> s = SQLOS()
- >>> from zope.interface.verify import verifyObject
- >>> verifyObject(ISQLObject, s)
- True
-
- And finally call tearDown and cleanup:
-
- >>> testdb.tearDown()
- """
- implements(ISQLObject)
- _connection = ConnectionDescriptor()
-
- class sqlmeta:
- lazyUpdate = True
-
- def _set_dirty(self, value):
- if value:
- self._connection._dm.register(self)
- # This breaks the transaction functional tests and seems to be an
- # optimization only. So I've commented it out. - jinty 2005-10-5
- #else:
- # # XXX: 'objects' shouldn't really be fiddled directly like this.
- # # Probably there should be an unregister function.
- # # - Andrew Bennetts, 2005-01-05
- # self._connection._dm.objects.discard(self)
- self._dirty = value
-
- def _get_dirty(self):
- return self._dirty
-
- dirty = property(_get_dirty, _set_dirty)
-
- def get(self, id, connection=None, selectResults=None):
- # While interacting with zope, we may end up having
- # objects in the cache that have a __parent__ set.
- # This may be confusing when expect to get a object
- # which has no __parent__ and thats not what you get.
- val = super(SQLOS, self).get(id, connection=connection,
- selectResults=selectResults)
- if getattr(val, '__parent__', None) is not None:
- val.__parent__ = None
- val.__name__ = None
- return val
- get = classmethod(get)
-
- def __repr__(self):
- return '<%s at 0x%x>' % (self.__class__.__name__, id(self))
-
- def setConnection(self, connection):
- if connection is not None:
- self._connection = connection
-
- setConnection = classmethod(setConnection)
More information about the z3-checkins
mailing list