On Sun, 14 Jan 2001, Jim Washington wrote:

> You probably want the work to be done in the context of an instance of
> the class, so assure you have "context" bound to the Python Script on
> the "bindings" tab.  It's bound by default.
> You might want to name the Script in a Zopish way to distinguish it from
> other scripts that may do other things.  I would probably call it
> manage_changeCDProperties.
> You will want to pass REQUEST to it so you can use it like the Zope
> builtins:
> containerName.CDInfoName.manage_changeCDProperties(REQUEST)
> So, put REQUEST in the parameters list.

I'm afraid I'm a bit confused here. Is 'CDInfoName' the id of an instance of
this CD class? If so, what would 'containerName' be?

In the particular example I'm thinking about (not a CD collection), I've
created a form that displays the current properties of the class (a job
opening for the H.R. deparment in my case), allows the user to modify any of
the properties in the form, and submit those changes. I suppose for the CD
example it would something like: (ignoring everything but the form)

<form action="manage_changeCDProperties(REQUEST)">
<table border="0">

  <td><input type="text" name="title" value="<dtml-var title>"></td>

  <td><input type="text" name="artist" value="<dtml-var artist>"></td>

<input type="submit" value=" Submit Edits ">

I don't think I'm calling the PythonScript correctly. In fact, I suspect I'm
quite a bit off.

> Inside the script, you would use Zope's manage_changeProperties method:
> context.propertysheets['cd_info'].manage_changeProperties(REQUEST)
> -or-
> context.propertysheets.cd_info.manage_changeProperties(REQUEST)

Following Evan's advice, would this then be:


So that's a one-liner? Hmmm. Cool if true. :-)

Let's say that I wanted to redirect the user back to the Web page where they
had begun this process. How would that be accomplished?


> Timothy Wilson wrote:
> > 
> > Hi everyone,
> > 
> > I'm looking forward to using some PythonScripts as methods of some ZClasses
> > because it seems like a much cleaner way to do things. I wonder if one of
> > the PythonScript gurus out there would be willing to show an example of two
> > presumably common PythonScript/ZClass tasks: processing changes to a
> > property sheet using form input and deleting a ZClass instance.
> > 
> > Let's say we've got a ZClass for keeping track of a CD collection. (I recall
> > seeing that example in a ZClass How-To.) Let's say the ZClass has a property
> > sheet called 'cd_info' with the following properties:
> > 
> > title (string)
> > artist (string)
> > date_purchased (date)
> > 
> > (for extra credit, add a 'songs' property of type 'lines' :-)
> > 
> > Is that enough info? Anybody want to take a crack at this? (This would
> > surely be good info to put at zope.org somewhere.)
> > 
> > -Tim

Tim Wilson      | Visit Sibley online:         | Check out:
Henry Sibley HS | http://www.isd197.k12.mn.us/ | http://www.zope.org/
W. St. Paul, MN |                              | http://slashdot.org/
[EMAIL PROTECTED] |   <dtml-var pithy_quote>     | http://linux.com/

Zope maillist  -  [EMAIL PROTECTED]
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-dev )

Reply via email to