[Zodb-checkins] CVS: Zope3/src/zodb/code - class_.py:1.7

Jeremy Hylton jeremy@zope.com
Tue, 21 Jan 2003 15:15:52 -0500


Update of /cvs-repository/Zope3/src/zodb/code
In directory cvs.zope.org:/tmp/cvs-serv26299

Modified Files:
	class_.py 
Log Message:
Add an __call__() to the PersistentClassMetaClass to guarantee
that instance's __init__() methods are called.

# type's __call__() uses tp_init directly, so it bypasses our
# __getattribute__() hook.  So we must guarantee that a class
# is loaded before it is called.


=== Zope3/src/zodb/code/class_.py 1.6 => 1.7 ===
--- Zope3/src/zodb/code/class_.py:1.6	Tue Dec 31 13:27:49 2002
+++ Zope3/src/zodb/code/class_.py	Tue Jan 21 15:15:48 2003
@@ -252,6 +252,13 @@
         cls._pc_init = True
         return cls
 
+    def __call__(cls, *args, **kwargs):
+        # type's __call__() uses tp_init directly, so it bypasses our
+        # __getattribute__() hook.  So we must guarantee that a class
+        # is loaded before it is called.
+        cls._p_activate()
+        return super(PersistentClassMetaClass, cls).__call__(*args, **kwargs)
+
     def __getattribute__(cls, name):
         # XXX I'm not sure I understand this code any more.
         super_meth = super(PersistentClassMetaClass, cls).__getattribute__