[Silva-general] How to edit a metadata element of a Silva Document programmatically?

Nico Grubert nicogrubert at gmail.com
Fri Mar 10 13:57:49 CET 2006


> I don't think it's as easy... I can find functionality to set the values
> of a whole set at once, but not for a single field (perhaps I'm just not
> looking at the right places, though, so it probably makes some sense to
> scan SilvaMetadata yourself a bit, too):
> 
> binding = self.service_metadata.getMetadata(object)
> binding.setValues('my-metadata-set', {'name1': value1,
> 					'name2': value2})

Hi Guido,

thank you very much for your reply.

I tried:

# Metadataset: 'WSLContact'
# Element to be changed: 'ldap_reference'

public_version_obj = mysilvadoc.get_viewable()

print self.service_metadata.getMetadataValue(public_version_obj, 
'WSLContact', 'ldap_reference')
# -> 'grubert'

binding = self.service_metadata.getMetadata(public_version_obj)
# reset ldap_reference
binding.setValues('WSLContact', {'ldap_reference': ''})
public_version_obj.reindex_object()

print self.service_metadata.getMetadataValue(public_version_obj, 
'WSLContact', 'ldap_reference')
# -> 'grubert'
# Hm, still 'grubert' but I excpected '' !?


After I set the element 'ldap_reference' to emtpy string ('') I expected 
to get '' in the last line above, but I still get 'grubert'.

Any idea, what's going wrong there?


Nico



More information about the Silva-general mailing list