annotate MetaData.py @ 1:e4bae49e657b

more renovation
author casties
date Mon, 25 Jul 2011 20:59:15 +0200
parents 9f9d9be26e53
children ac8e119b25ec
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
1 from OFS.Folder import Folder
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
2 from Products.PageTemplates.PageTemplateFile import PageTemplateFile
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
3 from Globals import package_home
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
4 from AccessControl import ClassSecurityInfo
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
5 import os.path
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
6 import urllib
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
7 import logging
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
8 import urlparse
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
9
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
10 # TODO: which xml toolkit?
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
11 import amara
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
12 import xml.sax.saxutils
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
13 import xml.dom.minidom
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
14 import xml.etree.ElementTree as ET
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
15
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
16
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
17 # TODO: do we need this?
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
18 #from Products.OSA_system2 import OSAS_helpers
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
19 #from Products.OSA_system2.OSAS_metadata import OSAS_Metadata,OSAS_MetadataMapping
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
20
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
21 from OSAS_metadata import OSAS_Metadata, OSAS_MetadataMapping
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
22
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
23
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
24 from SrvTxtUtils import getHttpData, getText
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
25
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
26
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
27 # TODO: get rid of this
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
28 def getTextFromNode(nodelist):
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
29 """gibt text aus nodelist"""
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
30 rc = ""
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
31 for node in nodelist:
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
32 if node.nodeType == node.TEXT_NODE:
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
33 rc = rc + node.data
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
34 return rc
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
35
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
36
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
37 def normalizeBibtype(bt):
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
38 """returns normalised bib type for looking up mappings"""
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
39 bt = bt.strip().replace(' ', '-').lower()
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
40 return bt
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
41
1
e4bae49e657b more renovation
casties
parents: 0
diff changeset
42 def getBibdataFromDom(dom):
e4bae49e657b more renovation
casties
parents: 0
diff changeset
43 """returns dict with all elements from bib-tag"""
e4bae49e657b more renovation
casties
parents: 0
diff changeset
44 bibinfo = {}
e4bae49e657b more renovation
casties
parents: 0
diff changeset
45 bib = dom.find(".//meta/bib")
e4bae49e657b more renovation
casties
parents: 0
diff changeset
46 if bib is not None:
e4bae49e657b more renovation
casties
parents: 0
diff changeset
47 # put type in @type
e4bae49e657b more renovation
casties
parents: 0
diff changeset
48 type = bib.get('type')
e4bae49e657b more renovation
casties
parents: 0
diff changeset
49 bibinfo['@type'] = normalizedBibtype(type)
e4bae49e657b more renovation
casties
parents: 0
diff changeset
50 # put all subelements in dict
e4bae49e657b more renovation
casties
parents: 0
diff changeset
51 for e in bib:
e4bae49e657b more renovation
casties
parents: 0
diff changeset
52 bibinfo[e.tag] = getText(e)
e4bae49e657b more renovation
casties
parents: 0
diff changeset
53
e4bae49e657b more renovation
casties
parents: 0
diff changeset
54 return bibinfo
e4bae49e657b more renovation
casties
parents: 0
diff changeset
55
0
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
56 def toString(list):
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
57 ret=u""
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
58
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
59 for l in list:
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
60 ret+=unicode(l)
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
61
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
62 return ret
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
63
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
64 def dcMetaDataToHash(mdSet):
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
65 """Convenience Function for creates a hash from the DCMetadataset
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
66 @param mdSet: String containing DCMetadata informmation
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
67 currently only in the format getDCMetadata of this module"""
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
68
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
69 NSS = {
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
70 'rdf': 'http://www.w3.org/1999/02/22-rdf-syntax-ns#',
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
71 'dc': 'http://dublincore.org/documents/dcmi-namespace/',
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
72 'owl':"http://www.w3.org/2002/07/owl#",
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
73 'rdfs':"http://www.w3.org/2000/01/rdf-schema#"
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
74 }
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
75 ret={}
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
76 import StringIO
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
77 import sys
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
78 buffer= StringIO.StringIO(mdSet)
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
79 try:
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
80 md = amara.parse(buffer,prefixes=NSS)
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
81 except:
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
82 logging.error("Error: %s (%s)"%(sys.exc_info()[0],sys.exc_info()[1]))
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
83
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
84 ret["error"]=mdSet
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
85 return ret
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
86
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
87 ret["title"] = toString(md.xml_xpath("//dc:title/text()"))
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
88 ret["creator"] =toString(md.xml_xpath("//dc:creator/text()"))
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
89 ret["date"] = toString(md.xml_xpath("//dc:date/text()"))
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
90
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
91 return ret
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
92
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
93
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
94
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
95
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
96
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
97 class MetaData(OSAS_Metadata):
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
98 """provides basic methods for managing metadata structures"""
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
99 meta_type='MetaData'
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
100 security=ClassSecurityInfo()
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
101 manage_options = Folder.manage_options+(
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
102 {'label':'Main Config','action':'changeMetadataForm'},
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
103 {'label':'Import XML Schema','action':'importMetaDataExportXML'},
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
104 {'label':'Select Fields for Display','action':'indicateDisplayFieldsForm'},
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
105 )
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
106
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
107 def __init__(self,id,shortDescription='',description='',fields=''):
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
108 """initialize a new instance"""
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
109 self.id = id
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
110 self.shortDescription =shortDescription #label fuer link auf add page
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
111 self.description=description #description of the method for link page
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
112 self.fieldList=fields.split(",")[0:]
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
113 self.metaDataServerUrl="" # muss mit change metadata gesetzt werden
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
114
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
115
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
116 def correctPath(self,path,remove=None,prefix=None,cut=0):
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
117 """convinience method um einen pfad zu veraendern"""
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
118
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
119 if remove is not None:
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
120 path=path.replace(remove,'')
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
121 if prefix is not None:
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
122 path=os.path.join(prefix,path)
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
123
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
124 if cut>0:
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
125 splitted=path.split("/")
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
126 path="/".join(splitted[0:len(splitted)-cut])
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
127 return path
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
128
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
129 def importMetaDataExportXML(self,importFile=None,RESPONSE=None):
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
130 """imports metadata from the metadataexportxml file"""
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
131
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
132 if importFile is None:
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
133 pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','importMetaDataExportXML.zpt')).__of__(self)
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
134 return pt()
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
135
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
136 dom=xml.dom.minidom.parse(importFile)
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
137 self.createMappingFromDom(dom.getElementsByTagName("metadataExport")[0])
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
138
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
139 if RESPONSE is not None:
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
140 RESPONSE.redirect('manage_main')
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
141
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
142
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
143 def createMappingFromDom(self,metadatanode,metadata=None):
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
144 """erzeuge ein Mapping aus dem der metadatanode des xmlformats, metadata ist ein metadataobject"""
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
145
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
146 if metadata is None:
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
147 metadata=self
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
148
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
149 nodes=metadatanode.childNodes
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
150
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
151 #erster schritt: anlegen der fieldlist
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
152 for node in nodes:
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
153 logging.debug("node: %s"%node.tagName)
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
154 if node.tagName=="set":
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
155 set=node
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
156 if set.getAttribute('name')=='generic':
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
157 list=[]
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
158 for entry in set.getElementsByTagName('entry'):
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
159 list.append(entry.getAttribute('genericName'))
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
160 metadata.fieldList=list[0:]
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
161
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
162 else:
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
163 id=set.getAttribute('name').encode('utf-8')
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
164 list=[]
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
165 argList={}
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
166 for entry in set.getElementsByTagName('entry'):
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
167 genericName=entry.getAttribute('genericName')
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
168 tag=entry.getAttribute('tag')
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
169 label=entry.getAttribute('label')
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
170 description=getTextFromNode(entry.childNodes) #TODO: clean
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
171 argList[genericName]=(tag,label,description)
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
172 metadata._setObject(id,MetaDataMapping(id,id,argList))
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
173
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
174 elif node.tagName=="metadata":
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
175 mn=node
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
176 name=mn.getAttribute('name').encode('utf-8')
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
177 metadata._setObject(name,MetaData(name,name))
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
178 mdObj=getattr(metadata,name)
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
179 mdObj.createMappingFromDom(mn)
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
180
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
181
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
182 def getMDFromPathOrUrl(self,path):
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
183 parsedurl = urlparse.urlparse(path)
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
184 if parsedurl[0] != "":
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
185 # has schema (e.g. http)
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
186 url=path
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
187 else:
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
188 # path only
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
189 if path.endswith("index.meta"):
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
190 url =self.metaDataServerUrl%path
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
191 else:
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
192 url=os.path.join(self.metaDataServerUrl%path,'index.meta')
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
193
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
194 #logging.debug("get Metadata: %s"%url)
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
195 md = getHttpData(url)
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
196 return md
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
197
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
198 def getDCFormatted(self,path):
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
199 """get the metadata as dc set"""
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
200 logging.debug("getDCFormatted(path=%s)"%path)
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
201 namespace={ 'mpiwg': "http://www.mpiwg-berlin.mpg.de/ns/mpiwg"}
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
202 namespaceUsed=False
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
203
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
204 md = self.getMDFromPathOrUrl(path)
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
205 logging.debug("MD in XML"+md)
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
206 im = amara.parse(md, prefixes=namespace)
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
207
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
208 typePaths=im.xml_xpath('//bib/@type')
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
209 archimedes=False
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
210
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
211 if len(typePaths)<1:
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
212 typePaths=im.xml_xpath('//meta/archimedes') # sinderfall fuer veraltete index.meta files vom typ archimedes
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
213 if len(typePaths)>0:
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
214 type = "archimedes"
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
215 archimedes=True
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
216 else:
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
217 typePaths=im.xml_xpath('//mpiwg:bib/@type')
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
218 if len(typePaths)<1:
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
219 return ""
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
220 else:
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
221 namespaceUsed=True
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
222
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
223 type=unicode(typePaths[0])
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
224 else:
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
225 type=unicode(typePaths[0])
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
226 logging.info("got type:"+type)
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
227 try:
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
228 mapping=getattr(self.main.meta.bib,type.lower(),None)
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
229 except:
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
230 logging.error("getMetaDataFromServer no mapping for type: %s"%type)
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
231 return ""
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
232
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
233 try:
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
234 dcMapping=getattr(self.main.meta.bib,"dc",None)
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
235 except:
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
236 logging.error("getMetaDataFromServer no dc in meta/bib")
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
237 return ""
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
238
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
239 mds=mapping.generateMappingHash() # Hole das Mapping generisches Feld --> Feld im entsprechenden Typ
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
240 dcMds=dcMapping.generateMappingHash()
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
241
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
242 mdHash=[]
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
243 logging.debug("Value: %s"%repr(mds))
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
244
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
245 for key,valueTriple in mds.items():
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
246 value=valueTriple[0]
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
247 logging.debug("Value: %s"%repr(value))
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
248 logging.debug("Key: %s"%repr(key))
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
249 if value!="":
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
250 if not archimedes:
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
251 if namespaceUsed:
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
252 try:
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
253 v = im.xml_xpath('//mpiwg:bib/mpiwg:%s/text()'%value)
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
254 except:
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
255 logging.error('cannot do: //mpiwg:bib/mpiwg:%s/text()'%value)
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
256 else:
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
257 v = im.xml_xpath('//bib/%s/text()'%value)
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
258 else:
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
259 v = im.xml_xpath('//archimedes/%s/text()'%value)
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
260 if len(v) > 0:
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
261 dc=dcMds[key][0]
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
262
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
263 if (dc !="") and (value !=""):
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
264 logging.debug("%s--> : %s"%(repr(value),dc))
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
265 mdHash.append([dc,unicode(v[0])])
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
266
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
267 ret="""<bib xmlns:dc="http://dublincore.org/documents/dcmi-namespace/"> """
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
268 ret+="<dc:type>%s</dc:type>"%type
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
269 for md in mdHash:
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
270
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
271 ret+="""<dc:%s>%s</dc:%s>"""%(md[0],xml.sax.saxutils.escape(md[1]),md[0])
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
272 ret+="</bib>"
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
273 return ret
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
274
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
275
1
e4bae49e657b more renovation
casties
parents: 0
diff changeset
276 def getBibFields(self, bibdata):
e4bae49e657b more renovation
casties
parents: 0
diff changeset
277 """returns dict with metadata description for bibdata"""
0
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
278 bibtype = bibdata['@type']
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
279 # get mapping from main/meta/bib
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
280 try:
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
281 mapping=getattr(self.main.meta.bib, bibtype.lower())
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
282 except:
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
283 logging.error("getStdMappedHash: no mapping for type: %s"%bibtype)
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
284 return mdHash
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
285
1
e4bae49e657b more renovation
casties
parents: 0
diff changeset
286 # get field descriptions
e4bae49e657b more renovation
casties
parents: 0
diff changeset
287 bibFields = mapping.getFields.copy()
e4bae49e657b more renovation
casties
parents: 0
diff changeset
288 # add field list
e4bae49e657b more renovation
casties
parents: 0
diff changeset
289 bibFields['@fieldList'] = mapping.getFieldList()
0
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
290
1
e4bae49e657b more renovation
casties
parents: 0
diff changeset
291 return bibFields
0
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
292
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
293
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
294 def getFormatted(self, template, path=None, dom=None, bibdata=None):
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
295 """returns string with document data formatted according to template.
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
296 gets data from server or dom or pre-parsed bibdata."""
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
297 logging.debug("getFormatted(template=%s)"%(template))
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
298
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
299 if dom is None and bibdata is None:
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
300 # get from server
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
301 md = self.getMDFromPathOrUrl(path.replace("/mpiwg/online",""))
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
302 #logging.debug("md:"+md)
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
303 #dom = amara.parse(md)
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
304 dom = ET.fromstring(md)
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
305
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
306 # get contents of bib tag
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
307 if bibdata is None:
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
308 bibdata = getBibdataFromDom(dom)
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
309
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
310 bibtype = bibdata['@type']
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
311
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
312 # get template
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
313 tp=getattr(self,"%s_%s"%(template, bibtype.lower()), None)
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
314 if tp is None:
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
315 logging.warning("getFormatted: no template for: %s_%s"%(template, bibtype))
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
316 # try generic
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
317 tp=getattr(self,"%s_generic"%(template), None)
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
318 if tp is None:
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
319 logging.error("getFormatted: no generic template either: %s"%(template))
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
320 return ""
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
321
1
e4bae49e657b more renovation
casties
parents: 0
diff changeset
322 # put bib field descriptions in mdHash
e4bae49e657b more renovation
casties
parents: 0
diff changeset
323 bibFields = self.getBibFields(bibdata)
0
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
324
1
e4bae49e657b more renovation
casties
parents: 0
diff changeset
325 return tp(bibFields=bibFields, md=bibdata)
0
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
326
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
327
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
328 def getFormattedMetaData(self, path=None, dom=None, bibdata=None):
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
329 """get the metadafrom server"""
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
330 logging.debug("getFormattedMetaData(path=%s)"%path)
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
331 return self.getFormatted('metadata_template', path=path, dom=dom, bibdata=bibdata)
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
332
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
333 def getFormattedMetaDataShort(self, path=None, dom=None, bibdata=None):
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
334 """get the metadafrom server"""
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
335 logging.debug("getFormattedMetaDataShort(path=%s)"%path)
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
336 return self.getFormatted('metadata_template', path=path, dom=dom, bibdata=bibdata)
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
337
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
338 def getFormattedMetaDataExtended(self,path=None, dom=None, bibdata=None):
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
339 """get the metadafrom server"""
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
340 logging.debug("getFormattedMetaDataExtended(path=%s)"%path)
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
341 return self.getFormatted('metadata_extended_template', path=path, dom=dom, bibdata=bibdata)
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
342
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
343 def getFormattedLabel(self,path=None, dom=None, bibdata=None):
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
344 """get the metadafrom server"""
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
345 logging.debug("getFormattedLabel(%s)"%path)
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
346 return self.getFormatted('label_template', path=path, dom=dom, bibdata=bibdata)
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
347
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
348 def getFormattedMetaDataShortFromServer(self,path):
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
349 """get the metadafrom server"""
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
350 logging.debug("getFormattedMetaDataShortFromServer(path=%s)"%path)
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
351 return self.getFormatted('metadata_template', path)
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
352
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
353 def getFormattedMetaDataExtendedFromServer(self,path):
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
354 """get the metadafrom server"""
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
355 logging.debug("getFormattedMetaDataExtendedFromServer(path=%s)"%path)
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
356 return self.getFormatted('metadata_extended_template', path)
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
357
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
358 def getFormattedLabelFromServer(self,path):
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
359 """get the metadafrom server"""
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
360 logging.debug("getFormattedLabelFromServer(%s)"%path)
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
361 return self.getFormatted('label_template', path)
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
362
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
363
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
364 security.declarePublic('changeMetadataForm')
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
365 def changeMetadataForm(self):
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
366 """Main configuration"""
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
367 pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','changeMetadata.zpt')).__of__(self)
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
368 return pt()
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
369
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
370 security.declarePublic('changeMetadata')
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
371 def changeMetadata(self,shortDescription,description,fields,metaDataServerUrl,RESPONSE=None):
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
372 """Change Metadata"""
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
373 self.shortDescription=shortDescription
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
374 self.description=description
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
375 self.fieldList=fields.split(",")[0:]
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
376 self.metaDataServerUrl=metaDataServerUrl
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
377 if RESPONSE is not None:
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
378 RESPONSE.redirect('manage_main')
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
379
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
380
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
381 def manage_addMetaDataForm(self):
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
382 """interface for adding the OSAS_add_Metadata"""
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
383 pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','addMetadataForm.zpt')).__of__(self)
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
384 return pt()
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
385
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
386 def manage_addMetaData(self,id,shortDescription,description,fields,RESPONSE=None):
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
387 """a metadata objekt"""
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
388 newObj=MetaData(id,shortDescription,description,fields)
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
389 self.Destination()._setObject(id,newObj)
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
390 if RESPONSE is not None:
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
391 RESPONSE.redirect('manage_main')
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
392