Annotation of OSAS/OSA_system/OSAS_addfiles.py, revision 1.7
1.1 dwinter 1: # Methoden und Classen zum Hinzufuegen von Dokumenten
2:
1.7 ! dwinter 3: import xml.dom.minidom
1.5 dwinter 4: from Products.ECHO_content import ECHO_collection
1.3 dwinter 5: import urllib
1.1 dwinter 6: import OSAS_add
1.5 dwinter 7: import string
1.1 dwinter 8: from OFS.Folder import Folder
9: from AccessControl import ClassSecurityInfo
10: from Globals import InitializeClass
11: from Products.PageTemplates.PageTemplateFile import PageTemplateFile
12: from Products.PageTemplates.PageTemplate import PageTemplate
13:
14: class OSAS_add_Document(Folder):
15: """Hinzufuegen eines Dokumentes zum Storage"""
16: security=ClassSecurityInfo()
17:
18: def __init__(self,id):
19: """initialize a new instance"""
20: self.id = id
21:
22:
23: meta_type='OSAS_add_Document'
24: manage_options = Folder.manage_options+(
25: {'label':'Main Config','action':'add_Document_config'},
26: )
27:
28:
29:
30: security.declarePublic('add_Document_config')
31: def add_Document_config(self):
32: """Main configuration"""
33: pt=PageTemplateFile('products/OSA_system/ChangeOSAS_addDocument.zpt').__of__(self)
34: return pt()
35:
36: security.declarePublic('change_OSAS_add_Document')
37: def change_OSAS_add_Document(self,RESPONSE=None):
38: """Change"""
39: # self.RootFolderName=RootFolderName
40: if RESPONSE is not None:
41: RESPONSE.redirect('manage_main')
42:
43: security.declarePublic('index_html')
44: def index_html(self):
45: """stantard aufruf"""
46: return OSAS_add.add(self,no_upload=1)
47:
48:
49: security.declarePublic('add2')
50: def add2(self):
51: """ anlegen naechster schritt"""
52: return OSAS_add.add2(self)
53:
54: def add3(self):
55: """Foldername"""
56: return OSAS_add.add3(self)
57:
58: def add4(self):
59: """Applet"""
60: return OSAS_add.add4(self)
61:
62: def add5(self):
63: """Foldername"""
64: return OSAS_add.add5(self)
65:
66: def add6(self):
67: """write new index.meta file"""
68: return OSAS_add.add6(self)
69:
70:
71: def addImages(self,path):
72: """Hinzufügen eines neuen Imagesfolders"""
73: return OSAS_add.addImages(self,path)
74:
75: def addImages2(self):
76: """Upload des neuen Imagefolders"""
1.2 dwinter 77: return OSAS_add.addImages2(self)
78:
1.1 dwinter 79:
80: def manage_AddOSAS_add_DocumentForm(self):
81: """interface for adding the OSAS_add_Metadata"""
82: pt=PageTemplateFile('products/OSA_system/AddOSAS_document.zpt').__of__(self)
83: return pt()
84:
85: def manage_AddOSAS_add_Document(self,id,RESPONSE=None):
86: """add the OSAS_root"""
87: newObj=OSAS_add_Document(id)
88: self.Destination()._setObject(id,newObj)
89: if RESPONSE is not None:
90: RESPONSE.redirect('manage_main')
91:
92:
93: InitializeClass(OSAS_add_Document)
94:
1.2 dwinter 95:
96: class OSAS_add_Text(Folder):
97: """Hinzufuegen eines Text-Dokumentes zum Storage"""
98: security=ClassSecurityInfo()
99:
100: def __init__(self,id):
101: """initialize a new instance"""
102: self.id = id
103:
104:
105: meta_type='OSAS_add_Text'
106: manage_options = Folder.manage_options+(
107: {'label':'Main Config','action':'add_Text_config'},
108: )
109:
110:
111:
112: security.declarePublic('add_Text_config')
113: def add_Text_config(self):
114: """Main configuration"""
115: pt=PageTemplateFile('products/OSA_system/ChangeOSAS_addText.zpt').__of__(self)
116: return pt()
117:
118: security.declarePublic('change_OSAS_add_Text')
119: def change_OSAS_add_Text(self,RESPONSE=None):
120: """Change"""
121: # self.RootFolderName=RootFolderName
122: if RESPONSE is not None:
123: RESPONSE.redirect('manage_main')
124:
125: def addText(self,path):
126: """Add a fulltext"""
127: return OSAS_add.addText(self,path)
128:
129: def addText2(self):
130: """Read the file and store it"""
131: return OSAS_add.addText2(self)
132: def manage_AddOSAS_add_TextForm(self):
133: """interface for adding the OSAS_add_Metadata"""
134: pt=PageTemplateFile('products/OSA_system/AddOSAS_text.zpt').__of__(self)
135: return pt()
136:
137: def manage_AddOSAS_add_Text(self,id,RESPONSE=None):
138: """add the OSAS_root"""
139: newObj=OSAS_add_Text(id)
140: self.Destination()._setObject(id,newObj)
141: if RESPONSE is not None:
142: RESPONSE.redirect('manage_main')
143:
144:
145: InitializeClass(OSAS_add_Text)
1.3 dwinter 146:
147: class OSAS_add_contextData(Folder):
148: """Einfuegen eines Documentes in eine Collection"""
149:
150: security=ClassSecurityInfo()
151:
152:
153: meta_type='OSAS_add_contextData'
154:
155: def __init__(self,id,collection):
156: self.id=id
157: self.collection=collection
158:
1.4 dwinter 159: def getChilds(self,id,depth,items):
160: list=[]
161: for object in items:
162: if (depth==object[2])&(id==object[0]):
163: list.append(object)
164: return list
165:
166: def printChilds(self,startItem,depth,items,enddepth):
1.3 dwinter 167:
1.4 dwinter 168: def spaces(depth):
169: tmp=""
170: k=0
171: while k<2*depth:
172: k+=1
173: tmp=tmp+" "+" "
174: return tmp
1.3 dwinter 175:
1.4 dwinter 176: def retLink(object):
1.5 dwinter 177: return "<input type='checkbox' name='collection' value='%s'>%s</input>"% (string.join(object.getPhysicalPath(),"."),object.title)
1.4 dwinter 178:
179: depth+=1
180: childs=self.getChilds(startItem,depth,items)
181: tmp=""
182: for child in childs:
183: if depth < enddepth:
184: tmp=tmp+spaces(depth)
1.5 dwinter 185:
1.4 dwinter 186: tmp= tmp+retLink(child[1])+"<br>"+self.printChilds(child[1],depth,items,enddepth)+"<br>"
187: else:
188: tmp=tmp+spaces(2*depth)
189: tmp = tmp+retLink(child[1])+"<br>"
1.3 dwinter 190:
1.4 dwinter 191: return tmp
192:
193: def generateTree(self,depth=3):
194: """Erzeugt HTML-Tree der Collection"""
195:
1.3 dwinter 196: exec("items=self.getPhysicalRoot()."+self.collection+".getCollectionTree()")
1.4 dwinter 197: #print items[0][0]
1.3 dwinter 198:
1.4 dwinter 199: childs=self.printChilds(items[0][0],0,items,3)
1.3 dwinter 200:
1.5 dwinter 201: return childs
1.3 dwinter 202:
1.5 dwinter 203: def getPartners(self):
204: """Zeige Partnerliste"""
205: exec("items=self.getPhysicalRoot()."+self.collection+".partners.getPartners()")
206: return items
207: def addContextData(self,path):
208: """Hinzufügen zu einer Sammlung"""
1.6 dwinter 209: try:
210: urllib.urlopen(self.REQUEST['SERVER_URL']+path+"/index.meta")
211: pt=PageTemplateFile('products/OSA_system/contextDataMain.zpt').__of__(self)
212: return pt()
213: except:
214: return "index.meta file has to exist!"
1.3 dwinter 215:
1.5 dwinter 216:
217:
218: def addContextData2(self,path,collection,context,science,practice,source_type,period,label,description,content_type,responsible,credits):
219: """Hinzufuegen der Resource"""
220: splitted=path.split("/")
221:
222: id=splitted[len(splitted)-1]
223: title=splitted[len(splitted)-1]
1.6 dwinter 224: metalink=self.REQUEST['SERVER_URL']+path+"/index.meta"
1.5 dwinter 225: link="TOBEDONE"
226: """Hinzufügen der Ressource"""
1.3 dwinter 227:
1.5 dwinter 228:
229: exec("collection_object=self"+collection)
230:
231: ECHO_collection.manage_AddECHO_resource(collection_object,context,science,practice,source_type,period,id,title,label,description,content_type,responsible,link,metalink,credits,RESPONSE=None)
1.6 dwinter 232:
233: getattr(collection_object,id).ECHO_getResourceMD()
1.5 dwinter 234:
235: return self.REQUEST.RESPONSE.redirect(self.REQUEST['URL2']+'?path='+path)
236:
1.3 dwinter 237: manage_options = Folder.manage_options+(
238: {'label':'Main Config','action':'add_contextData_config'},
239: )
240:
241:
242: def add_contextData_config(self):
243: """Main configuration"""
244: pt=PageTemplateFile('products/OSA_system/ChangeOSAS_add_contextData.zpt').__of__(self)
245: return pt()
246:
247:
248: def change_OSAS_add_contextData(self,collection,RESPONSE=None):
249: """Change"""
250: self.collection=collection
251: if RESPONSE is not None:
252: RESPONSE.redirect('manage_main')
253:
254: def manage_AddOSAS_add_contextDataForm(self):
255: """interface for adding the OSAS_add_Metadata"""
256: pt=PageTemplateFile('products/OSA_system/AddOSAS_contextData.zpt').__of__(self)
257: return pt()
258:
259: def manage_AddOSAS_add_contextData(self,id,collection,RESPONSE=None):
260: """add the OSAS_root"""
261: newObj=OSAS_add_contextData(id,collection)
262: self.Destination()._setObject(id,newObj)
263: if RESPONSE is not None:
264: RESPONSE.redirect('manage_main')
265:
266:
267: InitializeClass(OSAS_add_contextData)
1.2 dwinter 268:
269: class OSAS_add_Presentation(Folder):
270: """Hinzufügen der Presentationsinformationen"""
271: security=ClassSecurityInfo()
272:
273: def __init__(self,id):
274: """initialize a new instance"""
275: self.id = id
276:
277:
278: meta_type='OSAS_add_Presentation'
279: manage_options = Folder.manage_options+(
280: {'label':'Main Config','action':'add_Presentation_config'},
281: )
282:
283:
284:
285: security.declarePublic('add_Presentation_config')
286: def add_Presentation_config(self):
287: """Main configuration"""
288: pt=PageTemplateFile('products/OSA_system/ChangeOSAS_addPresentation.zpt').__of__(self)
289: return pt()
290:
291: security.declarePublic('change_OSAS_add_Presentation')
292: def change_OSAS_add_Presentation(self,RESPONSE=None):
293: """Change"""
294: # self.RootFolderName=RootFolderName
295: if RESPONSE is not None:
296: RESPONSE.redirect('manage_main')
297:
298: def addPresentation(self,path):
299: """Hinzufügen der Presenationsinformation"""
300: return OSAS_add.addPresentation(self,path)
301:
302: def addPresentation2(self):
303: """Eingabe von Metadateninformationen"""
304: return OSAS_add.addPresentation2(self)
305:
306: def manage_AddOSAS_add_PresentationForm(self):
307: """interface for adding the OSAS_add_Metadata"""
308: pt=PageTemplateFile('products/OSA_system/AddOSAS_presentation.zpt').__of__(self)
309: return pt()
310:
311: def manage_AddOSAS_add_Presentation(self,id,RESPONSE=None):
312: """add the OSAS_root"""
313: newObj=OSAS_add_Presentation(id)
314: self.Destination()._setObject(id,newObj)
315: if RESPONSE is not None:
316: RESPONSE.redirect('manage_main')
317:
318:
319: InitializeClass(OSAS_add_Presentation)
320:
321: class OSAS_combineTextImage(Folder):
322: """Hinzufügen der Combine Text und Image"""
323: security=ClassSecurityInfo()
324:
325: def __init__(self,id):
326: """initialize a new instance"""
327: self.id = id
328:
329:
330: meta_type='OSAS_combineTextImage'
331: manage_options = Folder.manage_options+(
332: {'label':'Main Config','action':'combineTextImage_config'},
333: )
334:
335:
336:
337: security.declarePublic('combineTextImage_config')
338: def combineTextImage_config(self):
339: """Main configuration"""
340: pt=PageTemplateFile('products/OSA_system/ChangeOSAS_combineTextImage.zpt').__of__(self)
341: return pt()
342:
343: security.declarePublic('change_OSAS_combineTextImage')
344: def change_OSAS_combineTextImage(self,RESPONSE=None):
345: """Change"""
346: # self.RootFolderName=RootFolderName
347: if RESPONSE is not None:
348: RESPONSE.redirect('manage_main')
349:
350: security.declarePublic('combineTextImage')
351: def combineTextImage(self,path):
352: """Hinzufügen der Presenationsinformation"""
353: return OSAS_add.combineTextImage(self,path)
354:
355: def combineTextImage2(self,path):
356: """Eingabe von Metadateninformationen"""
1.7 ! dwinter 357: OSAS_add.combineTextImage2(self,path) # Add images
! 358: splitted=path.split("/")
! 359: linkPath=splitted[len(splitted)-1]
! 360: linkViewerEnvironment="http://nausikaa2.mpiwg-berlin.mpg.de:86/cgi-bin/toc/toc.x.cgi?dir=%s&step=thumb" % linkPath
! 361: self.REQUEST.SESSION['linkViewerEnvironment']=linkViewerEnvironment
! 362:
! 363: writeToContext(path,linkViewerEnvironment,"ECHO standard environment")
! 364:
! 365: pt=PageTemplateFile('products/OSA_system/AddOSAS_combineTextImageFinal.zpt').__of__(self)
! 366:
! 367: return pt()
! 368:
! 369:
! 370: def writeToContext(path,link,description):
! 371: """Created an additional entry to the index.meta file of path"""
! 372: dom=xml.dom.minidom.parse(path+"/index.meta")
! 373: node=dom.getElementsByTagName('resource')[0]
! 374:
! 375: subnode=dom.createElement('context')
! 376:
! 377: linknode=dom.createElement('link')
! 378: namelinknode=dom.createTextNode(link)
! 379: linknode.appendChild(namelinknode)
! 380: subnode.appendChild(linknode)
! 381:
! 382: linknode=dom.createElement('name')
! 383: namelinknode=dom.createTextNode(description)
! 384: linknode.appendChild(namelinknode)
! 385: subnode.appendChild(linknode)
! 386:
! 387: node.appendChild(subnode)
! 388:
! 389: writefile=file(path+"/index.meta","w")
! 390: #print path+"/index.meta"
! 391: writefile.write(dom.toxml().encode('utf-8'))
! 392: writefile.close()
1.2 dwinter 393:
394: def manage_AddOSAS_combineTextImageForm(self):
395: """interface for adding the OSAS_add_Metadata"""
396: pt=PageTemplateFile('products/OSA_system/AddOSAS_combineTextImage.zpt').__of__(self)
397: return pt()
398:
399: def manage_AddOSAS_combineTextImage(self,id,RESPONSE=None):
400: """add the OSAS_root"""
401: newObj=OSAS_combineTextImage(id)
402: self.Destination()._setObject(id,newObj)
403: if RESPONSE is not None:
404: RESPONSE.redirect('manage_main')
405:
406:
407: InitializeClass(OSAS_combineTextImage)
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>