[Zope] Ticking Security boxes via Python (still not solved)

kapil thangavelu k_vertigo@yahoo.com
Mon, 8 Oct 2001 10:56:52 -0700


read the relevant chapter about security from the developer's guide it shows 
how to create default roles for certain methods.

the reason the below isn't working (half-guess, half-experience) is that when 
your object is created it doesn't have access to the acquisition heirarchy

ie 
in manage_add
ob = yourclass(id, title)
 
ob has no context

after you do
self._setObject(id, obj)

you can retrieve the wrapped object via

wrapped_obj = self._getObject(id)
and than call the methods

or you can try this in manage_afterAdd which gets called by the object 
manager after the object is added.

hth

kapil

On Monday 08 October 2001 01:52 pm, Peter Bengtsson wrote:
>  --- Robert Rottermann <robert@redcor.ch> wrote:
> > from a python script
> > obj = getattr(context, 'objIamLookingFor')
> > obj.manage_permission('View',
>
> ['Anonymous','Member'],1)
>
> I was wrong. It does still not work the way I want it
> to.
> This code works fine from a Python Script, but when I
> try it in the __init__ method if barks again about
> 'aq_aquire'.
>
> I tried:
> def __init__(self, id, title):
>     " "
>     self.id = id
>     self.title = title
>     self.manage_permission('View',['Manager'],0)
>
> 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 89, in addTimeTableAccount
>     (Object: LockableItem)
>   File
> C:\Program\zope240\lib\python\Products\TimeTable\TimeTable.py,
> line 279, 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)
>
>
> I don't want to have to start a script that prepares
> the new object each time. I want to do it in the
> __init__ method. Can this not be done?
>
>
> Peter
>
>
> =====
> 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
>
> _______________________________________________
> 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 )