[Zope-Checkins] CVS: Zope/lib/python/App - PersistentExtra.py:1.9 ProductContext.py:1.44 class_init.py:1.15

Jim Fulton cvs-admin at zope.org
Fri Nov 28 11:45:53 EST 2003


Update of /cvs-repository/Zope/lib/python/App
In directory cvs.zope.org:/tmp/cvs-serv4590/lib/python/App

Modified Files:
	PersistentExtra.py ProductContext.py class_init.py 
Log Message:
New-style class dictionaries are immutable. Changed some class-update
code to use setattr rather thah class-dictionary modifications.


=== Zope/lib/python/App/PersistentExtra.py 1.8 => 1.9 ===
--- Zope/lib/python/App/PersistentExtra.py:1.8	Wed Aug 14 17:31:40 2002
+++ Zope/lib/python/App/PersistentExtra.py	Fri Nov 28 11:45:21 2003
@@ -16,7 +16,7 @@
 import Globals
 from DateTime import DateTime
 
-Persistent.__dict__['__class_init__']=default__class_init__
+Persistent.__class_init__ = default__class_init__
 
 class PersistentUtil:
 
@@ -69,4 +69,7 @@
         except: return 0
         return 1
 
-for k, v in PersistentUtil.__dict__.items(): Persistent.__dict__[k]=v
+for k, v in PersistentUtil.__dict__.items():
+    if k[0] != '_':
+        setattr(Persistent, k, v)
+


=== Zope/lib/python/App/ProductContext.py 1.43 => 1.44 ===
--- Zope/lib/python/App/ProductContext.py:1.43	Fri May  2 18:01:34 2003
+++ Zope/lib/python/App/ProductContext.py	Fri Nov 28 11:45:22 2003
@@ -166,8 +166,10 @@
 
             fd = pack.__FactoryDispatcher__ = __FactoryDispatcher__
 
-        if not hasattr(pack, '_m'): pack._m=fd.__dict__
-        m=pack._m
+        if not hasattr(pack, '_m'):
+            pack._m = AttrDict(fd)
+
+        m = pack._m
 
         if interfaces is _marker:
             if instance_class is None:
@@ -341,3 +343,11 @@
                     continue
                 ht=APIHelpTopic.APIHelpTopic(file, '', os.path.join(path, file))
                 self.registerHelpTopic(file, ht)
+
+class AttrDict:
+
+    def __init__(self, ob):
+        self.ob = ob
+
+    def __setitem__(self, name, v):
+        setattr(self.ob, name, v)


=== Zope/lib/python/App/class_init.py 1.14 => 1.15 ===
--- Zope/lib/python/App/class_init.py:1.14	Wed Aug 14 17:31:41 2002
+++ Zope/lib/python/App/class_init.py	Fri Nov 28 11:45:22 2003
@@ -46,11 +46,13 @@
                 d['__name__']=name
             if name=='manage' or name[:7]=='manage_':
                 name=name+'__roles__'
-                if not have(name): dict[name]=('Manager',)
+                if not have(name):
+                    setattr(self, name, ('Manager',))
         elif name=='manage' or name[:7]=='manage_' and type(v) is ft:
             name=name+'__roles__'
-            if not have(name): dict[name]='Manager',
-
+            if not have(name):
+                setattr(self, name, ('Manager',))
+                
     # Look for a SecurityInfo object on the class. If found, call its
     # apply() method to generate __ac_permissions__ for the class. We
     # delete the SecurityInfo from the class dict after it has been
@@ -59,7 +61,7 @@
         if hasattr(value, '__security_info__'):
             security_info=value
             security_info.apply(self)
-            del dict[key]
+            delattr(self, key)
             break
 
     if self.__dict__.has_key('__ac_permissions__'):
@@ -72,4 +74,4 @@
             else:
                 pr=PermissionRole(pname)
             for mname in mnames:
-                dict[mname+'__roles__']=pr
+                setattr(self, mname+'__roles__', pr)




More information about the Zope-Checkins mailing list