|
|
| version 1.204, 2005/01/21 16:28:58 | version 1.216, 2005/02/28 20:02:08 |
|---|---|
| Line 1 | Line 1 |
| """New version of the product started February, 8th. Without scientific classification, use content-type for further classification.""" | """New version of the product started February, 8th. Without scientific classification, use content-type for further classification.""" |
| """Echo collection provides the classes for the ECHO content web-site. | """Echo collection provides the classes for the ECHO content web-site. |
| Line 153 class ECHO_layoutTemplate(ZopePageTempla | Line 154 class ECHO_layoutTemplate(ZopePageTempla |
| self.ZBindings_edit(self._default_bindings) | self.ZBindings_edit(self._default_bindings) |
| if text is None: | if text is None: |
| self._default_content_fn = os.path.join(package_home(globals()), | self._default_content_fn = os.path.join(package_home(globals()),'zpt','ECHO_%s_template_standard.zpt'%EchoType) |
| 'zpt/ECHO_%s_template_standard.zpt'%EchoType) | |
| text = open(self._default_content_fn).read() | text = open(self._default_content_fn).read() |
| self.pt_edit(text, content_type) | self.pt_edit(text, content_type) |
| Line 212 class ECHO_fullText(ZopePageTemplate,ECH | Line 212 class ECHO_fullText(ZopePageTemplate,ECH |
| def getPage(self,nr='1'): | def getPage(self,nr='1'): |
| """get page n""" | """get page n""" |
| dom=xml.dom.minidom.parseString(self()) | #return self().encode('latin-1','ignore') |
| dom=xml.dom.minidom.parseString(self().encode('utf-8','ignore')) | |
| pages=dom.getElementsByTagName('page') | pages=dom.getElementsByTagName('page') |
| return pages[int(nr)-1].toxml('utf-8') | return pages[int(nr)-1].toxml() |
| # Product registration and Add support | # Product registration and Add support |
| manage_addECHO_fullTextForm = PageTemplateFile( | manage_addECHO_fullTextForm = PageTemplateFile( |
| Line 561 class ECHO_resource(Folder,Persistent,EC | Line 562 class ECHO_resource(Folder,Persistent,EC |
| startpage=self.createImageUrl() | startpage=self.createImageUrl() |
| params="startpage=%s"%startpage | params="startpage=%s"%startpage |
| print 'http://xserve02.mpiwg-berlin.mpg.de:18880/echo_nav/storage/downloadExternalXML?index_meta_url=%s&xml_url=%s'%(self.metalink,self.absolute_url()+'/newMetaXML'+urllib.quote('?'+params)) | #print 'http://xserve02.mpiwg-berlin.mpg.de:18880/echo_nav/storage/downloadExternalXML?index_meta_url=%s&xml_url=%s'%(self.metalink,self.absolute_url()+'/newMetaXML'+urllib.quote('?'+params)) |
| ECHO_helpers.urlopen('http://xserve02.mpiwg-berlin.mpg.de:18880/echo_nav/storage/downloadExternalXML?index_meta_url=%s&xml_url=%s'%(self.metalink,self.absolute_url()+'/newMetaXML'+urllib.quote('?'+params))).read() | ECHO_helpers.urlopen('http://xserve02.mpiwg-berlin.mpg.de:18880/echo_nav/storage/downloadExternalXML?index_meta_url=%s&xml_url=%s'%(self.metalink,self.absolute_url()+'/newMetaXML'+urllib.quote('?'+params))).read() |
| Line 655 class ECHO_resource(Folder,Persistent,EC | Line 656 class ECHO_resource(Folder,Persistent,EC |
| security.declarePublic('content_html') | |
| def content_html(self): | def content_html(self): |
| """template fuer content""" | """template fuer content""" |
| return ECHO_basis.content_html(self,'resource') | return ECHO_basis.content_html(self,'resource') |
| Line 968 class ECHO_resource(Folder,Persistent,EC | Line 969 class ECHO_resource(Folder,Persistent,EC |
| def getMDValue(self,fieldName,empty=None): | def getMDValue(self,fieldName,empty=None): |
| if empty: | if not empty: |
| return self.metaDataHash.get(fieldName,'!!NOT USED HERE in Type: %s'%self.contentType) | return self.metaDataHash.get(fieldName,'!!NOT USED HERE in Type: %s'%self.contentType) |
| else: | else: |
| Line 1065 class ECHO_resource(Folder,Persistent,EC | Line 1066 class ECHO_resource(Folder,Persistent,EC |
| if ret == "": | if ret == "": |
| return None | return None |
| else: | else: |
| return ret | return ret |
| except: | except: |
| return None | return None |
| Line 1304 def manage_addECHO_resourceForm(self): | Line 1306 def manage_addECHO_resourceForm(self): |
| def manage_addECHO_resource(self,id,title,label,description,responsible,link,metalink,weight,copyrightType=None,resourceID=None,contentType=None,renderingType=None,credits=None,coords=None,RESPONSE=None): | def manage_addECHO_resource(self,id,title,label,description="",responsible="",link="",metalink="",weight="",copyrightType=None,resourceID=None,contentType=None,renderingType=None,credits=None,coords=None,RESPONSE=None): |
| """addaresource""" | """addaresource""" |
| newObj=ECHO_resource(id,link,metalink,resourceID,title,label,description,contentType,renderingType,copyrightType,responsible,credits,weight,coords) | newObj=ECHO_resource(id,link,metalink,resourceID,title,label,description,contentType,renderingType,copyrightType,responsible,credits,weight,coords) |
| Line 1320 class ECHO_externalLink(Folder,ECHO_basi | Line 1322 class ECHO_externalLink(Folder,ECHO_basi |
| security=ClassSecurityInfo() | security=ClassSecurityInfo() |
| meta_type='ECHO_externalLink' | meta_type='ECHO_externalLink' |
| security.declarePublic('content_html') | |
| def content_html(self): | def content_html(self): |
| """template fuer content""" | """template fuer content""" |
| return ECHO_basis.content_html(self,'externalLink') | return ECHO_basis.content_html(self,'externalLink') |
| Line 1410 def manage_addECHO_linkForm(self): | Line 1412 def manage_addECHO_linkForm(self): |
| return pt() | return pt() |
| def manage_addECHO_link(self,id,title,label,description,contentType,responsible,link,weight,coords=None,credits=None,RESPONSE=None): | def manage_addECHO_link(self,id,title,label,description="",contentType="",responsible="",link="",weight="",coords=[],credits=None,RESPONSE=None): |
| """Add an external Link""" | """Add an external Link""" |
| newObj=ECHO_link(id,link,title,label,description,contentType,responsible,credits,weight,coords) | newObj=ECHO_link(id,link,title,label,description,contentType,responsible,credits,weight,coords) |
| Line 1765 class ECHO_collection(Folder, Persistent | Line 1767 class ECHO_collection(Folder, Persistent |
| manage_addECHO_resource(self,id,label.encode('ascii'),label.encode('ascii'),"","","",link.encode('ascii'),"","") | manage_addECHO_resource(self,id,label.encode('ascii'),label.encode('ascii'),"","","",link.encode('ascii'),"","") |
| return ret | return ret |
| security.declarePublic('getImageTag') | |
| def getImageTag(self): | def getImageTag(self): |
| """GetTag""" | """GetTag""" |
| try: | try: |
| Line 1794 class ECHO_collection(Folder, Persistent | Line 1797 class ECHO_collection(Folder, Persistent |
| except: | except: |
| return "" | return "" |
| def getCollectionTreeXML(self): | def getCollectionTreeXML(self,pwstr=None): |
| """Tree as XML""" | """Tree as XML""" |
| def addPassWd(str): | def addPassWd(str,pwstr=None): |
| """adds a user/passwd to an url""" | """adds a user/passwd to an url""" |
| if pwstr: | |
| txt2=re.sub(r"(http://)(.*?)","\g<1>%s@\g<2>"%pwstr,str) | |
| else: | |
| txt2=re.sub(r"(http://)(.*?)","\g<1>www:3333@\g<2>",str) | txt2=re.sub(r"(http://)(.*?)","\g<1>www:3333@\g<2>",str) |
| return txt2 | return txt2 |
| def getCollection(object,depth=0): | def getCollection(object,depth=0,pwstr=None): |
| depth+=1 | depth+=1 |
| collections="" | collections="" |
| for entry in object.__dict__.keys(): | for entry in object.__dict__.keys(): |
| element=getattr(object,entry) | element=getattr(object,entry) |
| try: | try: |
| if element.meta_type in ["ECHO_collection","ECHO_group"]: | if element.meta_type in ["ECHO_collection","ECHO_group"]: |
| collections+="<element name=\""+urllib.quote(element.title)+"\" url=\""+addPassWd(element.absolute_url())+"\">" | collections+="<element name=\""+urllib.quote(element.title)+"\" url=\""+addPassWd(element.absolute_url(),pwstr=pwstr)+"\">" |
| collections+=getCollection(element,depth)+"</element>\n" | collections+=getCollection(element,depth)+"</element>\n" |
| except: | except: |
| """nothing""" | """nothing""" |
| return collections | return collections |
| ret="""<?xml version="1.0" encoding="utf-8" ?>""" | ret="""<?xml version="1.0" encoding="utf-8" ?>""" |
| return ret+"<collection>"+getCollection(self)+"</collection>" | return ret+"<collection>"+getCollection(self,pwstr=pwstr)+"</collection>" |
| def createAllJSAreas(self): | def createAllJSAreas(self): |
| """create area calls for JavaScript""" | """create area calls for JavaScript""" |
| Line 1865 class ECHO_collection(Folder, Persistent | Line 1871 class ECHO_collection(Folder, Persistent |
| return ECHO_rerenderLinksMD(self,obj,types) | return ECHO_rerenderLinksMD(self,obj,types) |
| def __init__(self,id,title,label,description,contentType,responsible,credits,weight,sortfield,coords,secondaryLinkTitle,secondaryLink,imageTag="",bgcolour=""): | def __init__(self,id,title,label,description="",contentType="",responsible="",credits="",weight="",sortfield="",coords=[],secondaryLinkTitle="",secondaryLink="",imageTag="",bgcolour=""): |
| self.id = id | self.id = id |
| """Festlegen der ID""" | """Festlegen der ID""" |
| Line 1976 class ECHO_collection(Folder, Persistent | Line 1982 class ECHO_collection(Folder, Persistent |
| elif hasattr(self,'collection_index_template'): | elif hasattr(self,'collection_index_template'): |
| ret=self.collection_index_template() | ret=self.collection_index_template() |
| elif hasattr(self,'main_index_template'): | elif hasattr(self,'main_index_template'): |
| ret=self.main_index_template() | |
| ret=self.main_index_template.__of__(self)(self.main_template) | |
| else: | else: |
| pt=zptFile(self, 'zpt/ECHO_main_index_template_standard.zpt') | pt=zptFile(self, 'zpt/ECHO_main_index_template_standard.zpt') |
| pt.content_type="text/html" | pt.content_type="text/html" |
| Line 1985 class ECHO_collection(Folder, Persistent | Line 1992 class ECHO_collection(Folder, Persistent |
| self.ZCacheable_set(ret) | self.ZCacheable_set(ret) |
| return ret | return ret |
| security.declarePublic('content_html') | |
| def content_html(self,**argv): | def content_html(self,**argv): |
| """template fuer content""" | """template fuer content""" |
| #print "NN",argv | #print "NN",argv |
| Line 2029 class ECHO_collection(Folder, Persistent | Line 2037 class ECHO_collection(Folder, Persistent |
| """Give list of coordinates""" | """Give list of coordinates""" |
| mapColTypes=['ECHO_collection','ECHO_resource'] | mapColTypes=['ECHO_collection','ECHO_resource'] |
| areas=[] | areas=[] |
| for entry in self.getSubCols(self,subColTypes=mapColTypes): | for entry in self.getSubCols(subColTypes=mapColTypes): |
| object=entry | object=entry |
| areas.extend(object.getMapAreas()) | areas.extend(object.getMapAreas()) |
| return areas | return areas |
| Line 2056 def manage_addECHO_collectionForm(self): | Line 2064 def manage_addECHO_collectionForm(self): |
| return pt() | return pt() |
| def manage_addECHO_collection(self,id,title,label,description,contentType,responsible,weight,sortfield,coords="",secondaryLinkTitle="",secondaryLink="",credits=None,RESPONSE=None,imageTag="",bgcolour=""): | def manage_addECHO_collection(self,id,title,label,description="",contentType="",responsible="",weight=0,sortfield="weight",coords="",secondaryLinkTitle="",secondaryLink="",credits=None,RESPONSE=None,imageTag="",bgcolour=""): |
| """add a echo collection""" | """add a echo collection""" |
| Line 2164 class ECHO_group(ECHO_collection): | Line 2172 class ECHO_group(ECHO_collection): |
| except: | except: |
| return "ECHO_groups" | return "ECHO_groups" |
| security.declarePublic('content_html') | |
| def content_html(self): | def content_html(self): |
| """template fuer content""" | """template fuer content""" |
| return ECHO_basis.content_html(self,'group') | return ECHO_basis.content_html(self,'group') |
| Line 2345 class ECHO_root(Folder,Persistent,Implic | Line 2354 class ECHO_root(Folder,Persistent,Implic |
| meta_type="ECHO_root" | meta_type="ECHO_root" |
| def printer(self,txt): | |
| print txt | |
| print txt[2] | |
| print txt[2].getImageTag() | |
| print "HO" | |
| return txt[2].getImageTag() | |
| def printer2(self,txt): | |
| print txt | |
| def item2(self,txt): | |
| return txt[2] | |
| def getContentOverviewTemplate(self): | def getContentOverviewTemplate(self): |
| """produces overview template with macro""" | """produces overview template with macro""" |
| pt = zptObjectOrFile(self, 'content_overview_template') | pt = zptObjectOrFile(self, 'content_overview_template') |
| Line 2370 class ECHO_root(Folder,Persistent,Implic | Line 2393 class ECHO_root(Folder,Persistent,Implic |
| def checkResource(self,id): | def checkResource(self,id): |
| """checks if a resource is in the tree, gives back none or list of resources""" | """checks if a resource is in the tree, gives back none or list of resources""" |
| if not id: | |
| id="" | |
| splitted=id.split("/") | |
| id=splitted[len(splitted)-1] | |
| if hasattr(self,"_v_checkResource") and self._v_checkResource.has_key(id): #existiert ein cache und id ist bereits drin? | if hasattr(self,"_v_checkResource") and self._v_checkResource.has_key(id): #existiert ein cache und id ist bereits drin? |
| return self._v_checkResource[id] | return self._v_checkResource[id] |
| Line 2591 class ECHO_root(Folder,Persistent,Implic | Line 2618 class ECHO_root(Folder,Persistent,Implic |
| except: | except: |
| return "" | return "" |
| security.declarePublic('getImageTag') | |
| def getImageTag(self): | def getImageTag(self): |
| """needed by main_template""" | """needed by main_template""" |
| return "" | return "" |
| secondaryLink="" #needed by main_template | secondaryLink="" #needed by main_template |
| secondaryLinkTitle="" #needed by main_template | secondaryLinkTitle="" #needed by main_template |
| Line 2871 class ECHO_root(Folder,Persistent,Implic | Line 2900 class ECHO_root(Folder,Persistent,Implic |
| if self.checkRef(ref): | if self.checkRef(ref): |
| if pn: | if pn: |
| link.setAttribute("href",self.aq_parent.absolute_url()+"/references?id="+ref+"&p="+pn) | link.setAttribute("href",self.aq_parent.absolute_url()+"/references?id="+ref+"&page="+pn) |
| else: | else: |
| link.setAttribute("href",self.aq_parent.absolute_url()+"/references?id="+ref) | link.setAttribute("href",self.aq_parent.absolute_url()+"/references?id="+ref) |