Dexterity: Setting Permissions for Fields

classic Classic list List threaded Threaded
4 messages Options
andreasma andreasma
Reply | Threaded
Open this post in threaded view
|

Dexterity: Setting Permissions for Fields

Hi all,

I'm trying to set permissions to fields in a Dexterity form. I have a
field whose content is imported from a field of the folder object. The
manager of the site should edit the source fields on the parent object
(folder) and the creator of the objects in the folder should have not
the right to change the text of the connected field on this file object.
He should only read the text of this field and apply to its conditions.
The folder object is tucenter.py.

and the non-folder-object (inside tucenter/tuproject) is
tudownloadablefile.py.

I've imported
from zope.security import checkPermission

The permissions for my fields are currently set to:

   
dexterity.read_permission(title_declaration_legal='cmf.AddPortalContent')
    dexterity.write_permission(title_declaration_legal='cmf.ManagePortal')
    title_declaration_legal=schema.TextLine(
        title=_(u""),
        required=False
    )
    dexterity.write_permission(declaration_legal='cmf.ManagePortal')
    form.primary('declaration_legal')
    declaration_legal = RichText(
        title=_(u""),
        required=False
    )

This ends up with the hiding of the fields in the edit-view of the
Dexterity object. If I set the read or write permission to
'cmf.AddPortalContent' the user has the possibility to change the text
of the field. If I set the permission to cmf.ManagePortal the content is
not visible inside the edit view.


Regards,
Andreas

--
## Developer LibreOffice
## Freie Office-Suite für Linux, Mac, Windows
## http://LibreOffice.org
## Support the Document Foundation (http://documentfoundation.org)
## Meine Seite: http://www.amantke.de 


------------------------------------------------------------------------------
LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial
Remotely access PCs and mobile devices and provide instant support
Improve your efficiency, and focus on delivering more value-add services
Discover what IT Professionals Know. Rescue delivers
http://p.sf.net/sfu/logmein_12329d2d
_______________________________________________
Plone-Users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/plone-users
andreasma andreasma
Reply | Threaded
Open this post in threaded view
|

Re: Dexterity: Setting Permissions for Fields

Hi all,

I've read again through the Dexterity developer manual and the behavior
seemed to be the expected one, but I hope there is a way to achieve my goal.

Regards,
Andreas

Am 23.12.2012 22:37, schrieb Andreas Mantke:

> Hi all,
>
> I'm trying to set permissions to fields in a Dexterity form. I have a
> field whose content is imported from a field of the folder object. The
> manager of the site should edit the source fields on the parent object
> (folder) and the creator of the objects in the folder should have not
> the right to change the text of the connected field on this file object.
> He should only read the text of this field and apply to its conditions.
> The folder object is tucenter.py.
>
> and the non-folder-object (inside tucenter/tuproject) is
> tudownloadablefile.py.
>
> I've imported
> from zope.security import checkPermission
>
> The permissions for my fields are currently set to:
>
>    
> dexterity.read_permission(title_declaration_legal='cmf.AddPortalContent')
>     dexterity.write_permission(title_declaration_legal='cmf.ManagePortal')
>     title_declaration_legal=schema.TextLine(
>         title=_(u""),
>         required=False
>     )
>     dexterity.write_permission(declaration_legal='cmf.ManagePortal')
>     form.primary('declaration_legal')
>     declaration_legal = RichText(
>         title=_(u""),
>         required=False
>     )
>
> This ends up with the hiding of the fields in the edit-view of the
> Dexterity object. If I set the read or write permission to
> 'cmf.AddPortalContent' the user has the possibility to change the text
> of the field. If I set the permission to cmf.ManagePortal the content is
> not visible inside the edit view.
>
>
> Regards,
> Andreas
>


--
## Developer LibreOffice
## Freie Office-Suite für Linux, Mac, Windows
## http://LibreOffice.org
## Support the Document Foundation (http://documentfoundation.org)
## Meine Seite: http://www.amantke.de 


------------------------------------------------------------------------------
LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial
Remotely access PCs and mobile devices and provide instant support
Improve your efficiency, and focus on delivering more value-add services
Discover what IT Professionals Know. Rescue delivers
http://p.sf.net/sfu/logmein_12329d2d
_______________________________________________
Plone-Users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/plone-users
David Glick (Plone) David Glick (Plone)
Reply | Threaded
Open this post in threaded view
|

Re: Dexterity: Setting Permissions for Fields

In reply to this post by andreasma
On 12/23/12 4:37 PM, Andreas Mantke wrote:

> Hi all,
>
> I'm trying to set permissions to fields in a Dexterity form. I have a
> field whose content is imported from a field of the folder object. The
> manager of the site should edit the source fields on the parent object
> (folder) and the creator of the objects in the folder should have not
> the right to change the text of the connected field on this file object.
> He should only read the text of this field and apply to its conditions.
> The folder object is tucenter.py.
>
> and the non-folder-object (inside tucenter/tuproject) is
> tudownloadablefile.py.
>
> I've imported
> from zope.security import checkPermission
>
> The permissions for my fields are currently set to:
>
>    
> dexterity.read_permission(title_declaration_legal='cmf.AddPortalContent')
>      dexterity.write_permission(title_declaration_legal='cmf.ManagePortal')
>      title_declaration_legal=schema.TextLine(
>          title=_(u""),
>          required=False
>      )
>      dexterity.write_permission(declaration_legal='cmf.ManagePortal')
>      form.primary('declaration_legal')
>      declaration_legal = RichText(
>          title=_(u""),
>          required=False
>      )
>
> This ends up with the hiding of the fields in the edit-view of the
> Dexterity object. If I set the read or write permission to
> 'cmf.AddPortalContent' the user has the possibility to change the text
> of the field. If I set the permission to cmf.ManagePortal the content is
> not visible inside the edit view.
>
>
Instead of messing with the permissions, set the field's mode to
'display' so that the widget is rendered as a view of the value rather
than an input field, even when it's included on an edit form (where the
widgets default to input mode):

from plone.directives import form
form.mode(title_declaration_legal='display')


------------------------------------------------------------------------------
LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial
Remotely access PCs and mobile devices and provide instant support
Improve your efficiency, and focus on delivering more value-add services
Discover what IT Professionals Know. Rescue delivers
http://p.sf.net/sfu/logmein_12329d2d
_______________________________________________
Plone-Users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/plone-users
andreasma andreasma
Reply | Threaded
Open this post in threaded view
|

Re: Dexterity: Setting Permissions for Fields

Hi David,

Am 24.12.2012 17:26, schrieb David Glick (Plone):

>
>> (...)
>>
> Instead of messing with the permissions, set the field's mode to
> 'display' so that the widget is rendered as a view of the value rather
> than an input field, even when it's included on an edit form (where
> the widgets default to input mode):
>
> from plone.directives import form
> form.mode(title_declaration_legal='display')
>
thanks David. That helps very much.

Best regards,
Andreas

--
## Developer LibreOffice
## Freie Office-Suite für Linux, Mac, Windows
## http://LibreOffice.org
## Support the Document Foundation (http://documentfoundation.org)
## Meine Seite: http://www.amantke.de 


------------------------------------------------------------------------------
LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial
Remotely access PCs and mobile devices and provide instant support
Improve your efficiency, and focus on delivering more value-add services
Discover what IT Professionals Know. Rescue delivers
http://p.sf.net/sfu/logmein_12329d2d
_______________________________________________
Plone-Users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/plone-users