Re: [Re: [Zope] Dictionary properties within Zope.]
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
On 29 Aug 1999 happyrhino@usa.net wrote:
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. Hmmm. Well, let's hope you won't have to change the titles of some pages. Reduant data is not a good idea, at least not from the viewpoint of data consistency. ;) True. It would be best if these were generated on-the-fly but But? Sorry, the fact is, that "HTML pages" are usually generated from ZOPE objects. As such, you should not store their URLs or titles in some additional storage, or you are in an awful portion of maintenance problems. (Well, other systems don't allow for this, but then there are many sites with broken links, right?)
Actually, navigation is done via lists. The dictionaries provide titles or urls for the navigation :) Subtle difference. Ok, so you have multiply reduant data: *) list of dictionary keys. What happens if you make an typo in the list, or the dictionary. *) URL of object. Again the same.
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]"> Well, try _.string.split(_['sequence-item'],':')[0]
By the way, is that really the way to use Python string services ? Yeap, it is ;)
Andreas -- Andreas Kostyrka | andreas@mtg.co.at phone: +43/1/7070750 | phone: +43/676/4091256 MTG Handelsges.m.b.H. | fax: +43/1/7065299 Raiffeisenstr. 16/9 | 2320 Zwoelfaxing AUSTRIA
participants (2)
-
Andreas Kostyrka -
happyrhinoï¼ usa.net