[Zope-dev] hotfix and security declaration

Florent Guillaume fg@nuxeo.com
Tue, 6 Aug 2002 12:54:01 +0000 (UTC)


Yuppie  <schubbe@web.de> wrote:
> Hi!
> 
> Writing a hotfix for my product, I have same questions about security 
> declarations. The ZDG doesn't cover this.
> 
> 1.) adding a new Method:
> Is the following code safe? Or is there a better way to do that?
> 
> <code>
> from Globals import InitializeClass
> from AccessControl import ClassSecurityInfo
> from Products.oldProduct import oldClass
> 
> def newMethod(self):
>     pass
> 
> oldClass.security = ClassSecurityInfo()
> oldClass.security.declareProtected( 'View', 'newMethod' )
> oldClass.newMethod = newMethod
> 
> InitializeClass(oldClass)
> </code>

This should work (maybe modulo tweaks).
You should also be able to do:

security = ClassSecurityInfo()
security.declareProtected('View', 'newMethod')
oldClass.newMethod = newMethod
security.apply(oldClass)

Check it though.


Florent
-- 
Florent Guillaume, Nuxeo (Paris, France)
+33 1 40 33 79 87  http://nuxeo.com  mailto:fg@nuxeo.com