Re: changing permissions on classes/methods at runtime?

Thierry Florac <[email protected]>
Newsgroups gmane.comp.web.zope.general
Organization Office National des Forêts
Message-ID <[email protected]>
Hi,


Le Wed, 29 Feb 2012 15:12:37 +0100,
  Jürgen Herrmann <[email protected]> a écrit:

> is it possible to change permissions and roles on classes/methods
> at runtime? normally you'd attach security declarations inline in
> your class definition code:
> 
> from AccessControl import ClassSecurityInfo
> from AccessControl.class_init import InitializeClass
> class Cls():
>    security = ClassSecurityInfo()
>    security.declarePrivate('foo')
>    def foo(self):
>      pass
> InitializeClass(Cls)
> 
> 
> now what i tried at runtime is:
> 
> from mycode import Cls
> from AccessControl import ClassSecurityInfo
> security = ClassSecurityInfo()
> security.declarePublic('foo')
> security.apply(Cls)
> 
> but this does not what i want it to, in fact it doesn't seem
> to do anything yet - probably because i'm using the wrong way :)
> 
> any hints how to do this correctly would be greatly appreciated.
> 
> thank you very much in advance and best regards,

The way I handle this kind of problem is:
 - declare me method as protected, with a specific permission
 - grant this permission to roles or users (which can be "anybody")
   according to your context.

Best regards,
Thierry
-- 
  Chef de projets internet/intranet
  Office National des Forêts
  Direction des Systèmes d'Information
  2, Avenue de Saint Mandé
  75570 PARIS Cedex 12

  Tél. : 01 40 19 59 64
  Fax. : 01 40 19 59 85
  Mél. : [email protected]
  WWW  : http://www.onf.fr
_______________________________________________
Zope maillist  -  [email protected]
https://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists -
 https://mail.zope.org/mailman/listinfo/zope-announce
 https://mail.zope.org/mailman/listinfo/zope-dev )
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.