--- ECHO_content/ECHO_collection.py 2004/12/10 13:48:13 1.201
+++ ECHO_content/ECHO_collection.py 2005/02/28 20:02:08 1.216
@@ -1,3 +1,4 @@
+
"""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.
@@ -74,7 +75,7 @@ regexpPage = re.compile(patternPage, re.
-def setECHO_collectionInformation(self,title,label,description,contentType,responsible,credits,weight,coordstrs="",viewClassification=""):
+def setECHO_collectionInformation(self,title,label,description,contentType,responsible,credits,weight,coordstrs=""):
"""Allegemeine Informationen zu einer ECHO Collection"""
@@ -153,8 +154,7 @@ class ECHO_layoutTemplate(ZopePageTempla
self.ZBindings_edit(self._default_bindings)
if text is None:
- self._default_content_fn = os.path.join(package_home(globals()),
- 'zpt/ECHO_%s_template_standard.zpt'%EchoType)
+ self._default_content_fn = os.path.join(package_home(globals()),'zpt','ECHO_%s_template_standard.zpt'%EchoType)
text = open(self._default_content_fn).read()
self.pt_edit(text, content_type)
@@ -212,10 +212,11 @@ class ECHO_fullText(ZopePageTemplate,ECH
def getPage(self,nr='1'):
"""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')
- return pages[int(nr)-1].toxml('utf-8')
+ return pages[int(nr)-1].toxml()
# Product registration and Add support
manage_addECHO_fullTextForm = PageTemplateFile(
@@ -258,7 +259,7 @@ class ECHO_resource(Folder,Persistent,EC
security=ClassSecurityInfo()
meta_type='ECHO_resource'
- viewClassificationList=viewClassificationListMaster
+# viewClassificationList=viewClassificationListMaster
getSubCols = ECHO_helpers.getSubCols
@@ -561,7 +562,7 @@ class ECHO_resource(Folder,Persistent,EC
startpage=self.createImageUrl()
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()
@@ -655,16 +656,16 @@ class ECHO_resource(Folder,Persistent,EC
-
+ security.declarePublic('content_html')
def content_html(self):
"""template fuer content"""
return ECHO_basis.content_html(self,'resource')
- def getViewClassification(self):
- if hasattr(self,'viewClassification'):
- return self.viewClassification
- else:
- return ""
+# def getViewClassification(self):
+# if hasattr(self,'viewClassification'):
+# return self.viewClassification
+# else:
+# return ""
def getFullTextXML(self,noredirect=None):
"""getFullTextXML; gives the FullText as an XML Document, and if somthing goes wrong."""
@@ -818,7 +819,7 @@ class ECHO_resource(Folder,Persistent,EC
coordsnew=[]
self.coords=coordsnew
- self.viewClassification=""
+# self.viewClassification=""
@@ -968,7 +969,7 @@ class ECHO_resource(Folder,Persistent,EC
def getMDValue(self,fieldName,empty=None):
- if empty:
+ if not empty:
return self.metaDataHash.get(fieldName,'!!NOT USED HERE in Type: %s'%self.contentType)
else:
@@ -1000,7 +1001,7 @@ class ECHO_resource(Folder,Persistent,EC
self.REQUEST.RESPONSE.setHeader('Content-Type','text/xml')
return writeMetadata(self.metalink,self.metaDataHash)
- def changeECHO_resource(self,metalink,link,title,label,description,contentType,responsible,weight,viewClassification="",coords=None,credits=None,RESPONSE=None):
+ def changeECHO_resource(self,metalink,link,title,label,description,contentType,responsible,weight,coords=None,credits=None,RESPONSE=None):
"""Aenderung der Properties"""
setECHO_collectionInformation(self,title,label,description,contentType,responsible,credits,weight)
@@ -1065,7 +1066,8 @@ class ECHO_resource(Folder,Persistent,EC
if ret == "":
return None
else:
- return ret
+
+ return ret
except:
return None
@@ -1102,7 +1104,9 @@ class ECHO_resource(Folder,Persistent,EC
retdata={}
fields=[]
fieldlist=self.standardMD.fieldList
-
+
+ tags=self.findTagsFromMapping(self.contentType)
+ self.referencetypes=tags[2]
for referenceTypeF in self.referencetypes:
if referenceTypeF[1].title.lower() == referenceType.lower():
@@ -1302,7 +1306,7 @@ 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"""
newObj=ECHO_resource(id,link,metalink,resourceID,title,label,description,contentType,renderingType,copyrightType,responsible,credits,weight,coords)
@@ -1318,7 +1322,7 @@ class ECHO_externalLink(Folder,ECHO_basi
security=ClassSecurityInfo()
meta_type='ECHO_externalLink'
-
+ security.declarePublic('content_html')
def content_html(self):
"""template fuer content"""
return ECHO_basis.content_html(self,'externalLink')
@@ -1394,7 +1398,7 @@ class ECHO_link(ECHO_externalLink):
meta_type="ECHO_link"
-
+
def content_html(self):
"""template fuer link"""
if hasattr(self,"link_template"):
@@ -1408,7 +1412,7 @@ def manage_addECHO_linkForm(self):
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"""
newObj=ECHO_link(id,link,title,label,description,contentType,responsible,credits,weight,coords)
@@ -1424,7 +1428,7 @@ class ECHO_collection(Folder, Persistent
security=ClassSecurityInfo()
meta_type='ECHO_collection'
- viewClassificationList=viewClassificationListMaster
+# viewClassificationList=viewClassificationListMaster
displayTypes=displayTypes
path="/mpiwg/online/permanent/shipbuilding"
@@ -1736,11 +1740,11 @@ class ECHO_collection(Folder, Persistent
"""nothing"""
return retStr
- def getViewClassification(self):
- if hasattr(self,'viewClassification'):
- return self.viewClassification
- else:
- return ""
+# def getViewClassification(self):
+# if hasattr(self,'viewClassification'):
+# return self.viewClassification
+# else:
+# return ""
def createRessourcesFromXMLForm(self):
@@ -1762,7 +1766,8 @@ class ECHO_collection(Folder, Persistent
ret+="
"+label+"
"
manage_addECHO_resource(self,id,label.encode('ascii'),label.encode('ascii'),"","","",link.encode('ascii'),"","")
return ret
-
+
+ security.declarePublic('getImageTag')
def getImageTag(self):
"""GetTag"""
try:
@@ -1792,29 +1797,32 @@ class ECHO_collection(Folder, Persistent
except:
return ""
- def getCollectionTreeXML(self):
+ def getCollectionTreeXML(self,pwstr=None):
"""Tree as XML"""
- def addPassWd(str):
+ def addPassWd(str,pwstr=None):
"""adds a user/passwd to an url"""
- txt2=re.sub(r"(http://)(.*?)","\g<1>www:3333@\g<2>",str)
+ 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)
return txt2
- def getCollection(object,depth=0):
+ def getCollection(object,depth=0,pwstr=None):
depth+=1
collections=""
for entry in object.__dict__.keys():
element=getattr(object,entry)
try:
if element.meta_type in ["ECHO_collection","ECHO_group"]:
- collections+=""
+ collections+=""
collections+=getCollection(element,depth)+"\n"
except:
"""nothing"""
return collections
ret=""""""
- return ret+""+getCollection(self)+""
+ return ret+""+getCollection(self,pwstr=pwstr)+""
def createAllJSAreas(self):
"""create area calls for JavaScript"""
@@ -1863,7 +1871,7 @@ class ECHO_collection(Folder, Persistent
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
"""Festlegen der ID"""
@@ -1922,7 +1930,7 @@ class ECHO_collection(Folder, Persistent
security.declarePublic('changeECHO_collection')
- def changeECHO_collection(self,title,label,description,contentType,responsible,weight,secondaryLink,secondaryLinkTitle,credits=None,sortfield="weight",coords=None,RESPONSE=None,imageTag="",bgcolour="",viewClassification=None,location=None,isAlwaysClickable=None):
+ def changeECHO_collection(self,title,label,description,contentType,responsible,weight,secondaryLink,secondaryLinkTitle,credits=None,sortfield="weight",coords=None,RESPONSE=None,imageTag="",bgcolour="",location=None,isAlwaysClickable=None):
"""Aenderung der Properties"""
self.secondaryLink=secondaryLink
@@ -1974,7 +1982,8 @@ class ECHO_collection(Folder, Persistent
elif hasattr(self,'collection_index_template'):
ret=self.collection_index_template()
elif hasattr(self,'main_index_template'):
- ret=self.main_index_template()
+
+ ret=self.main_index_template.__of__(self)(self.main_template)
else:
pt=zptFile(self, 'zpt/ECHO_main_index_template_standard.zpt')
pt.content_type="text/html"
@@ -1983,6 +1992,7 @@ class ECHO_collection(Folder, Persistent
self.ZCacheable_set(ret)
return ret
+ security.declarePublic('content_html')
def content_html(self,**argv):
"""template fuer content"""
#print "NN",argv
@@ -2025,10 +2035,10 @@ class ECHO_collection(Folder, Persistent
def getAllMapAreas(self):
"""Give list of coordinates"""
- subColTypes=['ECHO_collection','ECHO_resource']
+ mapColTypes=['ECHO_collection','ECHO_resource']
areas=[]
- for entrySearch in self.ZopeFind(self,obj_metatypes=subColTypes):
- object=entrySearch[1]
+ for entry in self.getSubCols(subColTypes=mapColTypes):
+ object=entry
areas.extend(object.getMapAreas())
return areas
@@ -2054,7 +2064,7 @@ def manage_addECHO_collectionForm(self):
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"""
@@ -2162,6 +2172,7 @@ class ECHO_group(ECHO_collection):
except:
return "ECHO_groups"
+ security.declarePublic('content_html')
def content_html(self):
"""template fuer content"""
return ECHO_basis.content_html(self,'group')
@@ -2343,12 +2354,26 @@ class ECHO_root(Folder,Persistent,Implic
meta_type="ECHO_root"
- def content_overview_main_t(self):
- """template for map overview page"""
- pt = zptFile(self, 'zpt/ECHO_content_overview_main')
+ 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):
+ """produces overview template with macro"""
+ pt = zptObjectOrFile(self, 'content_overview_template')
return pt
- ###CDLI adds -> have to be removed
+ ###Cdli adds -> have to be removed
def getTablet(self,item):
#print "getTablet"
try:
@@ -2368,6 +2393,10 @@ class ECHO_root(Folder,Persistent,Implic
def checkResource(self,id):
"""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?
return self._v_checkResource[id]
@@ -2588,10 +2617,12 @@ class ECHO_root(Folder,Persistent,Implic
return getattr(found,field).decode('ascii','ignore')
except:
return ""
-
+
+ security.declarePublic('getImageTag')
def getImageTag(self):
"""needed by main_template"""
return ""
+
secondaryLink="" #needed by main_template
secondaryLinkTitle="" #needed by main_template
@@ -2869,7 +2900,7 @@ class ECHO_root(Folder,Persistent,Implic
if self.checkRef(ref):
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:
link.setAttribute("href",self.aq_parent.absolute_url()+"/references?id="+ref)