[Zope3-Users] How to get the icon for a content item.

Tom Dossis td at yoma.com.au
Wed Dec 1 09:00:45 EST 2004



Stephan Richter wrote:
> On Tuesday 30 November 2004 23:23, Tom Dossis wrote:
> 
>>>How can I get the icon for a content object, e.g. Folder?
>>>My ui is a gui, not a browser, but I'd like to use the zmi_icon (for
>>>now).
>>
>>The following works, but is hackish..
>>
>> >>> root
>><zope.app.folder.folder.Folder object at 0x4120c36c>
>>
>> >>> from zope.app import zapi
>> >>> from zope.publisher.browser import TestRequest
>>
>> >>> icon = zapi.queryView(root, 'zmi_icon', TestRequest())
>> >>> icon
>><zope.app.publisher.browser.icon.IconView object at 0x4117ea2c>
>>
>> >>> icon()
>>u'<img
>>src="http://127.0.0.1/@@/zope-app-folder-interfaces-IFolder-zmi_icon.gif"
>>alt="Folder" width="16" height="16" border="0" />'
> 
> 
> What is hackish about that? It is exactely what I would have done. The icon is 
> just a view named zmi_icon.

I meant hackish, by having to create a TestRequest.  Maybe I'm being 
pedantic.
-Tom




More information about the Zope3-users mailing list