[Zope] Help with Edit This Page code?

Amos Latteier amos@aracnet.com
Mon, 11 Oct 1999 09:26:58 -0700


At 04:46 PM 10/10/99 -0700, David Robson wrote:
>
>Can someone please point me to code that will 
>
><> display an ‘Edit this page’ link on pages for which
>the viewer has edit permission
><> redirect user to an ‘edit & save’ window
><> hide the link from other users
>
>(I think there was a similar Q on the list some weeks
>ago but I can’t locate it now.) 

Here's one way to accomplish this:

<dtml-if "AUTHENTICATED_USER.has_permissions('Change DTML Documents',
this())">
<a href="manage_main">Edit this page</a>
</dtml-if>

This DTML fragment looks to see if the current user has the 'Change DTML
Documents' permission on the current object (this()) and if so, it displays
a link to the manage_main method.

Note, you could define another permission if you wish, though if you wish
to use standard Zope management screens you will need to give your users
adequate permissions to use them.

In general you can send a user to a Zope management screen and only those
options for which they have permissions, will appear in the management
interface. This is in general what you want.

If you don't want to use the Zope management interface you can write your
own methods for editing Zope objects, but you still need to make sure that
the users have adequate permissions, or that you set proxy roles on the
editing forms.

Good luck!

-Amos

P.S. A good way (in absence of exhaustive documentation of the internal
workings of Zope) to figure stuff like this out, is to go to the management
screens and see which URLS do what you want.