[Zope3-checkins] CVS: Zope3/src/zodb/code - class_.py:1.6.2.2
Jeremy Hylton
jeremy@zope.com
Fri, 24 Jan 2003 13:20:46 -0500
Update of /cvs-repository/Zope3/src/zodb/code
In directory cvs.zope.org:/tmp/cvs-serv3007/zodb/code
Modified Files:
Tag: new-pickle-branch
class_.py
Log Message:
Convert raw objects to simple descriptors.
Need for attributes like __implements__.
=== Zope3/src/zodb/code/class_.py 1.6.2.1 => 1.6.2.2 ===
--- Zope3/src/zodb/code/class_.py:1.6.2.1 Tue Jan 21 17:35:45 2003
+++ Zope3/src/zodb/code/class_.py Fri Jan 24 13:20:43 2003
@@ -28,6 +28,20 @@
# separate sets of attributes. This code should be documented, as it
# it quite delicate, and it should be move to a separate module.
+class SimpleDescriptor(object):
+
+ def __init__(self, value):
+ self._value = value
+
+ def __get__(self, obj, cls):
+ return self._value
+
+ def __set__(self, obj, value):
+ self._value = value
+
+ def __delete__(self, obj):
+ del self._value
+
class ExtClassDescr:
"""Maintains seperate class and instance descriptors for an attribute.
@@ -90,6 +104,10 @@
class DataMixin:
def __init__(self, name, descr, val):
+ if not hasattr(descr, "__get__"):
+ # If the object defined in the metaclass is not a descriptor,
+ # create one for it.
+ descr = SimpleDescriptor(descr)
super(DataMixin, self).__init__(name, descr)
self.val = val
@@ -194,7 +212,6 @@
# GHOST instead of UPTODATE. See __getnewargs__().
def __new__(meta, name, bases, dict, state=UPTODATE):
- # XXX make sure bases are not ghosts?
cls = super(PersistentClassMetaClass, meta).__new__(
meta, name, bases, dict)
# helper functions