annotate OSAS_metadata.py @ 12:7f0e2b656e5c

more work for non-bib metadata
author casties
date Fri, 29 Jul 2011 18:28:06 +0200
parents 9f9d9be26e53
children 9a1e75e708e1
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 """ Classes for managing metadata"""
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
2
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
3 from OFS.SimpleItem import SimpleItem
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
4 from Globals import InitializeClass,package_home
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
5 from OFS.Folder import Folder
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
6 from AccessControl import ClassSecurityInfo
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
7 from Products.PageTemplates.PageTemplateFile import PageTemplateFile
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
8 import os.path
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
9 import sys
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
10 import xml.dom.minidom
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
11 import xml.dom.pulldom
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
12 #TODO: get rid of this
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
13 from Products.OSA_system2 import OSAS_helpers
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
14 import logging
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 #ersetzt logging
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
17 def logger(txt,method,txt2):
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
18 """logging"""
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
19 logging.info(txt+ txt2)
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
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
22 import string
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
23 try:
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
24 from xml.xpath import Evaluate
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
25 except:
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
26 from Ft.Xml.XPath import Evaluate
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
27 import xmlrpclib
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
28
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
29 from types import *
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
30
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
31 class OSAS_MetadataMapping(SimpleItem):
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
32 """Einfaches Mapping Object"""
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
33
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
34 meta_type="OSAS_MetadataMapping__neu"
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 def readFieldsFromParent(self):
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
37 """read all elements from root"""
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
38
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
39 return self.aq_parent.fieldList
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
40
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
41 def __init__(self,id,title,arglist):
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
42 """init
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
43 @param id: id
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
44 @param title: title fuer zope navigation
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
45 @param arglist: dictionary mit Namen der zugelassenen generische Metadaten als key und Tripel als Werte (human readable, tag version,explanation
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
46 """
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
47 self.id=id
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
48 self.title=title
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
49 for fieldName in arglist.keys():
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
50 setattr(self,"md_"+fieldName,arglist[fieldName])
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
51
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
52
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
53 manage_options = SimpleItem.manage_options+(
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
54 {'label':'Main Config','action':'changeMetadataMappingForm'},
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
55 )
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
56
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
57
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
58 def showSetXML(self,RESPONSE=None):
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
59 """prints out the mapping as XML"""
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
60 ret="""<set name="%s">"""%self.title
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
61 for fieldName in self.readFieldsFromParent():
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
62 entry=getattr(self,"md_"+fieldName)
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
63 if entry[2]=="": # no explanation of this field
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
64 ret+="""<entry genericName="%s" tag="%s" label="%s"/>"""%(fieldName,entry[0],entry[1])
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
65 else:
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
66 ret+="""<entry genericName="%s" tag="%s" label="%s">%s</entry>"""%(fieldName,entry[0],entry[1],entry[2])
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
67 ret+="</set>"
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 if not RESPONSE:
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
70 return ret
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
71 else:
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
72 self.REQUEST.RESPONSE.setHeader('Content-Type','text/xml')
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
73 return ret
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 def getValue(self,fieldName):
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
76 """get md value
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
77 @param fieldName: Bezeichnung des gesuchten Metadatums
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
78 @retunr: Value des Metadatums"""
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
79
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
80 ret= getattr(self,"md_"+fieldName,(None,None,None,None,None))
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
81 if len(ret)!= 4: # alte MD haben keine info ueber optional/required und listen werte
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
82 ret=ret+("","")
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
83 return ret
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
84
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
85
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
86 def isEmptyValue(self,fieldName):
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
87 """teste ob fielname in diesem Metadatenschema definiert ist"""
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
88 field=getattr(self,"md_"+fieldName,'')
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
89 if field[1]=='':
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
90 return 0
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
91 else:
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
92 return 1
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 def generateMappingHash(self):
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
95 """erzeugen des dictionaries: generisches Feld -> Definition in diesem Schema"""
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
96 hash={}
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
97 for field in self.fieldList:
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
98 hash[field]=getattr(self,"md_"+field,'')
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
99 return hash
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
100
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
101
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
102
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
103 def changeMetadataMappingForm(self):
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
104 """change"""
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
105 pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','changeMetadataMapping.zpt')).__of__(self)
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
106 return pt()
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
107
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
108 def changeMetadataMapping(self,titleOfObject,RESPONSE=None):
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
109 """change"""
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
110
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
111 self.title=titleOfObject
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
112 arglist=self.REQUEST.form
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
113
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
114 for fieldName in self.readFieldsFromParent():
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
115 setattr(self,"md_"+fieldName,(arglist[fieldName],arglist['label_'+fieldName],arglist['explanation_'+fieldName],arglist['status_'+fieldName],arglist['values_'+fieldName]))
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
116
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
117
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
118 if RESPONSE is not None:
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
119 RESPONSE.redirect('manage_main')
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
120
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
121 manage_workspace=changeMetadataMappingForm
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
122
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
123 def manage_addMetadataMappingForm(self):
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
124 """interface for adding the OSAS_root"""
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
125 pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','addMetadataMappingForm.zpt')).__of__(self)
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
126
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
127 return pt()
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 manage_addMetadataMapping(self,idOfObject,titleOfObject,RESPONSE=None):
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
130 """add the OSAS_root"""
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 argList={}
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
133 for arg in self.fieldList:
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
134 if not (arg in ['idOfObject','titleOfObject']):
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
135 argList[arg]=(self.REQUEST.form[arg],self.REQUEST.form['label_'+arg],self.REQUEST.form['explanation_'+arg],self.REQUEST.form['status_'+arg],self.REQUEST.form['values_'+arg])
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
136
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
137 newObj=OSAS_MetadataMapping(idOfObject,titleOfObject,argList)
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
138 self._setObject(idOfObject,newObj)
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
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
144 class OSAS_Metadata(Folder):
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
145 """Foldertype enthaelt methoden zur Halbautomatischen Erstellung von Metadatenfiles"""
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
146 security=ClassSecurityInfo()
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
147
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
148 def __init__(self,id,shortDescription,description,fields):
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
149 """initialize a new instance"""
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
150 self.id = id
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
151 self.shortDescription =shortDescription #label fuer link auf add page
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
152 self.description=description #description of the method for link page
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
153 self.fieldList=fields.split(",")[0:]
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
154
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
155 meta_type='OSAS_Metadata__neu'
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
156
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
157 manage_options = Folder.manage_options+(
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
158 {'label':'Main Config','action':'changeMetadataForm'},
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
159 {'label':'Import XML Schema','action':'importXMLSchemaForm'},
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
160 {'label':'Select Fields for Display','action':'indicateDisplayFieldsForm'},
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
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
163 def showGenericXML(self,RESPONSE=None):
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
164 """show generic fields as XML"""
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
165 ret="""<set name="%s">"""%"generic"
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
166 for field in self.fieldList:
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
167 ret+="""<entry genericName="%s"/>"""%field
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
168
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
169 ret+="</set>"
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
170
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
171 if not RESPONSE:
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
172 return ret
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
173 else:
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
174 self.REQUEST.RESPONSE.setHeader('Content-Type','text/xml')
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
175 return ret
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
176
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
177
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
178 def showOverviewXML(self,RESPONSE=None,wrapped=False):
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
179 """gives an overview over the Metadata stored in this folder"""
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
180 ret=""
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
181 if wrapped:
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
182 ret+="""<metadataExport>"""
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
183 ret+="""<metadata name="%s">"""%self.getId()
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
184 ret+=self.showGenericXML()
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
185 for entry in self.ZopeFind(self,obj_metatypes=['OSAS_MetadataMapping__neu']):
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
186 ret+=entry[1].showSetXML()
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
187
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
188 for entry in self.ZopeFind(self,obj_metatypes=['OSAS_Metadata__neu']):
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
189 ret+=entry[1].showOverviewXML()
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
190
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
191 ret+="</metadata>"
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
192
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
193 if wrapped:
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
194 ret+="""</metadataExport>"""
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
195 if not RESPONSE:
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
196 return ret
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
197 else:
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
198 RESPONSE.setHeader('Content-Type','text/xml')
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
199 return ret
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
200
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
201 def generateMappingList(self):
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
202 """Erzeuge Mapping"""
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
203 mapping={}
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
204
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
205 for dict in self.__dict__:
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
206 #print dict
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
207 obj=getattr(self,dict)
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
208 if hasattr(obj,'meta_type'):
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
209 logging.debug("generateMappungList read type:"+repr(obj.meta_type))
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
210 if ((obj.meta_type=="OSAS_MetadataMapping__neu") or (obj.meta_type=="MetadataMapping")): #metadatamapping is the newer type
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
211 logging.debug("generateMappungListadded:"+repr(obj.getId()))
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
212 mapping[obj.getId()]=obj.generateMappingHash()
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
213
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
214 return mapping
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
215
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
216 def generateMappingForType(self,type,clean="yes"):
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
217 """erzeuge spezifisches Mapping"""
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
218
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
219 hash=self.generateMappingList()
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
220 logging.debug("generateMappingForType:"+type)
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
221 for key in hash.keys():
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
222 logging.debug("generateMappingForType comparing:"+key.lower()+type.lower())
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
223 if (key.lower() == type.lower()):
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
224 if clean=="yes":
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
225 temp={}
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
226 for x in hash[key].keys():
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
227 if not hash[key][x]=="":
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
228 temp[x]=hash[key][x]
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
229 return temp
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
230 else:
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
231
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
232 return hash[key]
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
233
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
234 return {}
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
235
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
236 def getFieldList(self):
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
237 """erzeuge string aus fields"""
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
238 try:
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
239 return string.join(self.fieldList,",")
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
240 except:
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
241 return ""
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
242
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
243 security.declarePublic('getFields')
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
244 def getFields(self):
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
245 """ausgabe der Felder"""
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
246 return self.fieldList
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
247
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
248 def getTypeTitle(self,id):
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
249 """Title von ID"""
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
250 try:
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
251 obj=getattr(self,id)
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
252 return obj.title
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
253 except:
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
254 return id
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
255
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
256 def getType(self,type):
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
257 """gib metadataobject type zurueck"""
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
258
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
259 for obj in self.ZopeFind(self,obj_metatypes=['OSAS_MetadataMapping__neu']):
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
260 if obj[0]==type:
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
261 return obj
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
262 return (self.id,self)
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
263
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
264
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
265
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
266 def getStoredTypes(self):
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
267 """Gebe gespeicherte typen zurueck"""
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
268
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
269 types=[]
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 for obj in self.ZopeFind(self,obj_metatypes=['OSAS_MetadataMapping__neu']):
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
272 if obj[1].title=="":
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
273 title=obj[1].id
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
274 else:
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
275 title=obj[1].title
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
276 types.append((obj[1].id, title, obj[1]))
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
277
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
278 return types
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
279
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
280 def indicateDisplayFieldsForm(self):
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
281 """form zur Makierung der Felder die in der Browserumgebung angezeigt werden"""
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
282 pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','indicateDisplayFieldsForm.zpt')).__of__(self)
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
283 return pt()
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
284
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
285 def indicateDisplayFields(self,displayFields,RESPONSE=None):
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
286 """set Displayfields
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
287 @param displayFields: Liste von Felder die im Browserenvironment angezeigt werden
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
288 """
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
289 self.displayFields=OSAS_helpers.toList(displayFields)
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
290 if RESPONSE is not None:
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
291 RESPONSE.redirect('manage_main')
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 def getDisplayFieldsAsStr(self,indexMeta):
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
294 ret=[]
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
295 try:
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
296 if indexMeta and not (indexMeta==""):
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
297 dom=xml.dom.pulldom.parseString(indexMeta)
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 for (event,node) in dom:
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
300
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
301 if event == xml.dom.pulldom.START_ELEMENT and node.tagName=="bib":
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
302 dom.expandNode(node)
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
303
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
304 try:
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
305 type=node.getAttribute('type')
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
306 mapping=getattr(self,type).generateMappingHash()
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
307 except:
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
308 type='generic'
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
309 mapping=getattr(self,type).generateMappingHash()
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
310
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
311 for field in self.displayFields:
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
312 try:
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
313 ret.append(OSAS_helpers.getText(node.getElementsByTagName(mapping[field][0])[0].childNodes))
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
314 except:
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
315 """nothing"""
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
316
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
317 return "; ".join(ret)
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
318 else:
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
319 return ""
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
320 except:
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
321 return ""
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
322 def getDisplayFieldsAsStrOLD(self,indexMeta):
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
323 """Gebe display fields als string zurueck
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
324 @param path: Pfad zum Object
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
325 """
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
326 ret=[]
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
327 try:
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
328 dom=xml.dom.minidom.parseString(indexMeta)
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
329 except:
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
330 logger("OSAS_metadata (getDisplayFieldsAsStr)",logging.INFO,"Cannot parse: %s"%indexMeta)
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
331 try:
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
332 bib = dom.getElementsByTagName("meta")[0].getElementsByTagName("bib")[0]
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
333 except:
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
334 return ""
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
335 try:
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
336 type=bib.getAttribute('type')
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
337 mapping=getattr(self,type).generateMappingHash()
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
338 except:
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
339 type='generic'
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
340 mapping=getattr(self,type).generateMappingHash()
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
341
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
342 for field in self.displayFields:
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
343 try:
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
344 ret.append(OSAS_helpers.getText(bib.getElementsByTagName(mapping[field][0])[0].childNodes))
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
345 except:
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
346 """nothing"""
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 return "; ".join(ret)
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
349
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
350 security.declarePublic('changeMetadataForm')
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
351 def changeMetadataForm(self):
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
352 """Main configuration"""
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
353 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
354 return pt()
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
355
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
356 security.declarePublic('changeMetadata')
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
357 def changeMetadata(self,shortDescription,description,fields,RESPONSE=None):
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
358 """Change Metadata"""
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
359 self.shortDescription=shortDescription
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
360 self.description=description
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
361 self.fieldList=fields.split(",")[0:]
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
362 if RESPONSE is not None:
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
363 RESPONSE.redirect('manage_main')
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
364
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
365 security.declarePublic('index_html')
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
366
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
367 def importXMLSchemaForm(self):
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
368 """form"""
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
369 pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','importXMLSchemaForm.zpt')).__of__(self)
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
370 return pt()
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
371
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
372
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
373 def importXMLSchema(self,file,RESPONSE=None):
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
374 """import xmlschema, Metadatenschema wird eingelesen und entsprechende Metadatenmappings angelegt."""
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
375
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
376 dom=xml.dom.minidom.parse(file)
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
377 sets=dom.getElementsByTagName('set')
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
378 #erster schritt: anlegen der fieldlist
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
379 for set in sets:
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
380 if set.getAttribute('name')=='generic':
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
381 list=[]
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
382 for entry in set.getElementsByTagName('entry'):
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
383 list.append(entry.getAttribute('genericName'))
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
384 self.fieldList=list[0:]
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 #zweiter schritt: anlegen der mapping
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
387 for set in sets:
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
388 id=set.getAttribute('name').encode('utf-8')
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
389 list=[]
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
390 argList={}
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
391 for entry in set.getElementsByTagName('entry'):
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
392 genericName=entry.getAttribute('genericName')
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
393 tag=entry.getAttribute('tag')
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
394 label=entry.getAttribute('label')
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
395 description=OSAS_helpers.getText(entry.childNodes)
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
396 argList[genericName]=(tag,label,description)
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
397 self._setObject(id,OSAS_MetadataMapping(id,id,argList))
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
398 if RESPONSE:
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
399 RESPONSE.write("Wrote: %s"%id)
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
400
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
401
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
402 def createMetadataFragment(self,type,path,prefix="",presets={}):
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
403 """fragment"""
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
404 self.REQUEST.SESSION['MDF_type']=type
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
405 self.REQUEST.SESSION['MDF_path']=path
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
406 self.REQUEST.SESSION['MDF_prefix']=prefix
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
407 self.REQUEST.SESSION['MDF_presets']=presets
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
408
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
409 pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','addMetadataForm_fragment.zpt')).__of__(self)
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
410 return pt()
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
411
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
412 def createMetadataForm(self,type="",path=""):
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
413 """createMetadataForm"""
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
414 self.REQUEST.SESSION['MDF_type']=type
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
415 self.REQUEST.SESSION['MDF_path']=path
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
416
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
417
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
418 pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','addMetadataForm_template.zpt')).__of__(self)
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
419 return pt()
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
420
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
421 def readMetadata(self,MDF_path,MDF_type,MDF_prefix="",MDF_xpathStart="", MDF_addPath=None,MDF_identifyFields=None,newdoc=None,actualNode=None):
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
422
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
423 if type(MDF_path)==ListType:
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
424 MDF_path=MDF_path[0]
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
425
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
426 indexFile=os.path.join(MDF_path,'index.meta')
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
427
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
428 server=xmlrpclib.Server(self.serverUrl)
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
429
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
430 documentStr=server.getFile(indexFile)
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
431
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
432 if documentStr:
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
433 newdoc=xml.dom.minidom.parseString(documentStr)
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
434 dom=newdoc.documentElement
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
435 actualNode=dom
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
436 else:
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
437 return {}
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
438
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
439 if self.containerTag=="":
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
440 containerTag="doc"
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
441 else:
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
442 containerTag=self.containerTag
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
443
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
444 if MDF_xpathStart=="":
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
445 dom=newdoc.documentElement
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
446 actualNode=dom
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
447 else:
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
448 #try to find xpath
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
449 if MDF_identifyFields:
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
450 query=[]
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
451 for field in MDF_identifyFields.keys():
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
452
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
453 query.append("""(%s="%s")"""%(field,MDF_identifyFields[field]))
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
454 querystr=" and ".join(query)
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
455 xpathStr=MDF_xpathStart+"[%s]"%querystr
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
456
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
457 else:
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
458 xpathStr=MDF_xpathStart
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
459
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
460
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
461 xpathNodes=Evaluate(xpathStr,actualNode)
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
462
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
463
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
464 if len(xpathNodes)>0:
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
465 actualNode=xpathNodes[0]
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
466 else:
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
467 return {}
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
468
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
469 ret={}
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
470 for node in actualNode.childNodes:
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
471 name=node.tagName
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
472 text=OSAS_helpers.getText(node.childNodes)
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
473 ret[name]=text
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
474
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
475 return ret
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
476
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
477 def writeMetadata(self,MDF_path,MDF_type,form,MDF_prefix="",MDF_xpathStart="", MDF_addPath=None,MDF_identifyFields=None,newdoc=None,actualNode=None):
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
478 """writeMetadata"""
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
479 #MDF_path="/tmp/index.meta"
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
480 if type(MDF_path)==ListType:
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
481 MDF_path=MDF_path[0]
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
482
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
483
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
484 indexFile=os.path.join(MDF_path,'index.meta')
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
485
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
486 server=xmlrpclib.Server(self.serverUrl)
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
487 if newdoc:
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
488 if not actualNode: actualNode=newdoc
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
489 dom=newdoc
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
490 else:
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
491 documentStr=server.getFile(indexFile)
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
492
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
493 if documentStr:
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
494
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
495 newdoc=xml.dom.minidom.parseString(documentStr)
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
496 dom=newdoc.documentElement
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
497 actualNode=dom
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
498
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
499
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
500 else:
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
501
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
502 impl=xml.dom.minidom.getDOMImplementation()
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
503 newdoc=None
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
504
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
505
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
506 if self.containerTag=="":
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
507 containerTag="doc"
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
508 else:
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
509 containerTag=self.containerTag
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
510
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
511 create=None
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
512 if MDF_xpathStart=="":
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
513 if not newdoc:
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
514 newdoc=impl.createDocument(None,containerTag,None)
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
515 dom=newdoc.documentElement
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
516 actualNode=dom
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
517 else:
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
518
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
519 #try to find xpath
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
520 if MDF_identifyFields:
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
521 query=[]
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
522 for field in MDF_identifyFields:
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
523
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
524 query.append("""(%s="%s")"""%(field,form[MDF_prefix+"MD_"+field]))
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
525 querystr=" and ".join(query)
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
526 xpathStr=MDF_xpathStart+"[%s]"%querystr
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
527
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
528 else:
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
529 xpathStr=MDF_xpathStart
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
530
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
531
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
532 xpathNodes=Evaluate(xpathStr,actualNode)
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
533
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
534
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
535
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
536
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
537 if len(xpathNodes)>0:
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
538 actualNode=xpathNodes[0]
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
539
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
540 else:
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
541 #existiert nicht dann neue erzeugen
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
542
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
543 if len(Evaluate(MDF_xpathStart,dom))>0:
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
544
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
545 create=True
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
546
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
547 splitted=MDF_xpathStart.split("/")
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
548 base=""
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
549 for element in splitted:
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
550
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
551 if not (element=="") and not (element==containerTag):
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
552 base="/".join([base,element])
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
553
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
554 if not newdoc:
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
555 newdoc=impl.createDocument(None,element,None)
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
556 actualNode=newdoc.documentElement
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
557 dom=actualNode
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
558 else:
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
559 changed=None
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
560
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
561 if not (MDF_addPath==base):
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
562
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
563
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
564 for childNode in actualNode.childNodes:
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
565 if getattr(childNode,'tagName','')==element:
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
566 actualNode=childNode
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
567 changed=1
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
568
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
569 if (os.path.normpath("/".join(["",containerTag,base]))==MDF_xpathStart) and create:
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
570 actualNode=actualNode.parentNode
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
571 changed=None
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
572
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
573 if not changed:
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
574 namenode=newdoc.createElement(element)
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
575
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
576 actualNode.appendChild(namenode)
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
577 actualNode=namenode
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
578
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
579
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
580
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
581
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
582 for name in self.REQUEST.form.keys():
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
583 length=len(MDF_prefix)
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
584 if MDF_type and not (MDF_type == ""):
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
585 actualNode.setAttribute("type",MDF_type)
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
586 if name[0:3+length]==MDF_prefix+"MD_":
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
587 tagName=name[3+length:]
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
588
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
589 #CHECK if element exists
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
590 for childNode in actualNode.childNodes:
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
591 if getattr(childNode,'tagName','')==tagName:
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
592 actualNode.removeChild(childNode).unlink()
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
593
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
594 namenode=newdoc.createElement(tagName)
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
595 namenodetext=newdoc.createTextNode(self.REQUEST.form[name])
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
596 namenode.appendChild(namenodetext)
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
597 actualNode.appendChild(namenode)
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
598
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
599 ret=newdoc.toxml(encoding='utf-8')
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
600 zLOG.LOG("OSAS_metadata (writeMetadata)",zLOG.INFO,"write: %s"%ret)
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
601
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
602
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
603 server.writeMetaDataFile(indexFile,ret)
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
604
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
605
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
606 return newdoc,actualNode
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
607
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
608 def writeMetadataFile(self,MDF_path,MDF_type,MDF_xpathStart="",newdoc=None,actualNode=None):
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
609 """writeMetaFile"""
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
610
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
611 return self.writeMetadata(MDF_path,MDF_type,self.REQUEST.form,MDF_xpathStart=MDF_xpathStart,newdoc=newdoc,actualNode=actualNode)
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
612
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
613
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
614 def isEmptyValue(self,fieldName):
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
615 """im generischen fall stets falsch"""
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
616 return 1
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
617
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
618 def getValue(self,fieldName):
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
619 """im generischen fall gleich fieldname"""
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
620 return fieldName,fieldName,"","",""
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
621
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
622 def getList(self,list):
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
623 """return list"""
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
624
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
625 if list=="":
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
626 return None
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
627 listsplit=[i.rstrip() for i in list.split("\n")]
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
628 return listsplit
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
629
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
630 def showHelp(self,refType,genericTag):
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
631 """helptext"""
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
632 for reference in self.ZopeFind(self):
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
633 if reference[1].title==refType:
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
634 text=getattr(reference[1],'md_'+genericTag)[2]
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
635 return text
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
636 return "NO EXPLANATION"
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
637
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
638 def showHelpTag(self,url,reftype,item):
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
639 """gen javascript for showhelp"""
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
640 url2=url+'/showHelp?refType=%s&genericTag=%s'%(reftype,item)
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
641 ret="""javascript:wd=window.open(\'%s\',\'Help\',\'width=300,height=250\');void(\'\');wd.focus();"""%url2
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
642 return ret
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
643
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
644
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
645 def manage_addMetadataForm(self):
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
646 """interface for adding the OSAS_add_Metadata"""
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
647 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
648 return pt()
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
649
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
650 def manage_addMetadata(self,id,shortDescription,description,fields,RESPONSE=None):
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
651 """add the OSAS_root"""
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
652 newObj=OSAS_Metadata(id,shortDescription,description,fields)
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
653 self.Destination()._setObject(id,newObj)
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
654 if RESPONSE is not None:
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
655 RESPONSE.redirect('manage_main')
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
656
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
657
9f9d9be26e53 first checkin in Mercurial (see history in SVN)
casties
parents:
diff changeset
658