Silva Metadata: support for delegates?

Clemens Klein-Robbenhaar <crobbenhaar-S0/[email protected]>
Newsgroups gmane.comp.web.zope.silva.devel
Message-ID <[email protected]>
Hi,

  as I try to update my SilvaLocalContent product I would like to have different sets
of metadata for the same content object and different languages.
  This is relatively easy to implement with the use of "delegates", e.g. by setting
the "binding.setObjectDelegate" method (unlike stated in the API.txt it does not
expect any additional parameters).

  However the "getMetadataValue" in the MetadataTool which is implemented
for performance reasons does not respect these delegators but directly asks the
content object. I guess this happens because Silva does not use delegators so far.

  Now I would like to have them in "getMetadataValue". Attached is a patch which would
make "getMetadataValue" respect delegators.

  Any objections if I would put this one in the CVS? At least the Silva unit tests pass with
the patch -- the SilvaMetadata tests seem to be a little out of date and I could not get
them to run at all, patch or no. (If there is any interest I could try to modernize them a little.)

  Or are there any other ideas how one can bind different metadata sets to the same object ?

Cheers
Clemens

_______________________________________________
silva-dev mailing list
silva-dev-IAPFreCvJWM6s/[email protected]
http://lists.infrae.com/mailman/listinfo/silva-dev
MetadataTool.patch (text/plain, 2.5 KB)
Index: MetadataTool.py
===================================================================
RCS file: /cvs/infrae/SilvaMetadata/MetadataTool.py,v
retrieving revision 1.19
diff -u -C7 -r1.19 MetadataTool.py
*** MetadataTool.py	12 May 2004 13:48:20 -0000	1.19
--- MetadataTool.py	11 Mar 2005 21:38:43 -0000
***************
*** 2,16 ****
  Author: kapil thangavelu <[email protected]>
  """
  
  
  from Access import invokeAccessHandler
  import Configuration
  from ZopeImports import *
! from Binding import MetadataNamespace, encodeElement
  from Exceptions import BindingError
  from Compatibility import IActionProvider, IPortalMetadata, ActionProviderBase
  from Compatibility import getContentType, getContentTypeNames
  from Acquisition import aq_base
  from Products.Annotations.AnnotationTool import Annotations
  
  class MetadataTool(UniqueObject, Folder, ActionProviderBase):
--- 2,17 ----
  Author: kapil thangavelu <[email protected]>
  """
  
  
  from Access import invokeAccessHandler
  import Configuration
  from ZopeImports import *
! from Namespace import MetadataNamespace, BindingRunTime
! from Binding import ObjectDelegate, encodeElement
  from Exceptions import BindingError
  from Compatibility import IActionProvider, IPortalMetadata, ActionProviderBase
  from Compatibility import getContentType, getContentTypeNames
  from Acquisition import aq_base
  from Products.Annotations.AnnotationTool import Annotations
  
  class MetadataTool(UniqueObject, Folder, ActionProviderBase):
***************
*** 143,156 ****
--- 144,165 ----
          It's only going to work for Silva, not CMF.
          """
          # XXX how does this interact with security issues?
          set = self.collection.getMetadataSet(set_id)
          element = set.getElement(element_id)
          
          annotations = getattr(aq_base(content), '_portal_annotations_', None)
+ 
+         bind_data = annotations[MetadataNamespace].get(BindingRunTime)
+         if bind_data:
+             delegate = bind_data.get(ObjectDelegate)
+             if delegate:
+                 content = getattr(content,delegate)()
+                 annotations = getattr(aq_base(content), '_portal_annotations_')
+ 
          try:
              saved_data = annotations[MetadataNamespace].get(set.metadata_uri)
          except (TypeError, KeyError):
              saved_data = None
          # if it's saved, we're done
          if saved_data is not None and saved_data.has_key(element_id):
              return saved_data[element_id]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.