problem with lines properties
Hi everyone, I've built a couple ZClasses that utilize a "lines" property that, when an instance of the class is viewed, is rendered as a <ul>. The problem is that when the instance is first viewed, the iteration through the lines property doesn't work correctly and I get a one-item <ul> with all the lines rendered in the same <li>. Strangely, if I visit the ZMI edit screen for the instance and click on "Save Changes" then the instance displays perfectly every time after that. Anybody seen anything like this? -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 Are you putting the data into the "lines" properties programmatically? What does that code look like? -- Jim Washington Timothy Wilson wrote:
Hi everyone,
I've built a couple ZClasses that utilize a "lines" property that, when an instance of the class is viewed, is rendered as a <ul>. The problem is that when the instance is first viewed, the iteration through the lines property doesn't work correctly and I get a one-item <ul> with all the lines rendered in the same <li>. Strangely, if I visit the ZMI edit screen for the instance and click on "Save Changes" then the instance displays perfectly every time after that.
Anybody seen anything like this?
On Sun, 8 Apr 2001, Jim Washington wrote:
Are you putting the data into the "lines" properties programmatically? What does that code look like?
No, I'm just entering them from the normal ZClass add form. Nothing fancy. The product I'm working on will keep track of our school's lunch menus. So I have a property lunch_menu that might contain: veal shank potato salad baked beans celery sticks (Not necessarily those items :-) The menu is rendered like this: <h2>Lunch</h2> <ul> <dtml-in lunch_menu> <dtml-let item=sequence-item> <li><dtml-var item></li> </dtml-let> </dtml-in> </ul> As I said, this doesn't work until I edit the instance and simply click on the "save changes" option. Weird. -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 might have to do some processing of your ZClass add-form data. I would recommend string.split()ing it and making a list before doing manage_changeProperties(), just to be sure. Lines properties can accept '\n' (i.e., new line) delimited strings or lists. My guess is that somehow you are initializing with something delimited differently, which is not recognized properly. Once it gets into the instance and onto the property sheet, Zope works to display it in a format that is correct, and a "save changes" makes it all proper. hth, -- Jim Washington Timothy Wilson wrote:
On Sun, 8 Apr 2001, Jim Washington wrote:
Are you putting the data into the "lines" properties programmatically? What does that code look like?
No, I'm just entering them from the normal ZClass add form. Nothing fancy. The product I'm working on will keep track of our school's lunch menus. So I have a property lunch_menu that might contain:
veal shank potato salad baked beans celery sticks
(Not necessarily those items :-)
The menu is rendered like this:
<h2>Lunch</h2> <ul> <dtml-in lunch_menu> <dtml-let item=sequence-item> <li><dtml-var item></li> </dtml-let> </dtml-in> </ul>
As I said, this doesn't work until I edit the instance and simply click on the "save changes" option. Weird.
Timothy Wilson wrote:
On Sun, 8 Apr 2001, Jim Washington wrote:
Are you putting the data into the "lines" properties programmatically? What does that code look like?
No, I'm just entering them from the normal ZClass add form. Nothing fancy. The product I'm working on will keep track of our school's lunch menus. So I have a property lunch_menu that might contain:
veal shank potato salad baked beans celery sticks
(Not necessarily those items :-)
The menu is rendered like this:
<h2>Lunch</h2> <ul> <dtml-in lunch_menu> <dtml-let item=sequence-item> <li><dtml-var item></li> </dtml-let> </dtml-in> </ul>
As I said, this doesn't work until I edit the instance and simply click on the "save changes" option. Weird.
-Tim
Setting a property type as lines does not guarantee that the value there is a list. Are you marshalling the form field to lines on you ZClass form? ala: <textarea name="lunch_menu:lines"... -- | Casey Duncan | Kaivo, Inc. | cduncan@kaivo.com `------------------>
On Mon, 9 Apr 2001, Casey Duncan wrote:
Setting a property type as lines does not guarantee that the value there is a list. Are you marshalling the form field to lines on you ZClass form?
ala: <textarea name="lunch_menu:lines"...
I think the correct syntax would be <textarea name="lunch_menu:list"... Yes, I'm doing that. -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/
Timothy Wilson wrote:
On Mon, 9 Apr 2001, Casey Duncan wrote:
Setting a property type as lines does not guarantee that the value there is a list. Are you marshalling the form field to lines on you ZClass form?
ala: <textarea name="lunch_menu:lines"...
I think the correct syntax would be <textarea name="lunch_menu:list"...
Yes, I'm doing that.
-Tim
Actually no. List will not work. List assumes there are multiple fields with that name. It then creates a list of their values. Lines on the other hand takes a single string field, splits it on carriage returns and returns the list, which is what I believe you want. Try it with lines. -- | Casey Duncan | Kaivo, Inc. | cduncan@kaivo.com `------------------>
participants (3)
-
Casey Duncan -
Jim Washington -
Timothy Wilson