[Zope] Changing Objects properties

J Cameron Cooper jccooper@jcameroncooper.com
Mon, 24 Mar 2003 17:25:38 -0600


>
> I have a newbee question. I have made a form in a DTMLMethod which i’m 
> going to use, to change some properties in an object. I’m calling it 
> with: http://site/theObjectToChange/theMethod - and that part is 
> working fine. When I have changed the values, how can I “save” those 
> changes to the object.

In Zope if you change an attribute or property, it stays changed. 
(That's the whole deal behind persistence.)

What you may be thinking of is the passing of form data, which is 
available in the method to which you've passed that data. That's part of 
the REQUEST, which is a transient object. You can get at form data in 
the method that was just called, but in order to use it for other than 
immediate display, you'll have to do something with it in 'theMethod' . 
Probably you want manage_changeProperties(), from what I read, which 
will change the properties of the object it's being called on (in your 
case the container of 'theMethod') based on the name=value pairs in the 
REQUEST (which is a required parameter of that method) and any 
parameters passed to the method.

Example:

calling as http://server/container/method?title=moose a method containing

<dtml-call "manage_changeProperties(REQUEST)">
I got the title = <dtml-var title> and set it.

will set the 'title' property of 'container' to 'moose', as well as 
print that value. One can do this with either GET or POST actions.

One can also do

<dtml-call "manage_changeProperties(title='mooses')">

without needing the REQUEST object.

You can do this with more than 'manage_changeProperties()': any method 
of any object could be used like this.

--jcc