getMetadataValue optionally acquires?
Andy Altepeter <[email protected]>
| Newsgroups | gmane.comp.web.zope.silva.devel |
|---|---|
| Organization | Bethel University |
| Message-ID | <[email protected]> |
Hey All,
I'm working on a silva extension (photo gallery) which uses the silva-extra
description for gallery containers and images. Both image's and gallery
container's descriptions are rendered on the page. The descriptions are
retrieved using MetadataTool.getMetadataValue. There's one problem though.
If a description is set on the container, then all images within that
container that do not have a description set acquire the containers
description.
This results in having the gallery description display at the top of the
gallery and as the description for every image within that gallery.
There is an easy patch to apply to getMetadataValue (from SilvaMetadata 0.10)
that adds an 'acquire' parameter. If that param is set to zero, do not
acquire the value:
--- MetadataTool.py 2006-06-06 10:52:45.246502452 -0500
+++ /export1/zope/MetadataTool.py 2006-06-06 10:46:52.092467000 -0500
@@ -145,7 +145,7 @@
)
return invokeAccessHandler(self, content)
- def getMetadataValue(self, content, set_id, element_id):
+ def getMetadataValue(self, content, set_id, element_id, acquire=1):
"""Get a metadata value right away. This can avoid
building up the binding over and over while indexing.
@@ -177,7 +177,7 @@
if saved_data is not None and saved_data.has_key(element_id):
return saved_data[element_id]
# if not, check whether we acquire it, if so, we're done
- if element.isAcquireable():
+ if acquire and element.isAcquireable():
aqelname = encodeElement(set_id, element_id)
try:
#print 'acquiring?', repr(aqelname)
Any chance this could be added to the SilvaMetadata trunk and released
sometime?
Thanks,
Andy