ZClasses meet PythonScripts, sample request
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/ wilson@visi.com | <dtml-var pithy_quote> | http://linux.com/
Hi, Tim I am not working through that example, but the below is a start on what you seem to need. Let me know what you think. good luck! -- Jim Washington *************************************** 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. (BTW, REQUEST is available as context.REQUEST if you choose not to pass REQUEST.) 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) You're done, unless you want to get fancy and process the items separately. If you want to get fancy, REQUEST.form['title'], REQUEST.form['artist'], and REQUEST.form['date_purchased'] are available to you. For example, if you want to assure title case for title and artist (try this in DTML first, just to get the scope of how much easier it is in a Python Script): import string dontCapitalize = ['a','in','of', 'for'] localPropertiesDict = {} for aproperty in ['title','artist']: theProperty = string.strip(REQUEST.form[aproperty]) splitWords = string.split(theProperty) newlist = [] for aWord in splitWords: if aWord in dontCapitalize and aWord != splitWords[0]: newlist.append(string.lower(aWord)) else: newlist.append(string.capitalize(aWord)) newValue = string.join(newlist,' ') localPropertiesDict[aproperty] = newValue context.propertysheets['cd_info'].manage_changeProperties(localPropertiesDict) **************************************** To delete something from the ZODB, pass a list of ids to manage_delObjects in your container. To delete them all: thelist = context.containerName.objectIds('CD_Info') context.containerName.manage_delObjects(thelist) Let's say you lent out all your Britney Spears CDs and don't expect to get them back. How do you update your collection? Make a form that allows you to select 'Britney Spears' into a variable called 'deleteThisArtist' Make a Python Script that is called by the action for the form. This goes into your class for CD collection, whatever you have named it. import string #we make this case-insensitive by converting all to uppercase deleteMe = string.upper(context.REQUEST.form['deleteThisArtist']) listToDel = [] for CD in context.objectValues('CD_Info'): if string.upper(CD.artist) == deleteMe: listToDel.append(CD.id) #in Zope-2.3.0+, you should use .getId() instead of .id context.manage_delObjects(listToDel) 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
From: "Jim Washington" <jwashin@vt.edu>
I am not working through that example, but the below is a start on what you seem to need. Let me know what you think.
Thanks for the fine examples! I have only one nit to pick; When using Scripts in ZClasses, you will typically want to use 'container', not 'context', since 'context' may not be the ZClass instance, but 'container' always is. Of course, a Script may operate on both the instance and on whatever object it was called on, in which case both 'container' and 'context' will be used. Cheers, Evan @ digicool & 4-am
On Sun, 14 Jan 2001, Jim Washington wrote:
I am not working through that example, but the below is a start on what you seem to need. Let me know what you think.
Thanks Jim. I will study the examples you provided. Do you suppose that the Zope Book would benefit from some examples of this type? -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/ wilson@visi.com | <dtml-var pithy_quote> | http://linux.com/
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"> <tr><th>Title</th> <td><input type="text" name="title" value="<dtml-var title>"></td> </tr> <tr><th>Artist</th> <td><input type="text" name="artist" value="<dtml-var artist>"></td> </tr> <tr><td> <input type="submit" value=" Submit Edits "> </td></tr> </table> </form> 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: container.propertysheets['cd_info'].manage_changeProperties(REQUEST) 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? -Tim
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/ wilson@visi.com | <dtml-var pithy_quote> | http://linux.com/
Hi, Tim
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?
Yes. CDInfoName here would be an instance of your CD Class. containerName is the name of the container, whether it be a folder or a folderish ZClass made for handling a collection of CD Class objects. It doesn't have to be there in the statement unless something else is asking the folderish object to ask the CD Class object to change the properties, which at the moment seems kind of silly. I must have gotten off on containers with your second question about deletion. Apologies for the confusion.
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">
<tr><th>Title</th> <td><input type="text" name="title" value="<dtml-var title>"></td> </tr>
<tr><th>Artist</th> <td><input type="text" name="artist" value="<dtml-var artist>"></td> </tr>
<tr><td> <input type="submit" value=" Submit Edits "> </td></tr> </table> </form>
I don't think I'm calling the PythonScript correctly. In fact, I suspect I'm quite a bit off.
I think it would work, at least as far as updating the properties, but it would not return anything. See below my attempt at an alternative.
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:
container.propertysheets['cd_info'].manage_changeProperties(REQUEST)
So that's a one-liner? Hmmm. Cool if true. :-)
Always has been, even in DTML.
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?
There are many ways. I like to make it all happen at the beginning of the DTML Method. Hacking up the form you provided above (lines with ! have been added or changed): !<dtml-var standard_html_header> !<dtml-if "REQUEST.form.has_key('editCD')"> ! <dtml-call "manage_changeCDProperties(REQUEST)"> ! <p><font color="red">Your changes have been saved</font></p> !</dtml-if> !<form action="replace_this_with_id_of_this_method"> <table border="0"> <tr><th>Title</th> <td><input type="text" name="title" value="<dtml-var title>"></td> </tr> <tr><th>Artist</th> <td><input type="text" name="artist" value="<dtml-var artist>"></td> </tr> <tr><td> ! <input type="submit" name="editCD" value=" Submit Edits "> </td></tr> </table> </form> !<dtml-var standard_html_footer> Hoping I have not confused further, -- Jim Washington
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
This seems to almost work. :-) On Sun, 14 Jan 2001, Jim Washington wrote:
!<dtml-var standard_html_header>
!<dtml-if "REQUEST.form.has_key('editCD')"> ! <dtml-call "manage_changeCDProperties(REQUEST)"> ! <p><font color="red">Your changes have been saved</font></p> !</dtml-if>
!<form action="replace_this_with_id_of_this_method"> <table border="0">
<tr><th>Title</th> <td><input type="text" name="title" value="<dtml-var title>"></td> </tr>
<tr><th>Artist</th> <td><input type="text" name="artist" value="<dtml-var artist>"></td> </tr>
<tr><td> ! <input type="submit" name="editCD" value=" Submit Edits "> </td></tr> </table> </form> !<dtml-var standard_html_footer>
That's quite clever. I wouldn't have thought of doing it that way. After translating the CD example to my own ZClass, I get the following error after hitting "Submit Edits" on the edit form: <h2>Zope Error</h2> <p>Zope has encountered an error while publishing this resource. </p> <p><strong>Resource not found</strong></p> Sorry, the requested Zope resource does not exist.<p>Check the URL and try again.<p> <!-- http://www.isd197.k12.mn.us/hr/jobs/postings/1234/editJobAction%28REQUEST%29 --> and the traceback: Traceback (innermost last): File /var/lib/zope/2.3.0a2/lib/python/ZPublisher/Publish.py, line 222, in publish_module File /var/lib/zope/2.3.0a2/lib/python/ZPublisher/Publish.py, line 187, in publish File /var/lib/zope/2.3.0a2/lib/python/Zope/__init__.py, line 221, in zpublisher_exception_hook (Object: Traversable) File /var/lib/zope/2.3.0a2/lib/python/ZPublisher/Publish.py, line 162, in publish File /var/lib/zope/2.3.0a2/lib/python/ZPublisher/BaseRequest.py, line 369, in traverse File /var/lib/zope/2.3.0a2/lib/python/ZPublisher/HTTPResponse.py, line 528, in notFoundError NotFound: (see above) It looks like REQUEST isn't getting passed correctly. I've got REQUEST listed as a parameter for my PythonScript. I don't need to mess with bindings do I? -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/ wilson@visi.com | <dtml-var pithy_quote> | http://linux.com/
Hi, Tim You do not need to mess with the Python Script bindings. It looks like you are trying to get URL: www.isd197.k12.mn.us/hr/jobs/postings/1234/editJobAction(REQUEST) Which of course does not exist. I would change your <form action=".. line to <form action="editJobAction" method="post"> assuming the DTML Method that has the form is called editJobAction. Don't worry about passing REQUEST there; Zope takes care of that. -- Jim Washington Timothy Wilson wrote:
This seems to almost work. :-)
On Sun, 14 Jan 2001, Jim Washington wrote:
!<dtml-var standard_html_header>
!<dtml-if "REQUEST.form.has_key('editCD')"> ! <dtml-call "manage_changeCDProperties(REQUEST)"> ! <p><font color="red">Your changes have been saved</font></p> !</dtml-if>
!<form action="replace_this_with_id_of_this_method"> <table border="0">
<tr><th>Title</th> <td><input type="text" name="title" value="<dtml-var title>"></td> </tr>
<tr><th>Artist</th> <td><input type="text" name="artist" value="<dtml-var artist>"></td> </tr>
<tr><td> ! <input type="submit" name="editCD" value=" Submit Edits "> </td></tr> </table> </form> !<dtml-var standard_html_footer>
That's quite clever. I wouldn't have thought of doing it that way.
After translating the CD example to my own ZClass, I get the following error after hitting "Submit Edits" on the edit form:
<h2>Zope Error</h2> <p>Zope has encountered an error while publishing this resource. </p> <p><strong>Resource not found</strong></p> Sorry, the requested Zope resource does not exist.<p>Check the URL and try again.<p> <!-- http://www.isd197.k12.mn.us/hr/jobs/postings/1234/editJobAction%28REQUEST%29 -->
and the traceback:
Traceback (innermost last): File /var/lib/zope/2.3.0a2/lib/python/ZPublisher/Publish.py, line 222, in publish_module File /var/lib/zope/2.3.0a2/lib/python/ZPublisher/Publish.py, line 187, in publish File /var/lib/zope/2.3.0a2/lib/python/Zope/__init__.py, line 221, in zpublisher_exception_hook (Object: Traversable) File /var/lib/zope/2.3.0a2/lib/python/ZPublisher/Publish.py, line 162, in publish File /var/lib/zope/2.3.0a2/lib/python/ZPublisher/BaseRequest.py, line 369, in traverse File /var/lib/zope/2.3.0a2/lib/python/ZPublisher/HTTPResponse.py, line 528, in notFoundError NotFound: (see above)
It looks like REQUEST isn't getting passed correctly. I've got REQUEST listed as a parameter for my PythonScript. I don't need to mess with bindings do I?
Jim (or anyone else who's feeling charitable this morning), Thanks for all your help. I really appreciate it. I wonder if you'd have time to look one more time at the two methods I've got that aren't working. I've included the actual code for my job posting product. Perhaps someone will find it instructive. I have a feeling that the remaining problem is not directly related to the processing of the form by the PythonScript. I also included the traceback at the end of this message. Here are the two methods. I have a table that displays the currently available jobs and displays two little icons which call the edit or delete methods on the corresponding instance of the 'Job Posting' class. The edit icon links to the 'editJobForm' method which in turn calls the 'editFormAction' method that actually processing the change. ------------------ editJobForm ----------------- <dtml-var standard_html_header> <h2>Edit a Job Board Entry</h2> <p>This form allows you to make changes to current postings on the online job board. You don't needed to fill in every field on the form. Click on the "Submit Edits" button at the bottom of the screen to save your changes to the database.</p> <dtml-if "REQUEST.form.has_key('editJob')"> <dtml-call "editFormAction(REQUEST)"> <p><font color="red">Your changes have been saved</font></p> </dtml-if> <form action="editJobForm"> <table border="0"> <tr><th>Notes</th> <td><textarea name="notes:text" rows="10" cols="60" wrap="virtual"><dtml-var notes></textarea></td> </tr> <tr><th>Job ID</th> <td><input type="text" name="id" size="20" value="<dtml-var id>"></td> </tr> <tr><th>Organization</th> <td><input type="text" name="organization" size="60" value="<dtml-var org_name>"></td> </tr> <tr><th>Position</th> <td><input type="text" name="position" size="60" value="<dtml-var name>"></td> </tr> <tr><th>Description</th> <td><textarea name="description:text" rows="10" cols="60" wrap="virtual"><dtml-var description></textarea></td> </tr> <tr><th>Pay Offered</th> <td><input type="text" name="pay" size="60" value="<dtml-var pay>"></td> </tr> <tr><th>Line of Authority</th> <td><input type="text" name="loa" size="60" value="<dtml-var loa>"></td> </tr> <tr><th>Function</th> <td><textarea name="function:text" rows="4" cols="60" wrap="virtual"><dtml-var function></textarea></td> </tr> <tr><th>Qualifications</th> <td><textarea name="qualifications:text" rows="8" cols="60" wrap="virtual"><dtml-var qualifications></textarea></td> </tr> <tr> <td colspan=2> <p>To create a bullet list of "duties," type each one in the box below and press the "ENTER" key between each item in the list.</p> </td> </tr> <tr><th>Duties</th> <dtml-if duties> <td><textarea name="duties:list" rows="10" cols="60" wrap="virtual"><dtml-in duties><dtml-let item=sequence-item><dtml-if item> <dtml-var item> </dtml-if></dtml-let></dtml-in></textarea></td> <dtml-else> <td><textarea name="duties:list" rows="10" cols="60" wrap="virtual"></textarea></td> </dtml-if> </tr> <tr><th>Offer Expires</th> <td><input type="text" name="expires" size="20" value="<dtml-var offer_expires fmt="%m/%d/%Y">"></td> </tr> <tr> <td colspan=2><p>Enter the date that the job was officially posted.</p></td> </tr> <tr><th>Posted Date</th> <td><input type="text" name="posted" size="20" value="<dtml-var date_posted fmt="%m/%d/%Y">"></td> </tr> <tr> <td> </td> <td> <input type="submit" name="editJob" value=" Submit Edits "> </form> <form action="admin_html"> <input type="submit" value=" Cancel "> </form> </td> </tr> </table> <dtml-var standard_html_footer> ----------------- editFormAction (with REQUEST as a parameter) ----------------- container.propertysheets['job_info'].manage_changeProperties(REQUEST) The error I get is: Error Type: TypeError Error Value: sequence index must be integer Traceback: Traceback (innermost last): File /var/lib/zope/2.3.0a2/lib/python/ZPublisher/Publish.py, line 222, in publish_module File /var/lib/zope/2.3.0a2/lib/python/ZPublisher/Publish.py, line 187, in publish File /var/lib/zope/2.3.0a2/lib/python/Zope/__init__.py, line 221, in zpublisher_exception_hook (Object: Traversable) File /var/lib/zope/2.3.0a2/lib/python/ZPublisher/Publish.py, line 171, in publish File /var/lib/zope/2.3.0a2/lib/python/ZPublisher/mapply.py, line 160, in mapply (Object: editJobForm) File /var/lib/zope/2.3.0a2/lib/python/ZPublisher/Publish.py, line 112, in call_object (Object: editJobForm) File /var/lib/zope/2.3.0a2/lib/python/OFS/DTMLMethod.py, line 189, in __call__ (Object: editJobForm) File /var/lib/zope/2.3.0a2/lib/python/DocumentTemplate/DT_String.py, line 538, in __call__ (Object: editJobForm) File /var/lib/zope/2.3.0a2/lib/python/DocumentTemplate/DT_Util.py, line 336, in eval (Object: editFormAction(REQUEST)) (Info: REQUEST) File <string>, line 0, in ? File /var/lib/zope/2.3.0a2/lib/python/Shared/DC/Scripts/Bindings.py, line 325, in __call__ (Object: editFormAction) File /var/lib/zope/2.3.0a2/lib/python/Shared/DC/Scripts/Bindings.py, line 354, in _bindAndExec (Object: editFormAction) File /var/lib/zope/2.3.0a2/lib/python/Products/PythonScripts/PythonScript.py, line 321, in _exec (Object: editFormAction) (Info: ({'script': <PythonScript instance at 8826790>, 'context': <JobPosting instance at 871e068>, 'container': <Folder instance at 885a3e0>, 'traverse_subpath': []}, (<h3>form</h3><table><tr valign="top" align="left"><th>posted</th><td>'01/14/2001'</td></tr><tr valign="top" align="left"><th>duties</th><td>['asdfasdf\015\012']</td></tr><tr -- I've deleted what looks like the entire contents of REQUEST -- File Python Script, line 2, in editFormAction File /var/lib/zope/2.3.0a2/lib/python/Products/PythonScripts/Guarded.py, line 276, in __getitem__ File /var/lib/zope/2.3.0a2/lib/python/OFS/PropertySheets.py, line 647, in __getitem__ (Object: Traversable) TypeError: (see above) -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/ wilson@visi.com | <dtml-var pithy_quote> | http://linux.com/
Hi, Tim I have it. The Python Script I sent you: container.propertysheets['job_info'].manage_changeProperties(REQUEST) needs to be rewritten: container.propertysheets.job_info.manage_changeProperties(REQUEST) Perhaps someone could explain why the first does not work. One point about your form: You have id as a form variable. You will be disappointed by its behavior. Regards, -- Jim Washington Timothy Wilson wrote:
Jim (or anyone else who's feeling charitable this morning),
Thanks for all your help. I really appreciate it. I wonder if you'd have time to look one more time at the two methods I've got that aren't working. I've included the actual code for my job posting product. Perhaps someone will find it instructive. I have a feeling that the remaining problem is not directly related to the processing of the form by the PythonScript. I also included the traceback at the end of this message.
Here are the two methods. I have a table that displays the currently available jobs and displays two little icons which call the edit or delete methods on the corresponding instance of the 'Job Posting' class. The edit icon links to the 'editJobForm' method which in turn calls the 'editFormAction' method that actually processing the change.
------------------ editJobForm -----------------
<dtml-var standard_html_header>
<h2>Edit a Job Board Entry</h2> <p>This form allows you to make changes to current postings on the online job board. You don't needed to fill in every field on the form. Click on the "Submit Edits" button at the bottom of the screen to save your changes to the database.</p>
<dtml-if "REQUEST.form.has_key('editJob')"> <dtml-call "editFormAction(REQUEST)"> <p><font color="red">Your changes have been saved</font></p> </dtml-if>
<form action="editJobForm"> <table border="0">
<tr><th>Notes</th> <td><textarea name="notes:text" rows="10" cols="60" wrap="virtual"><dtml-var notes></textarea></td> </tr> <tr><th>Job ID</th> <td><input type="text" name="id" size="20" value="<dtml-var id>"></td> </tr> <tr><th>Organization</th> <td><input type="text" name="organization" size="60" value="<dtml-var org_name>"></td> </tr> <tr><th>Position</th> <td><input type="text" name="position" size="60" value="<dtml-var name>"></td> </tr> <tr><th>Description</th> <td><textarea name="description:text" rows="10" cols="60" wrap="virtual"><dtml-var description></textarea></td> </tr> <tr><th>Pay Offered</th> <td><input type="text" name="pay" size="60" value="<dtml-var pay>"></td> </tr> <tr><th>Line of Authority</th> <td><input type="text" name="loa" size="60" value="<dtml-var loa>"></td> </tr> <tr><th>Function</th> <td><textarea name="function:text" rows="4" cols="60" wrap="virtual"><dtml-var function></textarea></td> </tr> <tr><th>Qualifications</th> <td><textarea name="qualifications:text" rows="8" cols="60" wrap="virtual"><dtml-var qualifications></textarea></td> </tr> <tr> <td colspan=2> <p>To create a bullet list of "duties," type each one in the box below and press the "ENTER" key between each item in the list.</p> </td> </tr> <tr><th>Duties</th> <dtml-if duties> <td><textarea name="duties:list" rows="10" cols="60" wrap="virtual"><dtml-in duties><dtml-let item=sequence-item><dtml-if item> <dtml-var item> </dtml-if></dtml-let></dtml-in></textarea></td> <dtml-else> <td><textarea name="duties:list" rows="10" cols="60" wrap="virtual"></textarea></td> </dtml-if> </tr> <tr><th>Offer Expires</th> <td><input type="text" name="expires" size="20" value="<dtml-var offer_expires fmt="%m/%d/%Y">"></td> </tr> <tr> <td colspan=2><p>Enter the date that the job was officially posted.</p></td> </tr> <tr><th>Posted Date</th> <td><input type="text" name="posted" size="20" value="<dtml-var date_posted fmt="%m/%d/%Y">"></td> </tr> <tr> <td> </td> <td> <input type="submit" name="editJob" value=" Submit Edits "> </form> <form action="admin_html"> <input type="submit" value=" Cancel "> </form> </td> </tr> </table>
<dtml-var standard_html_footer>
----------------- editFormAction (with REQUEST as a parameter) -----------------
container.propertysheets['job_info'].manage_changeProperties(REQUEST)
The error I get is:
Error Type: TypeError Error Value: sequence index must be integer
Traceback:
Traceback (innermost last): File /var/lib/zope/2.3.0a2/lib/python/ZPublisher/Publish.py, line 222, in publish_module File /var/lib/zope/2.3.0a2/lib/python/ZPublisher/Publish.py, line 187, in publish File /var/lib/zope/2.3.0a2/lib/python/Zope/__init__.py, line 221, in zpublisher_exception_hook (Object: Traversable) File /var/lib/zope/2.3.0a2/lib/python/ZPublisher/Publish.py, line 171, in publish File /var/lib/zope/2.3.0a2/lib/python/ZPublisher/mapply.py, line 160, in mapply (Object: editJobForm) File /var/lib/zope/2.3.0a2/lib/python/ZPublisher/Publish.py, line 112, in call_object (Object: editJobForm) File /var/lib/zope/2.3.0a2/lib/python/OFS/DTMLMethod.py, line 189, in __call__ (Object: editJobForm) File /var/lib/zope/2.3.0a2/lib/python/DocumentTemplate/DT_String.py, line 538, in __call__ (Object: editJobForm) File /var/lib/zope/2.3.0a2/lib/python/DocumentTemplate/DT_Util.py, line 336, in eval (Object: editFormAction(REQUEST)) (Info: REQUEST) File <string>, line 0, in ? File /var/lib/zope/2.3.0a2/lib/python/Shared/DC/Scripts/Bindings.py, line 325, in __call__ (Object: editFormAction) File /var/lib/zope/2.3.0a2/lib/python/Shared/DC/Scripts/Bindings.py, line 354, in _bindAndExec (Object: editFormAction) File /var/lib/zope/2.3.0a2/lib/python/Products/PythonScripts/PythonScript.py, line 321, in _exec (Object: editFormAction) (Info: ({'script': <PythonScript instance at 8826790>, 'context': <JobPosting instance at 871e068>, 'container': <Folder instance at 885a3e0>, 'traverse_subpath': []}, (<h3>form</h3><table><tr valign="top" align="left"><th>posted</th><td>'01/14/2001'</td></tr><tr valign="top" align="left"><th>duties</th><td>['asdfasdf\015\012']</td></tr><tr
-- I've deleted what looks like the entire contents of REQUEST --
File Python Script, line 2, in editFormAction File /var/lib/zope/2.3.0a2/lib/python/Products/PythonScripts/Guarded.py, line 276, in __getitem__ File /var/lib/zope/2.3.0a2/lib/python/OFS/PropertySheets.py, line 647, in __getitem__ (Object: Traversable) TypeError: (see above)
On Mon, 15 Jan 2001, Jim Washington wrote:
One point about your form:
You have id as a form variable. You will be disappointed by its behavior.
Thanks Jim. Care to elaborate on the problems with using id as a form variable. -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/ wilson@visi.com | <dtml-var pithy_quote> | http://linux.com/
participants (3)
-
Evan Simpson -
Jim Washington -
Timothy Wilson