[Zope] Ticking Security boxes via Python

Peter Bengtsson peter_bengtsson_temporary@yahoo.co.uk
Mon, 8 Oct 2001 16:49:09 +0100 (BST)


> from a python script
> obj = getattr(context, 'objIamLookingFor')
> 
> # manage_permission(listOfPermissions,
> ListOfWhomToGrant,
> FlagIfItShouldBeInherited)
> obj.manage_permission(['View'],
'Anonymous','Member'],1)


Thank you. That worked.
However, I had to do this:

obj.manage_permission('View',
['Anonymous','Member'],1)

Cheers, Peter




 
> both of the lists can also be a string (I believe)
> 
> Robert
> 
> ----- Original Message -----
> From: "Peter Bengtsson" <mail@peterbe.com>
> To: <zope@zope.org>
> Sent: Monday, October 08, 2001 3:17 AM
> Subject: [Zope] Ticking Security boxes via Python
> 
> 
> When an object (sub class to my new product I'm
> working on) is created I in
> it, create a user folder and user in there with the
> role "TimeTable User".
> 
> Suppose that I create this container, click
> "Security" and makes the
> following settings:
>   1) View is NOT acquired
>   2) To get View you have to be either "Manager",
> "TimeTable User" or
> "TimeTable Manager"
> little ticked boxes across the View permission.
> 
> How can I do this with python??
> 
> 
> 
> 
> I have tried this:
> 
> def __init__(self):
>     bla
>     bla
>     # do stuff via python instead of the ZMI
>     self.manage_permission('View',
>                                         
> roles=['Manager','TimeTable
> User','TimeTable Manager'],
>                                          acquire=0)
> 
> This throws an error:
> Error Type: AttributeError
> Error Value: aq_acquire
> 
> Traceback (innermost last):
>   File lib\python\ZPublisher\Publish.py, line 223,
> in publish_module
>   File lib\python\ZPublisher\Publish.py, line 187,
> in publish
>   File
> C:\Program\zope240\lib\python\Zope\__init__.py, line
> 226, in
> zpublisher_exception_hook
>     (Object: LockableItem)
>   File lib\python\ZPublisher\Publish.py, line 171,
> in publish
>   File
> C:\Program\zope240\lib\python\ZPublisher\mapply.py,
> line 160, in
> mapply
>     (Object: addTimeTableAccount)
>   File lib\python\ZPublisher\Publish.py, line 112,
> in call_object
>     (Object: addTimeTableAccount)
>   File
>
C:\Program\zope240\lib\python\Products\TimeTable\TimeTable.py,
> line
> 84, in addTimeTableAccount
>     (Object: LockableItem)
>   File
>
C:\Program\zope240\lib\python\Products\TimeTable\TimeTable.py,
> line
> 145, in __init__
>     (Object: LockableItem)
>   File
> C:\Program\zope240\lib\python\AccessControl\Role.py,
> line 234, in
> manage_permission
>     (Object: LockableItem)
>   File
> C:\Program\zope240\lib\python\AccessControl\Role.py,
> line 152, in
> ac_inherited_permissions
>     (Object: LockableItem)
>   File
> C:\Program\zope240\lib\python\OFS\ObjectManager.py,
> line 256, in
> _subobject_permissions
>     (Object: LockableItem)
> AttributeError: (see above)
> 
> 
> Basically, how do I go into the ZMI, -> Security and
> tick boxes with python
> code?
> 
> 
> peter
> 
> 
> _______________________________________________
> 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 )
> 
> 
> 
>  

=====
peter_bengtsson_temporary@yahoo.co.uk is a temporary address that
I use to send until I get my email stuff together.
You can always continue to send to my real address which is 
mail@peterbe.com

____________________________________________________________
Do You Yahoo!?
Get your free @yahoo.co.uk address at http://mail.yahoo.co.uk
or your free @yahoo.ie address at http://mail.yahoo.ie