Re: Problem - setzen von Permissions fuer eine Role im Code

Thomas Graf <[email protected]>
Newsgroups gmane.comp.web.zope.german
Message-ID <[email protected]>
Hallo Vlad,
danke, genau sowas habe ich gesucht.

sonnige Gruesse
Thomas


Vladislav Vorobiev schrieb:
> Hallo Thomas,
> 
> manage_permission nur wenn das Objekt bereits existiert.
> 
> Definiere einfach in deiner Klasse die Methode:
> 
> def manage_afterAdd(self, item, container):
>      """Diese methode wird nach _setObject aufgerufen von  """
>      self.manage_permission('ise.exchangeadm: Add Workspace',
> roles=['Workspace Manager'], acquire=0)
> 
> 
> Gruß
> Vlad
> 
> Am 12. August 2009 20:45 schrieb Thomas Graf <[email protected]>:
>> Hallo Liste,
>> ich hoffe ihr koennt mir mit einem eigentlich recht simplen Problem
>> helfen.Wie setze ich eine Permission fuer eine Role in einem zope2-Produkt
>> im Code:
>>
>> Ich habe zwei Klassen, einen "AppContainer" und einen "Workspace".
>>
>>>    context.registerClass(
>>        appcontainer.AppContainer,
>>        constructors = (
>>            appcontainer.manage_addAppContainer,
>>        ),
>>        permission = "Manage Site"
>>    )
>>
>>    context.registerClass(
>>        workspace.Workspace,
>>        constructors = (
>>            workspace.manage_addWorkspace,
>>        ),
>>        permission= "ise.exchangeadm: Add Workspace"
>>    )
>>
>> Beim anlegen eines AppContainers soll automatisch die Permission
>> "ise.exchangeadm: Add Workspace" fuer eine Rolle ("Workspace Manager")
>> gesetzt werden.
>>
>> Dies habe ich, mit Inspiration von
>> http://plone.org/documentation/tutorial/manipulating-plone-objects-programmatically/security-and-permission
>> versucht das Problem folgendermassen zu loesen:
>>
>>> class AppContainer( OrderedFolder.OrderedFolder ):
>>    """Application container for the ISE Exchange Admin Module"""
>>    interface.implements(IAppContainer)
>>    meta_type="Application_Container"
>>
>>    def __init__(self, id):
>>        self.id = id
>>        self._addRole('Workspace Manager')
>>        print self.ac_inherited_permissions(all=True)
>>        self.manage_permission(
>>            "ise.exchangeadm: Add Workspace",
>>            roles=['Workspace Manager'],
>>            acquire=[False])
>>
>> Beim Anlegen eines Containers wird zunaechst die Rolle hinzugefuegt und
>> danach fuer die Rolle die Permission gesetzt. Beim Ausfuehren von
>> manage_permission wird jedoch folgende Exception geworfen:
>>
>> Traceback (innermost last):
>>  Module ZPublisher.Publish, line 119, in publish
>>  Module ZPublisher.mapply, line 88, in mapply
>>  Module ZPublisher.Publish, line 42, in call_object
>>  Module ise.exchangeadm.appcontainer, line 38, in manage_addAppContainer
>>  Module ise.exchangeadm.appcontainer, line 19, in __init__
>>  Module AccessControl.Role, line 80, in ac_inherited_permissions
>>  Module OFS.ObjectManager, line 259, in _subobject_permissions
>> AttributeError: aq_acquire
>>
>> Ich nutze Zope 2.11.4,
>>
>> Wie kann ich eine Permission fuer ein Role beim Anlegen eines Objektes
>> setzen?
>>
>> Mit sonnigen Gruessen
>> Thomas Graf
>>
>> --
>> Thomas Graf, B.Sc.
>> Commercial and technical Services
>> Fraunhofer-Institut für Solare Energiesysteme ISE
>> Heidenhofstrasse 2, 79110 Freiburg, Germany
>> Phone: +49(0)761/4588-5123  Fax: +49(0)761/4588-9123
>> [email protected]
>> http://www.ise.fraunhofer.de
>>
>>
>>
>>
>> _______________________________________________
>> zope mailing list
>> [email protected]
>> https://mail.dzug.org/mailman/listinfo/zope
>>
>>
>>
>> ------------------------------------------------------------------------
>>
>>
>>
>> _______________________________________________
>> zope mailing list
>> [email protected]
>> https://mail.dzug.org/mailman/listinfo/zope


-- 
Thomas Graf, B.Sc.
Commercial and technical Services
Fraunhofer-Institut für Solare Energiesysteme ISE
Heidenhofstrasse 2, 79110 Freiburg, Germany
Phone: +49(0)761/4588-5123  Fax: +49(0)761/4588-9123
[email protected]
http://www.ise.fraunhofer.de



_______________________________________________
zope mailing list
[email protected]
https://mail.dzug.org/mailman/listinfo/zope
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.