[Zodb-checkins] CVS: Zope3/src/zodb/code - class_.py:1.9
Jeremy Hylton
jeremy@zope.com
Tue, 28 Jan 2003 17:04:16 -0500
Update of /cvs-repository/Zope3/src/zodb/code
In directory cvs.zope.org:/tmp/cvs-serv19372
Modified Files:
class_.py
Log Message:
Fix extend_attr() so that it doesn't provide default values for
attributes that don't exist on the instances.
=== Zope3/src/zodb/code/class_.py 1.8 => 1.9 ===
--- Zope3/src/zodb/code/class_.py:1.8 Fri Jan 24 18:20:56 2003
+++ Zope3/src/zodb/code/class_.py Tue Jan 28 17:03:43 2003
@@ -30,16 +30,22 @@
class SimpleDescriptor(object):
+ missing = object()
+
def __init__(self, value):
self._value = value
def __get__(self, obj, cls):
+ if self._value is self.missing:
+ raise AttributeError
return self._value
def __set__(self, obj, value):
self._value = value
def __delete__(self, obj):
+ if self._value is self.missing:
+ raise AttributeError
del self._value
class ExtClassDescr:
@@ -237,11 +243,11 @@
# helper functions
def extend_attr(attr, v):
- prev = findattr(cls, attr, None)
+ prev = findattr(cls, attr, SimpleDescriptor.missing)
setattr(cls, attr, ExtClassDataDescr(attr, prev, v))
def extend_meth(attr, m):
- prev = findattr(cls, attr, None)
+ prev = findattr(cls, attr, SimpleDescriptor.missing)
setattr(cls, attr, ExtClassMethodDescr(attr, prev, m))
extend_attr("_p_oid", None)