[Zope-Checkins] CVS: Zope2 - ApplicationManager.py:1.74 DavLockManager.py:1.5 class_init.py:1.11 special_dtml.py:1.17

shane@digicool.com shane@digicool.com
Thu, 7 Jun 2001 18:19:15 -0400 (EDT)


Update of /cvs-repository/Zope2/lib/python/App
In directory korak.digicool.com:/tmp/cvs-serv16812/App

Modified Files:
	ApplicationManager.py DavLockManager.py class_init.py 
	special_dtml.py 
Log Message:
The _need__name__ protocol assigns a name to DTMLMethods implicitly
so that ExtensionClass can find the correct <name>__roles__ attribute
of the method's class.  However it was discovered that this protocol
has a flaw: if a DTMLMethod is bound to multiple names, there is no
way for default__class_init__ to tell which name is the right one.

This change adds code that detects the condition and makes the name
explicit in all places where it occurs in the Zope core.  There are
likely products out there that have the same condition so they will
need a small correction.  For now this is a warning but it might be
appropriate to later make the condition an error.



--- Updated File ApplicationManager.py in package Zope2 --
--- ApplicationManager.py	2001/05/23 19:02:18	1.73
+++ ApplicationManager.py	2001/06/07 22:18:43	1.74
@@ -111,6 +111,7 @@
 class DatabaseManager(Fake, SimpleItem.Item, Acquisition.Implicit):
     """Database management"""
     manage=manage_main=DTMLFile('dtml/dbMain', globals())
+    manage_main._setName('manage_main')
     id        ='DatabaseManagement'
     name=title='Database Management'
     meta_type ='Database Management'
@@ -138,6 +139,7 @@
 class VersionManager(Fake, SimpleItem.Item, Acquisition.Implicit):
     """Version management"""
     manage=manage_main=DTMLFile('dtml/versionManager', globals())
+    manage_main._setName('manage_main')
     id        ='Versions'
     name=title='Version Management'
     meta_type ='Version Management'
@@ -162,6 +164,7 @@
 class DebugManager(Fake, SimpleItem.Item, Acquisition.Implicit):
     """Debug and profiling information"""
     manage=manage_main=DTMLFile('dtml/debug', globals())
+    manage_main._setName('manage_main')
     id        ='DebugInfo'
     name=title='Debug Information'
     meta_type = name
@@ -270,6 +273,7 @@
     DavLocks = DavLockManager()
 
     manage=manage_main=DTMLFile('dtml/cpContents', globals())
+    manage_main._setName('manage_main')
 
     def version_txt(self):
         if not hasattr(self, '_v_version_txt'):

--- Updated File DavLockManager.py in package Zope2 --
--- DavLockManager.py	2001/02/02 16:17:16	1.4
+++ DavLockManager.py	2001/06/07 22:18:43	1.5
@@ -103,6 +103,7 @@
 
     manage_davlocks=manage_main=manage=Globals.DTMLFile(
         'dtml/davLockManager', globals())
+    manage_davlocks._setName('manage_davlocks')
 
     manage_options = (
         {'label': 'Write Locks', 'action': 'manage_main',

--- Updated File class_init.py in package Zope2 --
--- class_init.py	2001/01/16 20:01:09	1.10
+++ class_init.py	2001/06/07 22:18:43	1.11
@@ -98,8 +98,24 @@
     dict_items=dict.items()
 
     for name, v in dict_items:
-        if hasattr(v,'_need__name__') and v._need__name__:
-            v.__dict__['__name__']=name
+        if getattr(v, '_need__name__', 0):
+            d = v.__dict__
+            oldname = d.get('__name__', '')
+            if d.get('_implicit__name__', 0):
+                # Already supplied a name.
+                if name != oldname:
+                    # Tried to implicitly assign a different name!
+                    try: classname = '%s.%s' % (
+                        self.__module__, self.__name__)
+                    except AttributeError: classname = `self`
+                    from zLOG import LOG, WARNING
+                    LOG('Init', WARNING, 'Ambiguous name for method of %s: '
+                        '"%s" != "%s"' % (classname, d['__name__'], name))
+            else:
+                # Supply a name implicitly so that the method can
+                # find the security assertions on its container.
+                d['_implicit__name__'] = 1
+                d['__name__']=name
             if name=='manage' or name[:7]=='manage_':
                 name=name+'__roles__'
                 if not have(name): dict[name]=('Manager',)

--- Updated File special_dtml.py in package Zope2 --
--- special_dtml.py	2001/04/27 20:27:38	1.16
+++ special_dtml.py	2001/06/07 22:18:43	1.17
@@ -121,6 +121,10 @@
             self.cook()
             if not changed: self.__changed__(0)
 
+    def _setName(self, name):
+        self.__name__ = name
+        self._need__name__ = 0
+
     def __call__(self, *args, **kw):
         self._cook_check()
         return apply(HTMLFile.inheritedAttribute('__call__'),