[Zope-Checkins] CVS: ZODB3/Persistence - PersistentList.py:1.3.96.1
PersistentMapping.py:1.20.96.1 __init__.py:1.4.88.3
TimeStamp.c:NONE cPersistence.c:NONE cPersistence.h:NONE
cPickleCache.c:NONE ring.c:NONE ring.h:NONE
Jim Fulton
cvs-admin at zope.org
Tue Oct 28 16:29:00 EST 2003
Update of /cvs-repository/ZODB3/Persistence
In directory cvs.zope.org:/tmp/cvs-serv9166/Persistence
Modified Files:
Tag: zodb33-devel-branch
PersistentList.py PersistentMapping.py __init__.py
Removed Files:
Tag: zodb33-devel-branch
TimeStamp.c cPersistence.c cPersistence.h cPickleCache.c
ring.c ring.h
Log Message:
Renamed the Persistence package to persistent.
The Persistence package is still there for backward compatability.
=== ZODB3/Persistence/PersistentList.py 1.3 => 1.3.96.1 ===
--- ZODB3/Persistence/PersistentList.py:1.3 Wed Aug 14 18:07:09 2002
+++ ZODB3/Persistence/PersistentList.py Tue Oct 28 16:28:28 2003
@@ -19,78 +19,14 @@
__version__='$Revision$'[11:-2]
import Persistence
-from UserList import UserList
+from persistent.list import PersistentList
-class PersistentList(UserList, Persistence.Persistent):
- __super_setitem = UserList.__setitem__
- __super_delitem = UserList.__delitem__
- __super_setslice = UserList.__setslice__
- __super_delslice = UserList.__delslice__
- __super_iadd = UserList.__iadd__
- __super_imul = UserList.__imul__
- __super_append = UserList.append
- __super_insert = UserList.insert
- __super_pop = UserList.pop
- __super_remove = UserList.remove
- __super_reverse = UserList.reverse
- __super_sort = UserList.sort
- __super_extend = UserList.extend
+class PersistentList(PersistentList, Persistence.Persistent):
+ """Legacy persistent list class
- def __setitem__(self, i, item):
- self.__super_setitem(i, item)
- self._p_changed = 1
+ This class mixes in ExtensionClass Base if it is present.
- def __delitem__(self, i):
- self.__super_delitem(i)
- self._p_changed = 1
+ Unless you actually want ExtensionClass semantics, use
+ persistent.list.PersistentList instead.
- def __setslice__(self, i, j, other):
- self.__super_setslice(i, j, other)
- self._p_changed = 1
-
- def __delslice__(self, i, j):
- self.__super_delslice(i, j)
- self._p_changed = 1
-
- def __iadd__(self, other):
- self.__super_iadd(other)
- self._p_changed = 1
-
- def __imul__(self, n):
- self.__super_imul(n)
- self._p_changed = 1
-
- def append(self, item):
- self.__super_append(item)
- self._p_changed = 1
-
- def insert(self, i, item):
- self.__super_insert(i, item)
- self._p_changed = 1
-
- def pop(self, i=-1):
- rtn = self.__super_pop(i)
- self._p_changed = 1
- return rtn
-
- def remove(self, item):
- self.__super_remove(item)
- self._p_changed = 1
-
- def reverse(self):
- self.__super_reverse()
- self._p_changed = 1
-
- def sort(self, *args):
- self.__super_sort(*args)
- self._p_changed = 1
-
- def extend(self, other):
- self.__super_extend(other)
- self._p_changed = 1
-
- # This works around a bug in Python 2.1.x (up to 2.1.2 at least) where the
- # __cmp__ bogusly raises a RuntimeError, and because this is an extension
- # class, none of the rich comparison stuff works anyway.
- def __cmp__(self, other):
- return cmp(self.data, self._UserList__cast(other))
+ """
=== ZODB3/Persistence/PersistentMapping.py 1.20 => 1.20.96.1 ===
--- ZODB3/Persistence/PersistentMapping.py:1.20 Wed Aug 14 18:07:09 2002
+++ ZODB3/Persistence/PersistentMapping.py Tue Oct 28 16:28:28 2003
@@ -19,88 +19,14 @@
__version__='$Revision$'[11:-2]
import Persistence
-from UserDict import UserDict
+from persistent.mapping import PersistentMapping
-class PersistentMapping(UserDict, Persistence.Persistent):
- """A persistent wrapper for mapping objects.
+class PersistentMapping(PersistentMapping, Persistence.Persistent):
+ """Legacy persistent mapping class
- This class allows wrapping of mapping objects so that object
- changes are registered. As a side effect, mapping objects may be
- subclassed.
+ This class mixes in ExtensionClass Base if it is present.
- A subclass of PersistentMapping or any code that adds new
- attributes should not create an attribute named _container. This
- is reserved for backwards compatibility reasons.
- """
-
- # UserDict provides all of the mapping behavior. The
- # PersistentMapping class is responsible marking the persistent
- # state as changed when a method actually changes the state. At
- # the mapping API evolves, we may need to add more methods here.
-
- __super_delitem = UserDict.__delitem__
- __super_setitem = UserDict.__setitem__
- __super_clear = UserDict.clear
- __super_update = UserDict.update
- __super_setdefault = UserDict.setdefault
-
- def __delitem__(self, key):
- self.__super_delitem(key)
- self._p_changed = 1
-
- def __setitem__(self, key, v):
- self.__super_setitem(key, v)
- self._p_changed = 1
-
- def clear(self):
- self.__super_clear()
- self._p_changed = 1
-
- def update(self, b):
- self.__super_update(b)
- self._p_changed = 1
+ Unless you actually want ExtensionClass semantics, use
+ persistent.mapping.PersistentMapping instead.
- def setdefault(self, key, failobj=None):
- # We could inline all of UserDict's implementation into the
- # method here, but I'd rather not depend at all on the
- # implementation in UserDict (simple as it is).
- if not self.has_key(key):
- self._p_changed = 1
- return self.__super_setdefault(key, failobj)
-
- try:
- __super_popitem = UserDict.popitem
- except AttributeError:
- pass
- else:
- def popitem(self):
- self._p_changed = 1
- return self.__super_popitem()
-
- # If the internal representation of PersistentMapping changes,
- # it causes compatibility problems for pickles generated by
- # different versions of the code. Compatibility works in both
- # directions, because an application may want to share a database
- # between applications using different versions of the code.
-
- # Effectively, the original rep is part of the "API." To provide
- # full compatibility, the getstate and setstate must read and
- # right objects using the old rep.
-
- # As a result, the PersistentMapping must save and restore the
- # actual internal dictionary using the name _container.
-
- def __getstate__(self):
- state = {}
- state.update(self.__dict__)
- state['_container'] = state['data']
- del state['data']
- return state
-
- def __setstate__(self, state):
- if state.has_key('_container'):
- self.data = state['_container']
- del state['_container']
- elif not state.has_key('data'):
- self.data = {}
- self.__dict__.update(state)
+ """
=== ZODB3/Persistence/__init__.py 1.4.88.2 => 1.4.88.3 ===
--- ZODB3/Persistence/__init__.py:1.4.88.2 Tue Jul 8 14:19:45 2003
+++ ZODB3/Persistence/__init__.py Tue Oct 28 16:28:28 2003
@@ -1,6 +1,6 @@
##############################################################################
#
-# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
+# Copyright (c) 2001, 2002, 2003 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
@@ -11,7 +11,43 @@
# FOR A PARTICULAR PURPOSE
#
##############################################################################
-"""Provide access to Persistent and PersistentMapping."""
+"""Persistence and ExtensionClass combined
-from cPersistence import Persistent
-from cPickleCache import PickleCache
+$Id$
+"""
+
+from persistent import Persistent, PickleCache
+
+try:
+ from ExtensionClass import Base
+except:
+ from warnings import warn
+ warn("""Couldn't import ExtensionClass
+
+ There are two possibilities:
+
+ 1. You don't care about ExtensionClass. You are importing
+ Persistence because that's what you imported in the past.
+ In this case, you should really use the persistent package
+ instead:
+
+ >>> from persistent import Persistent
+ >>> from persistent.list import PersistentList
+ >>> from persistent.mapping import PersistentMapping
+
+ 2. You want your classes you be ExtensionClasses. In thsi case,
+ you need to install the ExtensionClass package
+ separately. ExtensionClass is no-longer included with ZODB3.
+
+ """)
+ Base = object
+
+class Persistent(Persistent, Base):
+ """Legacy persistent class
+
+ This class mixes in ExtensionClass Base if it is present.
+
+ Unless you actually want ExtensionClass semantics, use
+ persistent.Persistent instead.
+
+ """
=== Removed File ZODB3/Persistence/TimeStamp.c ===
=== Removed File ZODB3/Persistence/cPersistence.c ===
=== Removed File ZODB3/Persistence/cPersistence.h ===
=== Removed File ZODB3/Persistence/cPickleCache.c ===
=== Removed File ZODB3/Persistence/ring.c ===
=== Removed File ZODB3/Persistence/ring.h ===
More information about the Zope-Checkins
mailing list