[Zope] Editing ZClasses - Hole in Documentation

Casey Duncan c.duncan@nlada.org
Thu, 15 Nov 2001 09:35:01 -0500


On Thursday 15 November 2001 06:55 am, Ronald L. Chichester allegedly wrote:
[snip]
> Some of us have products we would like to roll out that require that
> users (including managers, owners, and yes, sometimes even anonymous (if
> your organization can handle that)) to edit the ZClass instance once it
> has been instantiated.  I'm still hunting for either documentation or an
> example that has this capability.  In a few instances, I have seen
> people say it is "trivial."  It may be, once you find out how.
> Unfortunately, there is still some smoke and mirrors here.  The solution
> isn't obvious to the casual developer.
>
> If someone can prove me wrong, I would be thrilled to know about it.
>
> Best,
>
> Ron

You dare to suggest that there is a capability of Zope that is undocumented? 
I find the mere suggestion of this utterly infathomable!

Seriously, tho, the API of Zope and especially ZClasses is pretty opaque in 
places, unless you like hunting through the source code, which in the case of 
ZClasses doesn't help much without Jim F. looking over your shoulder... 8^)

Actually there is an example of how to do this right under your nose. The 
default constructor method of the ZClass has the important call syntax in a 
comment as an example. Something like:

<dtml-call expr="propertysheets.Basic.manage_editProperties(REQUEST)">

Now, manage_editProperties is fine so long as you want to change all of the 
properties at once, but not if you only need to change one or two. For that, 
use manage_changeProperties.

This call would work in response to a form (either from Python or DTML):

propertysheets.my_property_sheet.manage_changeProperties(REQUEST)

just make sure the ZClass instance is at the top of the namespace stack, 
which is easily accomplished using the URL as in:

http://zope/path/to/instance/editMethod

<plug type="shameless">
You can find a complete example of a ZClass based app in the newly-published 
"Book of Zope" which is sadly only available in dead-tree form. Although you 
can download the ZCatalog chapter at www.nostarch.com.
</plug>

hth,
/---------------------------------------------------\
  Casey Duncan, Sr. Web Developer
  National Legal Aid and Defender Association
  c.duncan@nlada.org
\---------------------------------------------------/