Pyhton: how get ObjectValues in Subfolders? (and their URL?) /kv
From the Zope book I have this little script which returns a list of any images from the folder where it is called.
return container.objectValues(['Image']) how can I modify it so it also searches for images inside Subfolders? and how would I ask for their URLs? if I explicitly write: return container.IMG.objectValues(['Image']) it searches in the subfolder "IMG" ... still it scans that folder only ... and I can't find out how to get the full URL of the images. thanks! 'K:?
On Mon, Nov 03, 2003 at 04:52:38PM +0100, Kai Vermehr wrote:
From the Zope book I have this little script which returns a list of any images from the folder where it is called.
return container.objectValues(['Image'])
how can I modify it so it also searches for images inside Subfolders?
try the ZopeFind method: images = container.ZopeFind(container, obj_metatypes=['Image']) However, if you do this a lot, you will find it a lot faster to use the Catalog instead of ZopeFind.
and how would I ask for their URLs?
use the absolute_url method: urls = [img.absolute_url() for img in images] -- Paul Winkler http://www.slinkp.com Look! Up in the sky! It's ALMIGHTY CHICK! (random hero from isometric.spaceninja.com)
I'm still sruggling ... I have a page template that calls some python scripts (images (returns all image objects), image_date (returns formated modification date): <tr tal:repeat="item container/images"> <td tal:content="item/image_date">2001/09/17</td> <td tal:content="item/absolute_url()">123</td> </tr> how call the URL of an image that has been found "item/absolute_url()" obviously is wrong ... also this did not work for scanning the subfolders ...
images = container.ZopeFind(container, obj_metatypes=['Image'])
'K:? -- Kai Vermehr / k@eboy.com http://www.eboy.com On 03.11.2003, at 20:15, Paul Winkler wrote:
On Mon, Nov 03, 2003 at 04:52:38PM +0100, Kai Vermehr wrote:
From the Zope book I have this little script which returns a list of any images from the folder where it is called.
return container.objectValues(['Image'])
how can I modify it so it also searches for images inside Subfolders?
try the ZopeFind method: images = container.ZopeFind(container, obj_metatypes=['Image'])
However, if you do this a lot, you will find it a lot faster to use the Catalog instead of ZopeFind.
and how would I ask for their URLs?
use the absolute_url method:
urls = [img.absolute_url() for img in images]
--
Paul Winkler http://www.slinkp.com Look! Up in the sky! It's ALMIGHTY CHICK! (random hero from isometric.spaceninja.com)
_______________________________________________ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
participants (2)
-
Kai Vermehr -
Paul Winkler