[Zope] overriding __str__ method?

Tim Cook twcook@iswt.com
Sun, 08 Oct 2000 21:33:25 -0500


Seb Bacon wrote:

> My strategy:
> Each element that I want the user to be able to edit is a ZClass with a
> manage_content method.  This provides the custom management view (e.g.
> combines properties and title/data into a single form).
> Now I want a way to give the user access to this screen.  I could do a new
> version of the folders tree view (manage_menu), but what I'd really like to
> do is have a button next to each of these elements ("edit this") which calls
> its manage_content method.  The button would only appear when the user was
> authenticated / authorised.
> 
> My problem:
> The only place I can think of doing this is in each object's __str__ method.
> But AFAIK there's no convenient way of overriding its default behaviour.
> What I'd like to do is override it in the ZClass views interface.  I can
> override the 'View' method (from the ZClass 'views' tab), but that doesn't
> get called in the course of rendering a component in a page.  The problem
> would seem to be that there's no equivalent of the __str__ method available
> to override...  Or is there?

Either I don't understand the problem or you're making it too
complicated. <g>

You have a form to edit the properties.
...
<input type="text" name="last_name" value="&dtml-last_name;">
...

The action method of this form sets the REQUEST variables to the
property names:
...
<dtml-call "REQUEST.set('last_name', REQUEST['last_name'])">
...
(I generally use the same names for form vars and property names
to avoid confusing myself)

then:
<dtml-call "manage_changeProperties(REQUEST)">

Does this help?

-- Tim Cook --
Cook Information Systems | Office: (901) 884-4126 8am-5pm CDT
* It's easy to stop making mistakes. Just stop having ideas.  *
FreePM Project Coordinator http://www.freepm.org
OSHCA Founding Supporter http://www.oshca.org