--- ECHO_content/ECHO_collection.py 2008/12/10 13:37:03 1.300
+++ ECHO_content/ECHO_collection.py 2012/01/04 13:23:00 1.314
@@ -1,4 +1,4 @@
-"""New version of the product started February, 8th. Without scientific classification, use content-type for further classification."""
+"""New version of the produc started February, 8th. Without scientific classification, use content-type for further classification."""
"""Echo collection provides the classes for the ECHO content web-site.
class ECHO_collection is the basis class for an ECHO collection.
@@ -21,6 +21,7 @@ import tempfile
import zipfile
import re
import os,shutil
+import traceback
import OFS.Image
from types import *
from OFS.Cache import Cacheable
@@ -40,7 +41,10 @@ from Globals import Persistent, package_
from Acquisition import Implicit
from Products.ZCatalog.CatalogPathAwareness import CatalogAware
from Products.ZCTextIndex.ZCTextIndex import manage_addLexicon
-from Products.MetaDataProvider.MetaDataClient import MetaDataClient
+try:
+ from Products.MetaDataProvider.MetaDataClient import MetaDataClient
+except:
+ print "no metadataclient"
import urllib
import urllib2
import cgi
@@ -54,6 +58,7 @@ import Ft.Xml.XPath
import cStringIO
import sys
+import logging
try:
from psycopg import libpq
@@ -103,6 +108,7 @@ def setECHO_collectionInformation(self,t
self.weight=weight
import ECHO_resource
+from ECHO_resource import manage_addECHO_resource
class ECHO_resource(ECHO_resource.ECHO_resource):
"""depricated use class in ECHO_resource.py"""
@@ -376,7 +382,7 @@ class ECHO_fullText(ZopePageTemplate,ECH
try:
dom=xml.dom.minidom.parseString(self())
except:
- dom=xml.dom.minidom.parseString(self().encode('latin-1'))
+ dom=xml.dom.minidom.parseString(self.utf8ify(self()))
pages=dom.getElementsByTagName('page')
return pages[int(nr)-1].toxml()
@@ -697,6 +703,39 @@ class ECHO_collection(CatalogAware, Fold
path="/mpiwg/online/permanent/shipbuilding"
+ def getSection(self, crumbs=None):
+ """returns the current section name"""
+ # use breadcrumbs if available
+ if crumbs is not None and len(crumbs) > 0:
+ return crumbs[0][2].getId()
+
+ p = self
+
+ sec = None
+ # descend parents to the root (and remember the last id)
+ while p is not None and p.meta_type != 'ECHO_root' and p.meta_type!='ECHO_main' and p.meta_type!='ECHO_nav':
+ sec = p.getId()
+ p = p.aq_parent
+
+ return sec
+
+ def getSubSection(self, crumbs=None):
+ """returns the current subsection name"""
+ # use breadcrumbs if available
+ if crumbs is not None and len(crumbs) > 1:
+ return crumbs[1][2].getId()
+
+ p = self
+ sec = None
+ subsec = None
+ # descend parents to the root (and remember the last id)
+ while p is not None and p.meta_type != 'ECHO_root' and p.meta_type!='ECHO_main' and p.meta_type!='ECHO_nav':
+ subsec = sec
+ sec = p.getId()
+ p = p.aq_parent
+
+ return subsec
+
def exportImportObjects_html(self,RESPONSE):
"""ImportObject"""
@@ -718,7 +757,7 @@ class ECHO_collection(CatalogAware, Fold
ret=None
for name in zf.namelist():
- fn=tempfile.mkstemp()[1]
+ ds,fn=tempfile.mkstemp()
tf=file(fn,"w")
x=zf.read(name)
tf.write(x)
@@ -729,8 +768,11 @@ class ECHO_collection(CatalogAware, Fold
if not ret:
ret=""
ret+="Cannot import: %s (Already existing?)
"%name
+ os.close(ds)
os.remove(fn)
-
+
+ zf.close()
+
if ret:
return """
OK: %s"%resource[0]) - else: - if RESPONSE is not None: - RESPONSE.write("
ERROR: %s (%s)"%(resource[1].absolute_url()+'/ECHO_resource_config_main',resource[0],msg)) + resource[1].newViewer=newViewer; + +# done,msg=resource[1].changeViewer(newViewer) +# if done: +# if RESPONSE is not None: +# RESPONSE.write("
OK: %s"%resource[0]) +# else: +# if RESPONSE is not None: +# RESPONSE.write("
ERROR: %s (%s)"%(resource[1].absolute_url()+'/ECHO_resource_config_main',resource[0],msg)) if RESPONSE is not None: RESPONSE.write("
Done
") - def changeViewerTemplateSets(self,project,xslt,thumbtemplate,topbar,digiLibTemplate,digiliburlprefix,RESPONSE=None): - """change the templates""" - - resources=self.ZopeFind(self,obj_metatypes=['ECHO_resource'],search_sub=1) - - for resource in resources: - - resource[1].changeViewerTemplateSet(project,xslt,thumbtemplate,topbar,digiLibTemplate,digiliburlprefix) - - if RESPONSE is not None: - RESPONSE.redirect('manage_main') - def setStartpageFolderForm(self): """Form for changing the startpage""" @@ -1384,6 +1486,8 @@ class ECHO_collection(CatalogAware, Fold {'label':'Main Config','action':'ECHO_collection_config'}, {'label':'Change Labels','action':'changeLabels'}, {'label':'Change Titles','action':'changeTitles'}, + {'label':'Change MetaLinks','action':'changeMetaLinks'}, + {'label':'Change Image Viewer','action':'changeViewerTemplateSetsForm'}, {'label':'Localize','action':'localizeObjects'}, {'label':'Change Weights','action':'changeWeights'}, {'label':'Rerender Labels and Titles','action':'ECHO_rerenderLinksMDWarning'}, @@ -1391,7 +1495,6 @@ class ECHO_collection(CatalogAware, Fold {'label':'Graphic Coords','action':'ECHO_graphicEntry'}, {'label':'create resources from XML','action':'createRessourcesFromXMLForm'}, {'label':'Set Startpage','action':'setStartpageFolderForm'}, - {'label':'Change Viewer Templates and Image Viewer','action':'changeViewerTemplateSetsForm'}, {'label':'Reload Metadata','action':'reloadMetaDataFromStorageWarning'}, {'label':'ImportCollection','action':'importCollection'}, {'label':'Copy MD for indexing and search','action':'copySearchFields'}, @@ -1422,7 +1525,7 @@ class ECHO_collection(CatalogAware, Fold 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="",location=None,isAlwaysClickable=None,prefix="",suffix="",isVisible=True): + 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,prefix="",suffix="",isVisible=True,fullTextBasisUrl=None): """Aenderung der Properties""" self.secondaryLink=secondaryLink @@ -1434,6 +1537,7 @@ class ECHO_collection(CatalogAware, Fold self.prefix=prefix[0:] self.suffix=suffix[0:] self.setIsVisible(isVisible) + self.fullTextBasisUrl=fullTextBasisUrl setECHO_collectionInformation(self,title,label,description,contentType,responsible,credits,weight) @@ -1442,6 +1546,9 @@ class ECHO_collection(CatalogAware, Fold if RESPONSE is not None: RESPONSE.redirect('manage_main') + def getFullTextBasisUrl(self): + return self.fullTextBasisUrl + def setAlwaysClickable(self,flag="yes"): """set clickable""" if flag=="yes": @@ -1453,8 +1560,15 @@ class ECHO_collection(CatalogAware, Fold def showOverview(self): """overview""" + # ECHO_overview.html template for this instance if 'ECHO_overview.html' in self.__dict__.keys(): return getattr(self,'ECHO_overview.html')() + + # ECHO_overview_main template in path + if hasattr(self, 'ECHO_overview_main'): + return getattr(self, 'ECHO_overview_main')() + + # template from product pt=zptFile(self, 'zpt/ECHO_content_overview.zpt') return pt() @@ -1607,17 +1721,17 @@ class ECHO_group(ECHO_collection): if not urn: urn=self.absolute_url() - li="""