[Zope] Re: [Re: [Zope] Dictionary properties within Zope.]
happyrhino@usa.net
happyrhino@usa.net
29 Aug 99 14:16:49 MDT
>> I can add properties which can be lines, strings, numbers.
>> But hasn't anyone found the need to add dictionaries ?
>> In almost every website I've created, the global configuration
>> files are full of dictionary variables.
>> For example, for navigation menus we might have
>> navigation = {"Title 1" : URL1, "Title2" : URL2, etc}
>> from which it's then simple to generate the HTML for the navigation.
>> And there are many other instances where dictionaries save the day.
>
>The problem with this approach is, that you need at least three parts:
>title, url, and sort key.
Yes, that's what I usually have. But I use them over and over
again so it's worth it. The dictionary might be =
{ "geo" : "Geological Reports",
"his" : "Historical Manuscripts",
etc }
and then I have a list ["geo", "his".... ] which defines the list order
since the dictionary.keys() can not be used. URL's are always based upon
these keys so it's pretty much automatic :)
>Actually, this can be done much nicer in ZOPE with the Navigation >Product.
Maybe but I then call these dictionary keys in SQL statements. They're
ingrained into the website.
>> This would have been something very useful to put in the root
>> folder properties as a form of "site configuration".
>Well, this is not actually the ZOPE Zen, as it is absolutly non object
>oriented. What if you delete some object? Or rename it? ...
True. It would be best if these were generated on-the-fly but
>> The only references to dictionaries seem to be with respect to the
>> REQUEST.cookies and REQUEST.form and DTML doesn't seem to have the
>> mechanisms for dealing with dictionary properties on folders.
>Well, you can always set them in DTML methods yourself ;)
>But navigation surely is the wrong usage for dictionaries ;)
Actually, navigation is done via lists. The dictionaries provide
titles or urls for the navigation :) Subtle difference.
Anyway, I think I've found a way to do it. Not very elegant though =
Create a 'lines' property called 'dico'
eg. bio:Biohazard
chem:Chemical
Then in the DTML document use
<dtml-in dico>
<dtml-var "_.string.split(sequence-item,':')[0]">
<dtml-var "_.string.split(sequence-item,':')[1]">
</dtml-in>
except I can't pass sequence-item to the Python expression :(
By the way, is that really the way to use Python string services ?
I tried <dtml-var expr="split()"> or <dtml-var "split()"> as per two
different versions of documentation and it didn't work.
Henry
____________________________________________________________________
Get free email and a permanent address at http://www.netaddress.com/?N=1