Dictionary properties within Zope.
I'm embarassed to be asking yet another silly question but after 40 minutes searching the archives and the documentation, can't find it. Hopefully it'll be short and sweet = 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. This would have been something very useful to put in the root folder properties as a form of "site configuration". 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. I'm getting around this right now with external methods but I'm also hoping to move all of my code into the Zope environment. Again, sorry for yet another question. Believe me, I searched. Henry ____________________________________________________________________ Get free email and a permanent address at http://www.netaddress.com/?N=1
On 29 Aug 1999 happyrhino@usa.net wrote:
I'm embarassed to be asking yet another silly question but after 40 minutes searching the archives and the documentation, can't find it. Hopefully it'll be short and sweet =
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.
Actually, this can be done much nicer in ZOPE with the Navigation Product.
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? ...
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 ;)
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
At 20:50 29/08/99 , happyrhino@usa.net wrote:
I'm embarassed to be asking yet another silly question but after 40 minutes searching the archives and the documentation, can't find it. Hopefully it'll be short and sweet =
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.
This would have been something very useful to put in the root folder properties as a form of "site configuration".
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.
I'm getting around this right now with external methods but I'm also hoping to move all of my code into the Zope environment.
Again, sorry for yet another question. Believe me, I searched.
Henry
Indeed, there are no dictionary properties in Zope. But there are a few alternatives: 1) Reconsider your need for a dictionary. If you are duplicating data that is already in your Zope database, why not use that? If you are trying to create a site navigation scheme, try using methods like objectValues and properties on Folders to create you links. It avoids redundancy and broken links because of typos and out-of-sync dictionaries. 2) Use a TinyTable. This is a read-only tablelike object, that has the added advantage it retains order, unlike a dictionary. It is downloadable from the Contributed Area of the Zope web site. I think you might need to patch it slightly to have it working in Zope 2. Search the archives or ask Ty Sarna (his email address is likely to be mentioned somewhere in the TinyTable package). 3) Use a DTML Method. Using the return tag, a DTML Method can return more then just text. It can return any Python object: <dtml-return "{'Title 1' : URL1, 'Title2' : URL2}"> -- Martijn Pieters, Web Developer | Antraciet http://www.antraciet.nl | Tel: +31-35-7502100 Fax: +31-35-7502111 | mailto:mj@antraciet.nl http://www.antraciet.nl/~mj | PGP: http://wwwkeys.nl.pgp.net:11371/pks/lookup?op=get&search=0xA8A32149 ------------------------------------------
participants (3)
-
Andreas Kostyrka -
happyrhinoï¼ usa.net -
Martijn Pieters