# $Id: metadata.sf 1360 2009-05-29 14:07:33Z hvddool $ # $URL: https://svn.non-gnu.uvt.nl/uvt-dev/trunk/sources/meresco/bzv/html/dynamic/metadata.sf $ import rating, availability def fieldRow(name, value): row = '\n%s%s' %(name, value) return row def main(arguments, *args, **kwargs): recordId = arguments.get('recordId',[None])[0] record = call.createRecord(recordId) yield """
""" # # # # #
# # #
# """ # mods = any.getMods(recordId) yield """ \n""" yield availability.main(record=record, recordId=recordId, *args, **kwargs) ### getOrder() is method of Record() from bzv.record ### order is a dictionary; keys: numbers and values: field labels order = call.getOrder() ### sort the numbers order.keys().sort() for key in order.keys(): label = order[key] if label in record: if label == 'URL(s)': for url in record['URL(s)']: label = 'URL' value = '* %(url)s' %{'url':url} else: value = record[label] yield fieldRow(label, value) yield """
Availability
""" ### geen ratings # yield 'Current rating ' # yield rating.showRating(recordId) # yield '  ' # yield rating.showCreateRating(Headers, recordId) # # yield '
' #### the following can be used for testing mods = call.getStream(recordId, "mods") modsRecord = escapeXml(tostring(parse(mods), pretty_print = True)) #mods = any.getMods(recordId) #modsRecord = escapeXml(tostring(mods, pretty_print = True)) yield '

mods

' yield '%s' % modsRecord yield '

header

' try: header = parse(call.getStream(recordId, 'header')) headerRecord = escapeXml(tostring(header, pretty_print = True)) yield '
%s
' % headerRecord except Exception, e: yield '
no header info available
' try: timestamp = parse(call.getStream(recordId, 'timestamp')) timestampRecord = escapeXml(tostring(timestamp, pretty_print = True)) except Exception, e: timestampRecord = format_exc() yield '

timestamp

' yield '
%s
' % timestampRecord meta = parse(call.getStream(recordId, 'meta')) metaRecord = escapeXml(tostring(meta, pretty_print = True)) yield '

meta

' yield '
%s
' % metaRecord extra = parse(call.getStream(recordId, 'extra')) extraRecord = escapeXml(tostring(extra, pretty_print = True)) yield '

extra

' yield '
%s
' % extraRecord metadata = parse(call.getStream(recordId, 'metadata')) metadataRecord = escapeXml(tostring(metadata, pretty_print = True)) yield '

metadata

' # yield '
%s
' % metadataRecord yield '%s' % metadataRecord ns = {'meta': 'http://meresco.com/namespace/harvester/meta'} parts = meta.xpath("/meta:meta/meta:parts", namespaces=ns) if parts: for part in parts[0]: if part.text == "ddi": ddi = parse(call.getStream(recordId, 'ddi')) if ddi: ddiRecord = escapeXml(tostring(ddi, pretty_print = True)) yield '

ddi

' yield '
%s
' % ddiRecord elif part.text == "ddi3": ddi = parse(call.getStream(recordId, 'ddi3')) if ddi: ddiRecord = escapeXml(tostring(ddi, pretty_print = True)) yield '

ddi

' yield '
%s
' % ddiRecord # yield """ #
# #
yield """
"""