Skip to content

Commit

Permalink
Use new-style security declarations everywhere possible. This means
Browse files Browse the repository at this point in the history
remove the use of __ac_permissions__, foo__roles__ and
default__class_init__. A few corner cases can't be converted because of
circular imports.
  • Loading branch information
Florent Guillaume committed Nov 21, 2005
1 parent 380ec10 commit 21e23fe
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions ExternalMethod.py
Expand Up @@ -19,6 +19,11 @@
__version__='$Revision: 1.52 $'[11:-2]
from Globals import Persistent, DTMLFile, MessageDialog, HTML
import OFS.SimpleItem, Acquisition
from Globals import InitializeClass
from AccessControl import ClassSecurityInfo
from AccessControl.Permissions import change_external_methods
from AccessControl.Permissions import view_management_screens
from AccessControl.Permissions import view as View
import AccessControl.Role, sys, os, stat, traceback
from OFS.SimpleItem import pretty_tb
from App.Extensions import getObject, getPath, FuncCode
Expand Down Expand Up @@ -81,6 +86,9 @@ class ExternalMethod(OFS.SimpleItem.Item, Persistent, Acquisition.Explicit,

meta_type = 'External Method'

security = ClassSecurityInfo()
security.declareObjectProtected(View)

func_defaults = ComputedAttribute(lambda self: self.getFuncDefaults())
func_code = ComputedAttribute(lambda self: self.getFuncCode())

Expand All @@ -100,17 +108,14 @@ class ExternalMethod(OFS.SimpleItem.Item, Persistent, Acquisition.Explicit,
+AccessControl.Role.RoleManager.manage_options
)

__ac_permissions__=(
('View management screens', ('manage_main',)),
('Change External Methods', ('manage_edit',)),
('View', ('__call__','')),
)

def __init__(self, id, title, module, function):
self.id=id
self.manage_edit(title, module, function)

security.declareProtected(view_management_screens, 'manage_main')
manage_main=DTMLFile('dtml/methodEdit', globals())

security.declareProtected(change_external_methods, 'manage_edit')
def manage_edit(self, title, module, function, REQUEST=None):
"""Change the external method
Expand Down Expand Up @@ -182,6 +187,7 @@ def getFuncCode(self):
self._v_f = self.getFunction()
return self._v_func_code

security.declareProtected(View, '__call__')
def __call__(self, *args, **kw):
"""Call an ExternalMethod
Expand Down Expand Up @@ -243,3 +249,5 @@ def filepath(self):
self._v_filepath=getPath('Extensions', self._module,
suffixes=('','py','pyc','pyp'))
return self._v_filepath

InitializeClass(ExternalMethod)

0 comments on commit 21e23fe

Please sign in to comment.