Commit 6150e9df authored by Shane Hathaway's avatar Shane Hathaway

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.
parent ff0e3677
......@@ -84,7 +84,7 @@
##############################################################################
"""Access control package"""
__version__='$Revision: 1.150 $'[11:-2]
__version__='$Revision: 1.151 $'[11:-2]
import Globals, socket, SpecialUsers,re
import os
......@@ -746,6 +746,7 @@ class BasicUserFolder(Implicit, Persistent, Navigation, Tabs, RoleManager,
_editUser=DTMLFile('dtml/editUser', globals(),
remote_user_mode__=_remote_user_mode)
manage=manage_main=_mainUser
manage_main._setName('manage_main')
def domainSpecValidate(self, spec):
for ob in spec:
......
......@@ -83,7 +83,7 @@
#
##############################################################################
__doc__="""System management components"""
__version__='$Revision: 1.73 $'[11:-2]
__version__='$Revision: 1.74 $'[11:-2]
import sys,os,time,string,Globals, Acquisition, os, Undo
......@@ -111,6 +111,7 @@ class Fake:
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 @@ Globals.default__class_init__(DatabaseManager)
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 @@ _v_rst=None
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 @@ class ApplicationManager(Folder,CacheManager):
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'):
......
......@@ -83,7 +83,7 @@
#
##############################################################################
__version__ = "$Revision: 1.4 $"[11:-2]
__version__ = "$Revision: 1.5 $"[11:-2]
import OFS, Acquisition, Globals
from AccessControl import getSecurityManager, ClassSecurityInfo
......@@ -103,6 +103,7 @@ class DavLockManager(OFS.SimpleItem.Item, Acquisition.Implicit):
manage_davlocks=manage_main=manage=Globals.DTMLFile(
'dtml/davLockManager', globals())
manage_davlocks._setName('manage_davlocks')
manage_options = (
{'label': 'Write Locks', 'action': 'manage_main',
......
......@@ -98,8 +98,24 @@ def default__class_init__(self):
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',)
......
......@@ -121,6 +121,10 @@ class ClassicHTMLFile(DocumentTemplate.HTMLFile,MethodObject.Method,):
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__'),
......
......@@ -84,7 +84,7 @@
##############################################################################
"""DTML Method objects."""
__version__='$Revision: 1.65 $'[11:-2]
__version__='$Revision: 1.66 $'[11:-2]
import History
from Globals import HTML, DTMLFile, MessageDialog
......@@ -265,6 +265,7 @@ class DTMLMethod(HTML, Acquisition.Implicit, RoleManager,
return full_read_guard(ob)
manage_editForm=DTMLFile('dtml/documentEdit', globals())
manage_editForm._setName('manage_editForm')
# deprecated!
manage_uploadForm=manage_editForm
......
......@@ -84,7 +84,7 @@
##############################################################################
"""Image object"""
__version__='$Revision: 1.129 $'[11:-2]
__version__='$Revision: 1.130 $'[11:-2]
import Globals, string, struct
from OFS.content_types import guess_content_type
......@@ -146,7 +146,7 @@ class File(Persistent, Implicit, PropertyManager,
manage_editForm =DTMLFile('dtml/fileEdit',globals(),
Kind='File',kind='file')
manage_editForm._setName('manage_editForm')
manage=manage_main=manage_editForm
manage_uploadForm=manage_editForm
......@@ -736,7 +736,7 @@ class Image(File):
manage_editForm =DTMLFile('dtml/imageEdit',globals(),
Kind='Image',kind='image')
view_image_or_file =DTMLFile('dtml/imageView',globals())
manage_editForm._setName('manage_editForm')
manage=manage_main=manage_editForm
manage_uploadForm=manage_editForm
......
......@@ -84,8 +84,8 @@
##############################################################################
"""SMTP mail objects
$Id: MailHost.py,v 1.60 2001/01/11 15:03:52 chrism Exp $"""
__version__ = "$Revision: 1.60 $"[11:-2]
$Id: MailHost.py,v 1.61 2001/06/07 22:18:44 shane Exp $"""
__version__ = "$Revision: 1.61 $"[11:-2]
from Globals import Persistent, DTMLFile, HTML, MessageDialog
from smtplib import SMTP
......@@ -128,6 +128,7 @@ class MailBase(Acquisition.Implicit, OFS.SimpleItem.Item, RoleManager):
'a mailhost...?'
meta_type='Mail Host'
manage=manage_main=DTMLFile('dtml/manageMailHost', globals())
manage_main._setName('manage_main')
index_html=None
icon='misc_/MailHost/MHIcon'
......
......@@ -89,7 +89,7 @@ This product provides support for Script objects containing restricted
Python code.
"""
__version__='$Revision: 1.28 $'[11:-2]
__version__='$Revision: 1.29 $'[11:-2]
import sys, os, traceback, re, marshal
from Globals import DTMLFile, MessageDialog, package_home
......@@ -183,6 +183,7 @@ class PythonScript(Script, Historical, Cacheable):
ZPythonScriptHTML_editForm = DTMLFile('www/pyScriptEdit', globals())
manage = manage_main = ZPythonScriptHTML_editForm
ZPythonScriptHTML_editForm._setName('ZPythonScriptHTML_editForm')
security.declareProtected('Change Python Scripts',
'ZPythonScriptHTML_editAction',
......
......@@ -77,6 +77,7 @@ class SiteRoot(Traverser, Implicit):
manage_options=({'label':'Edit', 'action':'manage_main', 'help': ('SiteAccess', 'SiteRoot_Edit.stx')},)
manage = manage_main = DTMLFile('www/SiteRootEdit', globals())
manage_main._setName('manage_main')
def __init__(self, title, base, path):
'''Title'''
......
......@@ -203,6 +203,7 @@ class OldCatalogWrapperObject(SimpleItem, Implicit):
)
manage_main = DTMLFile('dtml/manageOldindex',globals())
manage_main._setName('manage_main')
manage_workspace = manage_main
def __init__(self, o):
......
......@@ -85,8 +85,8 @@
__doc__='''SQL Methods
$Id: SQL.py,v 1.18 2001/03/07 15:13:57 brian Exp $'''
__version__='$Revision: 1.18 $'[11:-2]
$Id: SQL.py,v 1.19 2001/06/07 22:18:45 shane Exp $'''
__version__='$Revision: 1.19 $'[11:-2]
import Shared.DC.ZRDB.DA
from Globals import DTMLFile
......@@ -193,6 +193,7 @@ class SQL(Shared.DC.ZRDB.DA.DA):
meta_type='Z SQL Method'
manage=manage_main=DTMLFile('dtml/edit', globals())
manage_main._setName('manage_main')
__ac_permissions__=(
('Change Database Methods', ('manage', 'manage_main')),
......
......@@ -388,6 +388,7 @@ class ZInstanceSheetsSheet(OFS.Traversable.Traversable,
manage=Globals.DTMLFile('OFS/dtml/main',
management_view='Property Sheets')
manage_main = manage
manage_main._setName('manage_main')
manage_addCommonSheetForm=Globals.DTMLFile('dtml/addCommonSheet',
globals())
......
......@@ -85,7 +85,7 @@
"""WebDAV support - null resource objects."""
__version__='$Revision: 1.28 $'[11:-2]
__version__='$Revision: 1.29 $'[11:-2]
import sys, os, string, mimetypes, Globals, davcmds
import Acquisition, OFS.content_types
......@@ -299,6 +299,7 @@ class LockNullResource(NullResource, OFS.SimpleItem.Item_w__name__):
manage = manage_main = DTMLFile('dtml/locknullmain', globals())
manage_workspace = manage
manage_main._setName('manage_main') # explicit
def __no_valid_write_locks__(self):
# A special hook (for better or worse) called when there are no
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment