I've written some code that programmatically adds a method to the ObjectManager class, but I want to secure my method so that not everyone can access it. How can I secure the method after the class has been registered? Thanks, Jeff
I believe you can do something like this: ObjectManager.foomethod = foomethod ObjectManager.foomethod__roles__ = ('Manager',) This is what the class initialization machinery does under the hood. - C On Sun, 2002-05-26 at 18:14, Jeff Ross wrote:
I've written some code that programmatically adds a method to the ObjectManager class, but I want to secure my method so that not everyone can access it. How can I secure the method after the class has been registered?
Thanks,
Jeff
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
I've written some code that programmatically adds a method to the ObjectManager class, but I want to secure my method so that not everyone can access it. How can I secure the method after the class has been registered?
Thanks,
Jeff
Hi Jeff - here's something (untested) that _should_ work: from AccessControl.SecurityInfo import ClassSecurityInfo from OFS.ObjectManager import ObjectManager # Hack ObjectManager and add security. Note that whether # this is _possible_ and whether its really a _good idea_ # are two separate things :) This may not necessarily # do what you expect in terms of protecting subclasses, # for example. def myMethod(self): return 'something' # add method to class ObjectManager.myMethod = myMethod # add security assertions. security = ClassSecurityInfo() security.declareProtected('Some permission', 'myMethod') security.apply(ObjectManager) Brian Lloyd brian@zope.com V.P. Engineering 540.361.1716 Zope Corporation http://www.zope.com
participants (3)
-
Brian Lloyd -
Chris McDonough -
Jeff Ross