Annotation of ECHO_content/ECHO_collection.py, revision 1.19
1.13 dwinter 1: """New version of the product started February, 8th. Without scientific classification, use content-type for further classification."""
1.1 casties 2: """Echo collection provides the classes for the ECHO content web-site.
3:
4: class ECHO_collection is the basis class for an ECHO collection.
5:
6: class ECHO_resource contains information on ECHO resources (e.g. an Display environment for Metadata
7:
8: class ECHO_externalLink contains information on externalLinks
9:
10:
11: """
12: import string
1.14 dwinter 13: import re
1.1 casties 14: import OFS.Image
15: from types import *
16: from OFS.Image import Image
17: from Globals import DTMLFile
18: from OFS.Folder import Folder
19: from OFS.SimpleItem import SimpleItem
20: from AccessControl import ClassSecurityInfo
21: from Globals import InitializeClass
22: from Globals import DTMLFile
23: from Products.PageTemplates.PageTemplateFile import PageTemplateFile
24: from Products.PageTemplates.PageTemplate import PageTemplate
25: from Globals import Persistent
26: from Acquisition import Implicit
1.15 dwinter 27: #from psycopg import libpq
28: #from pyPgSQL import libpq
1.14 dwinter 29: import xml.dom.minidom
1.1 casties 30:
31: import urllib
32: import xml.dom.minidom
33:
34:
1.6 dwinter 35: #List of different types for the graphical linking viewer
36: viewClassificationListMaster=['view point','area']
37:
38:
1.1 casties 39: def toList(field):
40: """Einzelfeld in Liste umwandeln"""
41: if type(field)==StringType:
42: return [field]
43: else:
44: return field
45:
46: def getText(nodelist):
47:
48: rc = ""
49: for node in nodelist:
50: if node.nodeType == node.TEXT_NODE:
51: rc = rc + node.data
52: return rc
53:
54:
55: def readMetadata(url):
56: """Methoden zum Auslesen der Metadateninformation zu einer Resource
57: Vorerst noch Typ bib"""
58:
59: metadict={}
60: try:
61: geturl=""
62: for line in urllib.urlopen(url).readlines():
63: geturl=geturl+line
64:
65:
66: except:
67: return (None,"Cannot open: "+url)
68:
69: try:
70: dom=xml.dom.minidom.parseString(geturl)
71: except:
72: return (None,"Cannot parse: "+url+"<br>"+geturl)
73:
74: metanode=dom.getElementsByTagName('bib')
75: metadict['bib_type']='Book'
76: if len(metanode)==0:
77: metanode=dom.getElementsByTagName('archimedes')
78: metadict['bib_type']='Archimedes'
79: #print "HELLO"
80:
81: if not len(metanode)==0:
82: metacontent=metanode[0].childNodes
83:
84: try:
85: metadict['bib_type']=getText(dom.getElementsByTagName('bib')[0].attributes['type'].childNodes)
86: except:
87: """nothing"""
88:
89: for node in metacontent:
90: try:
91: metadict[node.tagName.lower()]=getText(node.childNodes)
92: except:
93: """nothing"""
94:
95: #print metadict
96: return metadict,""
97:
98:
1.13 dwinter 99: def setECHO_collectionInformation(self,title,label,description,content_type,responsible,credits,weight,coordstrs,viewClassification=""):
1.1 casties 100:
101: """Allegemeine Informationen zu einer ECHO Collection"""
102:
1.6 dwinter 103: self.viewClassification=viewClassification
104:
1.1 casties 105: self.label = label
106: self.title=title
107: self.description=description
108: self.content_type=content_type
109: self.responsible=responsible
110: self.credits=toList(credits)
111: self.weight=weight
112:
1.5 dwinter 113: coords=[]
1.1 casties 114: #coordinates of for rectangles
1.10 dwinter 115:
1.9 dwinter 116: #print "cs", coordstrs
117: if coordstrs:
118: for coordstr in coordstrs:
1.12 dwinter 119: #print "cs", coordstr
1.9 dwinter 120: try:
121: temco=coordstr.split(",")
122: except:
123: temco=[]
124: #temco.append(angle)
125: coords.append(temco)
126:
1.10 dwinter 127:
1.5 dwinter 128: self.coords=coords[0:]
1.1 casties 129:
130:
131: class scientificClassification(SimpleItem,Persistent,Implicit):
1.13 dwinter 132: """outdated will be deleeted in the next versions: subclass"""
1.1 casties 133: security=ClassSecurityInfo()
134:
135: def __init__(self,context,science,practice):
136: self.context=context
137: self.science=science
138: self.practice=practice
139: self.id="scientific_Classification"
140:
141: security.declarePublic('get_context')
142: def get_context(self):
143: return self.context
144:
145: security.declarePublic('get_science')
146: def get_science(self):
147: return self.science
148:
149: security.declarePublic('get_practice')
150: def get_practice(self):
151: return self.practice
152:
153:
154: class scientificInformation(Folder,Persistent,Implicit):
1.13 dwinter 155: """outdated will be deleted in the next versions: subclass scientificInformation"""
1.1 casties 156: security=ClassSecurityInfo()
157:
158:
159:
160: def __init__(self,source_type,period):
161:
162: self.id="scientific_Information"
163: self.source_type=source_type
164: self.period=period
165:
166:
167:
168: security.declarePublic('get_source_type')
169: def get_source_type(self):
170: return self.source_type
171:
172: security.declarePublic('get_period')
173: def get_period(self):
174: return self.period
175:
176:
177: class ECHO_resource(Folder):
178: """ECHO Ressource"""
179: meta_type='ECHO_resource'
180:
1.6 dwinter 181: viewClassificationList=viewClassificationListMaster
1.1 casties 182:
1.6 dwinter 183: def getViewClassification(self):
184: if hasattr(self,'viewClassification'):
185: return self.viewClassification
186: else:
187: return ""
1.13 dwinter 188:
1.9 dwinter 189: def getCredits(self):
190: """Ausgabe der credits"""
191: if self.credits:
192: return self.credits
193: else:
194: return []
1.6 dwinter 195:
1.1 casties 196: def __init__(self,id,link,metalink,title,label,description,content_type,responsible,credits,weight,coords):
197:
198: self.id = id
199: """Festlegen der ID"""
200:
201: self.label = label
202: self.link= link
203: self.metalink=metalink
204: self.title=title
205: self.weight=weight
206: self.credits=toList(credits)
207: self.description=description
208: self.content_type=content_type
209: self.responsible=responsible
1.9 dwinter 210:
211: if coords:
212: coordsnew=[ string.split(x,",") for x in coords]
213: else:
214: coordsnew=[]
215:
1.1 casties 216: self.coords=coordsnew
217:
1.3 dwinter 218:
219: def getCoords(self):
220: try:
1.4 dwinter 221: return [string.join(x,",") for x in self.coords]
1.3 dwinter 222: except:
223: return []
224:
1.1 casties 225:
226: def ECHO_resource_config(self):
227: """Main configuration"""
228:
229: if not hasattr(self,'weight'):
230: self.weight=""
231: if not hasattr(self,'coords'):
232: self.coords=[]
233:
1.13 dwinter 234: pt=PageTemplateFile('Products/ECHO_content/zpt/ChangeECHO_resource.zpt').__of__(self)
1.1 casties 235: return pt()
236:
237:
1.13 dwinter 238: def changeECHO_resource(self,metalink,link,title,label,description,content_type,responsible,weight,viewClassification="",coords=None,credits=None,RESPONSE=None):
1.10 dwinter 239:
1.1 casties 240:
241: """Änderung der Properties"""
242:
243:
1.13 dwinter 244: setECHO_collectionInformation(self,title,label,description,content_type,responsible,credits,weight,coords,viewClassification)
1.1 casties 245:
246:
247: self.link=link
248: self.metalink=metalink
249:
250: if RESPONSE is not None:
251: RESPONSE.redirect('manage_main')
252:
253:
254: manage_options = Folder.manage_options+(
255: {'label':'Main Config','action':'ECHO_resource_config'},
256: {'label':'Metadata','action':'ECHO_getResourceMD'},
1.3 dwinter 257: {'label':'Graphics','action':'ECHO_graphicEntry'},
1.1 casties 258: )
259:
1.3 dwinter 260: def ECHO_graphicEntry(self):
261: """DO nothing"""
1.19 ! dwinter 262: overview = self.ZopeFind(self,obj_ids=['overview'])
! 263:
! 264: if overview:
1.13 dwinter 265: pt=PageTemplateFile('Products/ECHO_content/zpt/ECHO_draw.zpt').__of__(self)
1.3 dwinter 266: return pt()
267: else:
268: return "NO OVERVIEW GRAPHICS"
269:
1.4 dwinter 270: def ECHO_enterCoords(self,coordstr,angle="",RESPONSE=None):
1.3 dwinter 271: """Enter coords"""
272: coords=self.coords
1.4 dwinter 273: temco=coordstr.split(",")
274: temco.append(angle)
275: coords.append(temco)
276:
1.3 dwinter 277: self.coords=coords[0:]
1.13 dwinter 278:
1.3 dwinter 279: if RESPONSE is not None:
280: RESPONSE.redirect('ECHO_graphicEntry')
281:
1.1 casties 282: def ECHO_getResourceMD(self,template="yes"):
283: """Einlesen der Metadaten und Anlegen dieser Metadaten als Informationen zur Resource"""
284: (metadict, error)=readMetadata(self.metalink)
285:
1.13 dwinter 286:
1.1 casties 287:
288: if not error=="": #Fehler beim Auslesen des Metafiles
289: return "ERROR:",error
290: for key in metadict.keys():#Hinzufügen der Felder
291:
292: setattr(self,key,metadict[key].encode('ascii','replace'))
293:
294:
295: self.metadata=metadict.keys()
1.13 dwinter 296:
1.1 casties 297: self.label=self.generate_label()
298:
299: if template=="yes":
1.13 dwinter 300: pt=PageTemplateFile('Products/ECHO_content/zpt/ECHO_resourceMD.zpt').__of__(self)
1.1 casties 301: return pt()
302:
303: def ECHO_getMD(self,item):
304: """Ausgabe der MD"""
305: return getattr(self,item)
306:
307: def index_html(self):
308: """standard page"""
309:
310: return self.REQUEST.RESPONSE.redirect(self.link)
311:
312: def generate_label(self):
313: """Erzeugt_standard_Label aus Template"""
314: pt=getattr(self,"label_template_"+self.bib_type)
1.13 dwinter 315:
1.1 casties 316: return pt()
317:
1.13 dwinter 318: def manage_addECHO_resourceForm(self):
319: """Form for adding a ressource"""
320: pt=PageTemplateFile('Products/ECHO_content/zpt/AddECHO_resourceForm.zpt').__of__(self)
1.1 casties 321: return pt()
322:
323:
1.10 dwinter 324:
1.13 dwinter 325: def manage_addECHO_resource(self,id,title,label,description,content_type,responsible,link,metalink,weight,credits=None,coords=None,RESPONSE=None):
326: """addaresource"""
1.1 casties 327:
328: newObj=ECHO_resource(id,link,metalink,title,label,description,content_type,responsible,credits,weight,coords)
329:
330: self._setObject(id,newObj)
1.13 dwinter 331:
1.1 casties 332: if RESPONSE is not None:
333: RESPONSE.redirect('manage_main')
334:
335:
336: class ECHO_externalLink(Folder):
337: """Link zu einer externen Ressource"""
338: security=ClassSecurityInfo()
339: meta_type='ECHO_externalLink'
340:
341:
342: def __init__(self,id,link,title,label,description,content_type,responsible,credits,weight,coords):
343:
344: self.id = id
345: """Festlegen der ID"""
346:
347: self.credits=toList(credits)
348: self.label = label
349: self.link= link
350: self.title=title
351: self.weight=weight
352: self.description=description
353: self.content_type=content_type
354: self.responsible=responsible
355: coordsnew=[ string.split(x,",") for x in coords]
356: self.coords=coordsnew
357:
358: def ECHO_externalLink_config(self):
359: """Main configuration"""
360:
361: if not hasattr(self,'weight'):
362: self.weight=""
363: if not hasattr(self,'coords'):
1.9 dwinter 364:
1.1 casties 365: self.coords=['']
1.12 dwinter 366: #print "G",self.coords
1.1 casties 367:
1.13 dwinter 368: pt=PageTemplateFile('Products/ECHO_content/zpt/ChangeECHO_externalLink.zpt').__of__(self)
1.1 casties 369: return pt()
370:
371:
1.13 dwinter 372: def changeECHO_externalLink(self,link,title,label,description,content_type,responsible,weight,coords=None,credits=None,RESPONSE=None):
1.1 casties 373:
374: """Änderung der Properties"""
375:
376:
1.13 dwinter 377: setECHO_collectionInformation(self,title,label,description,content_type,responsible,credits,weight,coords)
1.1 casties 378:
379:
380: self.link=link
381: if RESPONSE is not None:
382: RESPONSE.redirect('manage_main')
383:
384:
385: manage_options = Folder.manage_options+(
386: {'label':'Main Config','action':'ECHO_externalLink_config'},
387: )
1.17 dwinter 388:
389: def getCredits(self):
390: """Ausgabe der credits"""
391: if self.credits:
392: return self.credits
393: else:
394: return []
395:
1.1 casties 396: def index_html(self):
397: """standard page"""
398:
399: return self.REQUEST.RESPONSE.redirect(self.link)
400:
1.13 dwinter 401: def manage_addECHO_externalLinkForm(self):
402: """Form for external Links"""
403: pt=PageTemplateFile('Products/ECHO_content/zpt/AddECHO_externalLinkForm.zpt').__of__(self)
1.1 casties 404: return pt()
405:
406:
1.13 dwinter 407: def manage_addECHO_externalLink(self,id,title,label,description,content_type,responsible,link,weight,coords=None,credits=None,RESPONSE=None):
408: """Add an external Link"""
1.1 casties 409:
410: newObj=ECHO_externalLink(id,link,title,label,description,content_type,responsible,credits,weight,coords)
411:
412: self._setObject(id,newObj)
1.13 dwinter 413:
1.1 casties 414: if RESPONSE is not None:
415: RESPONSE.redirect('manage_main')
416:
417:
418: class ECHO_collection(Folder, Persistent, Implicit):
419: """ECHO Collection"""
420: security=ClassSecurityInfo()
421: meta_type='ECHO_collection'
422:
423:
424:
425: security.declarePublic('getCreditObject')
426: def getCreditObject(self,name):
427: """credit id to credititem"""
1.15 dwinter 428: try:
429: return getattr(self.partners,name)
430: except:
431: return ""
1.17 dwinter 432:
1.1 casties 433: security.declarePublic('ECHO_generateNavBar')
434: def ECHO_generateNavBar(self):
435: """Erzeuge Navigationsbar"""
436: link=""
437: object="self"
438: ret=[]
439: path=self.getPhysicalPath()
440: for element in path:
441:
442:
443: if not element=="":
444: object+="."+element
445:
446: label=eval(object).label
447: link+="/"+element
448: if not label=="":
449: ret.append((label,link))
450: return ret
451:
452: security.declarePublic('ECHO_rerenderLinksMD')
453: def ECHO_rerenderLinksMD(self):
454: """Rerender all Links"""
1.13 dwinter 455:
1.1 casties 456: for entry in self.__dict__.keys():
457: object=getattr(self,entry)
458:
459:
460: try:
461:
462: if object.meta_type == 'ECHO_resource':
463:
464: object.ECHO_getResourceMD(template="no")
465:
466: except:
467: """nothing"""
468:
469: return "Rerenderd all links to resources in: "+self.title
1.19 ! dwinter 470:
! 471: security.declarePublic('ECHO_newViewerLink')
1.1 casties 472:
473:
474: def getCoords(self):
475: try:
1.11 dwinter 476:
477: x= [string.join(x,",") for x in self.coords]
478: return x
1.4 dwinter 479:
1.11 dwinter 480: except:
1.4 dwinter 481:
1.1 casties 482: return []
1.3 dwinter 483:
1.1 casties 484: def __init__(self,id,title,label,description,content_type,responsible,credits,weight,sortfield,coords):
1.9 dwinter 485: #print "CO",coords
1.1 casties 486:
487: self.id = id
488: """Festlegen der ID"""
489: self.credits=toList(credits)
490: self.label = label
491: self.title=title
492: self.description=description
493: self.content_type=content_type
494: self.responsible=responsible
495:
496: self.weight=weight
497: self.sortfield=sortfield
498: coordsnew=[ string.split(x,",") for x in coords]
499: self.coords=coordsnew
500:
501:
502: manage_options = Folder.manage_options+(
1.13 dwinter 503: {'label':'Main Config','action':'ECHO_collection_config'},
1.1 casties 504: {'label':'Rerender Links','action':'ECHO_rerenderLinksMD'},
505: {'label':'Graphics','action':'ECHO_graphicEntry'},
506:
507: )
508:
1.19 ! dwinter 509: def getOverview(self):
! 510: """overview graphics"""
! 511: return self.ZopeFind(self,obj_ids=['overview'])[0][1]
! 512:
1.1 casties 513: def ECHO_graphicEntry(self):
514: """DO nothing"""
1.19 ! dwinter 515: overview = self.ZopeFind(self,obj_ids=['overview'])
! 516:
! 517: if overview:
1.13 dwinter 518: pt=PageTemplateFile('Products/ECHO_content/zpt/ECHO_draw.zpt').__of__(self)
1.1 casties 519: return pt()
520: else:
521: return "NO OVERVIEW GRAPHICS"
522:
1.4 dwinter 523: def ECHO_enterCoords(self,coordstr,angle="",RESPONSE=None):
1.1 casties 524: """Enter coords"""
1.2 dwinter 525: coords=self.coords
1.4 dwinter 526: temco=coordstr.split(",")
527: temco.append(angle)
528: coords.append(temco)
1.2 dwinter 529: self.coords=coords[0:]
1.13 dwinter 530:
1.2 dwinter 531: if RESPONSE is not None:
532: RESPONSE.redirect('ECHO_graphicEntry')
1.1 casties 533:
534:
1.13 dwinter 535: security.declarePublic('ECHO_collection_config')
536: def ECHO_collection_config(self):
1.1 casties 537: """Main configuration"""
538:
539: if not hasattr(self,'weight'):
540: self.weight=""
541:
542: if not hasattr(self,'sortfield'):
543: self.sortfield="weight"
1.13 dwinter 544:
1.1 casties 545: if not hasattr(self,'coords'):
546: self.coords=[]
547:
1.13 dwinter 548: pt=PageTemplateFile('Products/ECHO_content/zpt/ChangeECHO_collection.zpt').__of__(self)
1.1 casties 549: return pt()
550:
551:
1.13 dwinter 552: security.declarePublic('changeECHO_collection')
1.1 casties 553:
1.10 dwinter 554:
1.13 dwinter 555: def changeECHO_collection(self,title,label,description,content_type,responsible,weight,credits=None,sortfield="weight",coords=None,RESPONSE=None):
556: """Änderung der Properties"""
1.10 dwinter 557:
1.17 dwinter 558: coordsnew=[ string.split(x,",") for x in coords]
559:
1.13 dwinter 560: setECHO_collectionInformation(self,title,label,description,content_type,responsible,credits,weight,coordsnew)
1.1 casties 561:
562: self.sortfield=sortfield
563:
564: if RESPONSE is not None:
565: RESPONSE.redirect('manage_main')
566:
567: security.declarePublic('index_html')
568:
1.18 dwinter 569: showOverview=DTMLFile('dtml/ECHO_content_overview',globals())
1.1 casties 570:
571:
572: def index_html(self):
573: """standard page"""
574:
575: if 'index.html' in self.__dict__.keys():
576: return getattr(self,'index.html')()
577: elif 'overview' in self.__dict__.keys():
578: return self.showOverview()
579:
580:
1.13 dwinter 581: pt=PageTemplateFile('Products/ECHO_content/zpt/ECHO_content_standard.zpt').__of__(self)
1.1 casties 582: pt.content_type="text/html"
583: return pt()
584:
1.11 dwinter 585: def getCredits(self):
586: """Ausgabe der credits"""
587: if self.credits:
588: return self.credits
589: else:
590: return []
1.1 casties 591:
592: def getGraphicCoords(self):
593: """Give list of coordinates"""
594: subColTypes=['ECHO_collection','ECHO_externalLink','ECHO_resource']
595: ids=[]
596: for entry in self.__dict__.keys():
597: object=getattr(self,entry)
598: try:
599: if object.meta_type in subColTypes:
1.4 dwinter 600: for coordtemp in object.coords:
601: if len(coordtemp)>3:
602: coord=coordtemp[0:4]
1.3 dwinter 603: if hasattr(object,'title'):
604: if not object.title=="":
605: ids.append([string.join(coord,", "),object.getId(),object.title])
606: else:
607: ids.append([string.join(coord,", "),object.getId(),object.getId()])
608: else:
609: ids.append([string.join(coord,", "),object.getId(),object.getId()])
1.1 casties 610:
611: except:
612: """nothing"""
1.13 dwinter 613:
1.1 casties 614: return ids
615:
616: def getSubCols(self,sortfield="weight"):
617:
618: subColTypes=['ECHO_collection','ECHO_externalLink','ECHO_resource']
619: ids=[]
620: for entry in self.__dict__.keys():
621: object=getattr(self,entry)
622: try:
623: if object.meta_type in subColTypes:
624: ids.append(object)
625:
626: except:
627: """nothing"""
628: try:
629: sortfield=self.sortfield
630: except:
631: """nothing"""
632:
633: tmplist=[]
634: for x in ids:
635: if hasattr(x,sortfield):
636: try:
637: x=int(x)
638: except:
639: """nothing"""
640: tmp=getattr(x,sortfield)
641: else:
642: tmp=10000000
643: tmplist.append((tmp,x))
644: tmplist.sort()
645: return [x for (key,x) in tmplist]
646:
647:
648:
649:
650:
651:
1.13 dwinter 652: def manage_addECHO_collectionForm(self):
653: """Add collection form"""
654: pt=PageTemplateFile('Products/ECHO_content/zpt/AddECHO_collectionForm.zpt').__of__(self)
1.1 casties 655: return pt()
656:
657:
1.13 dwinter 658: def manage_addECHO_collection(self,id,title,label,description,content_type,responsible,weight,sortfield,coords="",credits=None,RESPONSE=None):
659: """add a echo collection"""
1.1 casties 660:
661:
662: newObj=ECHO_collection(id,title,label,description,content_type,responsible,credits,weight,sortfield,coords)
663:
664: self._setObject(id,newObj)
1.13 dwinter 665:
1.1 casties 666: if RESPONSE is not None:
667: RESPONSE.redirect('manage_main')
668:
669: class ECHO_root(Folder,Persistent,Implicit):
670: """ECHO Root Folder"""
671: meta_type="ECHO_root"
1.19 ! dwinter 672:
! 673: def ECHO_newViewerLink(self,obj=None):
! 674: """change links (:86 faellt weg)"""
! 675:
! 676: if not obj:
! 677: obj = self
! 678:
! 679: entries=obj.ZopeFind(obj,obj_metatypes=['ECHO_resource','ECHO_collection'])
! 680:
! 681: for entry in entries:
! 682:
! 683: if entry[1].meta_type == 'ECHO_resource':
! 684:
! 685: entry[1].link=re.sub('\:86','',entry[1].link)
! 686:
! 687: else:
! 688:
! 689: entry[1].ECHO_newViewerLink(entry[1])
! 690:
! 691: return "Rerenderd all links to resources in: "+self.title
1.1 casties 692:
693: def __init__(self,id,title):
694: """init"""
695: self.id = id
696: self.title=title
1.13 dwinter 697:
1.14 dwinter 698: def deleteSpace(self,str):
699: """delete space at the end of a line"""
700: if str[len(str)-1]==" ":
701: return str[0:len(str)-1]
702: else:
703: return str
704:
705:
706:
707: # zusaetliche methoden fuer das vlp muessen in ein eigenes produkt
708:
709: def formatAscii(self,str,url=None):
710: """ersetze ascii umbrueche durch <br>"""
711: #url=None
712: if url:
713:
714: retStr=""
715: words=str.split("\n")
716:
717: for word in words:
718: strUrl=url%word
719: print "str",strUrl
720: retStr+="""<a href="%s">%s</a><br/>"""%(strUrl,word)
721: str=retStr
722: if str:
723: return re.sub(r"[\n]","<br/>",str)
724: else:
725: return ""
726:
727: def link2html(self,str):
728: """link2html fuer VLP muss hier noch raus"""
729: if str:
730: print str
731: str=re.sub("\&","&",str)
732: dom=xml.dom.minidom.parseString("<?xml version='1.0' ?><txt>"+str+"</txt>")
733: links=dom.getElementsByTagName("link")
734:
735: print "link",links
736: for link in links:
737: link.tagName="a"
738: ref=link.getAttribute("ref")
739: if self.checkRef(ref):
740: link.setAttribute("href",self.aq_parent.absolute_url()+"/vlp_coll?id="+ref)
741:
742: return dom.toxml('utf-8')
743: return ""
744:
745:
746: def checkRef(self,ref):
747: dbs={'vl_literature':'AND CD LIKE \'%lise%\'','vl_technology':'','vl_people':''}
748: res=None
749: for db in dbs.keys():
750: #print ref,"select reference from %s where reference =\'%s\' %s"%(db,ref,dbs[db])
751:
752: res=res or self.search(var=str("select reference from %s where reference =\'%s\' %s"%(db,ref,dbs[db])))
753: return res
754:
755: #Ende Methode fuer vlp
756:
1.13 dwinter 757: def PgQuoteString(self,string):
758: """Quote string"""
1.14 dwinter 759: #print "PG",string
1.13 dwinter 760: return libpq.PgQuoteString(string)
1.1 casties 761:
762: def getPartners(self):
763: """Get list of Partners. Presently only from a subfolder partners"""
764: partnerTypes=['ECHO_partner']
765: ids=[]
1.13 dwinter 766: try:
767: for entry in self.partners.__dict__.keys():
768: object=getattr(self.partners,entry)
769:
770: try:
1.1 casties 771:
1.13 dwinter 772: if object.meta_type in partnerTypes:
773: ids.append(object)
1.1 casties 774:
1.13 dwinter 775: except:
776: """nothing"""
777: except:
778: ids=[] # no partners
1.1 casties 779: return ids
780:
781: def getCollectionTree(self):
782: """get the collection tree (list of triples (parent,child, depth)"""
783:
784: def getCollection(object,depth=0):
785: depth+=1
786: collections=[]
787: for entry in object.__dict__.keys():
788: element=getattr(object,entry)
789: try:
790: if element.meta_type=="ECHO_collection":
791: collections.append((object,element,depth))
792: collections+=getCollection(element,depth)
793: except:
794: """nothing"""
795: return collections
796:
797:
798: return getCollection(self)
799:
800: def getCollectionTreeIds(self):
801: """Show the IDs of the Tree"""
802: ret=[]
803: for collection in self.getCollectionTree():
804: ret.append((collection[0].getId(),collection[1].getId(),collection[2]))
805: return ret
806:
807:
808:
1.13 dwinter 809: def manage_addECHO_root(self,id,title,RESPONSE=None):
1.1 casties 810: """Add an ECHO_root"""
811: self._setObject(id,ECHO_root(id,title))
812:
813: if RESPONSE is not None:
814: RESPONSE.redirect('manage_main')
815:
1.13 dwinter 816: def manage_addECHO_rootForm(self):
1.1 casties 817: """Nothing yet"""
1.13 dwinter 818: pt=PageTemplateFile('Products/ECHO_content/zpt/AddECHO_root.zpt').__of__(self)
1.1 casties 819: return pt()
820:
821: class ECHO_partner(Image,Persistent):
822: """ECHO Partner"""
823:
824: meta_type="ECHO_partner"
825:
826: def __init__(self, id, title,url, file, content_type='', precondition=''):
827: self.__name__=id
828: self.title=title
829: self.url=url
830: self.precondition=precondition
831:
832: data, size = self._read_data(file)
833: content_type=self._get_content_type(file, data, id, content_type)
834: self.update_data(data, content_type, size)
835:
836: manage_options = Image.manage_options+(
837: {'label':'Partner Information','action':'ECHO_partner_config'},
838: )
839:
840: def changeECHO_partner(self,url,RESPONSE=None):
841: """Change main information"""
842: self.url=url
843: if RESPONSE is not None:
844: RESPONSE.redirect('manage_main')
845:
846:
847:
848: def ECHO_partner_config(self):
849: """Main configuration"""
850: if not hasattr(self,'url'):
851: self.url=""
1.13 dwinter 852: pt=PageTemplateFile('Products/ECHO_content/zpt/ChangeECHO_partner.zpt').__of__(self)
1.1 casties 853: return pt()
854:
855:
1.13 dwinter 856: manage_addECHO_partnerForm=DTMLFile('dtml/ECHO_partnerAdd',globals(),
1.1 casties 857: Kind='ECHO_partner',kind='ECHO_partner')
858:
859:
860:
1.13 dwinter 861: def manage_addECHO_partner(self, id, file,url, title='', precondition='', content_type='',
1.1 casties 862: REQUEST=None):
863: """
864: Add a new ECHO_partner object.
865:
866: Creates a new ECHO_partner object 'id' with the contents of 'file'.
867: Based on Image.manage_addImage
868: """
869:
870: id=str(id)
871: title=str(title)
872: content_type=str(content_type)
873: precondition=str(precondition)
874:
875: id, title = OFS.Image.cookId(id, title, file)
876:
877: self=self.this()
878:
879: # First, we create the image without data:
880: self._setObject(id, ECHO_partner(id,title,url,'',content_type, precondition))
881:
882: # Now we "upload" the data. By doing this in two steps, we
883: # can use a database trick to make the upload more efficient.
884: if file:
885: self._getOb(id).manage_upload(file)
886: if content_type:
887: self._getOb(id).content_type=content_type
888:
889: if REQUEST is not None:
890: try: url=self.DestinationURL()
891: except: url=REQUEST['URL1']
892: REQUEST.RESPONSE.redirect('%s/manage_main' % url)
893: return id
894:
895:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>