Zope-artists, Regretably, I have suffered an anurism trying to define a two-variable property in Zope. Such as: Fruit basket: 20 oranges 30 bannanas 15 apples or myProperty has values [['a',20],['b',30]] I have tried marshalling the data using trinkets, and TinyTables, all of which have no good way to get the data in and out of this type of simple list within a list. Whilst I sew my brain back together, does anyone have any really easy way that can save me from further self-surgery? All my best, -- Jason Spisak webmaster@hiretechs.com
Jason Spisak wrote:
Zope-artists,
Regretably, I have suffered an anurism trying to define a two-variable property in Zope.
I usually use a lines property and then split it up, similar to the way TinyTables store data. E.g. Example - a lines property that displays as: a ::: 3 b ::: 4 and then <dtml-in Examples> <dtml-call "REQUEST.set('pair', _.string.split(_['sequence-item'], ' ::: '))"> <dtml-var "REQUEST['pair'][0]"> is <dtml-var "REQUEST['pair'][1]"><br> </dtml-in> I usually use pythonmethods though, since its cleaner. -- Itamar S.T. itamars@ibm.net
Thank you, Itamar, I only need a two value property so a python method is a bit overkill. Thanks very much. I made a post to the list just before I got your message. Is there a way to get the index of a sequence-item that has been split without reassigning to the REQUEST? All my best, and thanks
Zope-artists,
Regretably, I have suffered an anurism trying to define a two-variable property in Zope.
I usually use a lines property and then split it up, similar to the way TinyTables store data.
E.g. Example - a lines property that displays as: a ::: 3 b ::: 4
and then
<dtml-in Examples> <dtml-call "REQUEST.set('pair', _.string.split(_['sequence-item'], ' ::: '))"> <dtml-var "REQUEST['pair'][0]"> is <dtml-var "REQUEST['pair'][1]"><br> </dtml-in>
I usually use pythonmethods though, since its cleaner.
-- Itamar S.T. itamars@ibm.net
Jason Spisak webmaster@hiretechs.com Under US Code Title 47, Sec.227(b)(1)(C), Sec.227(a)(2)(B) This email address may not be added to any commercial mail list with out my permission. Violation of my privacy with advertising or SPAM will result in a suit for a MINIMUM of $500 damages/incident, $1500 for repeats.
One of the easiest (and least obvious) ways to create complex "properties" in Zope is to return them from a Method. They are then very easy to view, edit, or use. Unfortunately, if you need to update such a "property" from DTML, it's nearly impossible. For example, if we create a DTML Method 'complex_data' containing: <dtml-return expr=" _(mom='Penney', dad='Evan', kids=['Ashley', 'Jason', 'Sam', 'Alex']) "> then we can write: <dtml-with complex_data> <dtml-var mom>, <dtml-var dad>:<dtml-in kids> <dtml-var sequence-item></dtml-in> </dtml-with> You can even make a pseudo-table out of namespaces by concatenating them: <dtml-return expr=" _.namespace(row=1, qty=20, fruit='oranges') +_.namespace(row=2, qty=30, fruit='bananas') +_.namespace(row=3, qty=15, fruit='apples') "> allows: <dtml-in complex_data sort=qty> <dtml-var row>: <dtml-var qty> <dtml-var fruit> </dtml-in> ----- Original Message ----- From: Jason Spisak <webmaster@hiretechs.com>
Regretably, I have suffered an anurism trying to define a two-variable property in Zope.
Such as:
Fruit basket: 20 oranges 30 bannanas 15 apples
Unfortunately, if you need to update such a "property" from DTML, it's nearly impossible.
By this, do you mean that using forms on the web to put info into and out of this kind of property is nearly impossible? Because that is what I am finding out. After much brain twisting I am unable to marshal the data into and out of a simple two variable property in any normal fashion. I really hope there is a way to do this that we are missing. All my best, Jason Spisak webmaster@hiretechs.com Under US Code Title 47, Sec.227(b)(1)(C), Sec.227(a)(2)(B) This email address may not be added to any commercial mail list with out my permission. Violation of my privacy with advertising or SPAM will result in a suit for a MINIMUM of $500 damages/incident, $1500 for repeats.
participants (4)
-
Evan Simpson -
Itamar Shtull-Trauring -
Jason Spisak -
Jason Spisak