RE: [Zope] object icons
From: Loren Stafford [mailto:lstaffor@dynalogic.com]
As usual, I blabbered on before I knew what I was talking about.
I played some more with this (because I have the same problem in my product) and found that the "Product Icons" section at http://www.zope.org/Members/Zen/howto/ProductAPITutorial does indeed work as documented:
Here's our poll's misc_ definition:
misc_={ 'poll': ImageFile('poll.gif',globals()), }
It only defines one thing--the poll's icon. For your Product's icons you should use 'ImageFile's.
Objects defined in a Product's misc_ mapping are made available through the web at /misc_//.
To allow Zope to find this icon you need to specify its URL in your Product's class. So here's how we indicate our poll's icon:
class Poll: ... icon='misc_/Poll/poll' ...
You just have to realize that icon="misc_/<ProductID>/<misc_key>".
The Misc object is a special object for storing things like the actual data for product icons. Using context.registerClass automates the process of storing an icon in the misc_ structure (containing Misc objects), and having your class.icon URL attribute pointing at the URL for that icon. Doing so makes it easier for your product to have an icon, and you don't have to worry about setting the icon attribute correctly. Just leave out the icon attribute of you class, and pass in the (relative) path to your icon. See, for example, lib/python/Products/ZCatalog/__init__.py. You will only want to mess with the icon attribute when you want to dynamically change the icon of your class. You'd have to store the icons manually in the misc_ structure, like Loren described, and manually set your icon attribute to URLs to those icons. -- Martijn Pieters, Software Engineer | Digital Creations http://www.digicool.com | Creators of Zope http://www.zope.org | mailto:mj@digicool.com ICQ: 4532236 | PGP: http://wwwkeys.nl.pgp.net:11371/pks/lookup?op=get&search=0xA8A32149 -------------------------------------------
participants (1)
-
Martijn Pieters