--- ECHO_content/ECHO_collection.py 2010/02/15 19:03:28 1.308 +++ ECHO_content/ECHO_collection.py 2012/01/19 19:03:28 1.310.2.6 @@ -9,11 +9,7 @@ class ECHO_externalLink contains informa """ -try: - from reportlab.pdfgen import canvas - from reportlab.lib.pagesizes import A4 -except: - print "PDF generation will not work" + import urlparse import string @@ -40,6 +36,8 @@ from Globals import Persistent, package_ from Acquisition import Implicit from Products.ZCatalog.CatalogPathAwareness import CatalogAware from Products.ZCTextIndex.ZCTextIndex import manage_addLexicon +import ECHO_helpers +from Acquisition import aq_parent try: from Products.MetaDataProvider.MetaDataClient import MetaDataClient except: @@ -49,14 +47,15 @@ import urllib2 import cgi import smtplib import time -from Ft.Xml.Domlette import NonvalidatingReader -from Ft.Xml.Domlette import PrettyPrint, Print -from Ft.Xml import EMPTY_NAMESPACE - -import Ft.Xml.XPath +#from Ft.Xml.Domlette import NonvalidatingReader +#from Ft.Xml.Domlette import PrettyPrint, Print +#from Ft.Xml import EMPTY_NAMESPACE +# +#import Ft.Xml.XPath import cStringIO import sys +import logging try: from psycopg import libpq @@ -696,11 +695,54 @@ class ECHO_collection(CatalogAware, Fold meta_type='ECHO_collection' default_catalog='resourceCatalog' + rootMetaTypes = ['ECHO_root', 'ECHO_main', 'ECHO_nav'] + # viewClassificationList=viewClassificationListMaster displayTypes=displayTypes 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 not in self.rootMetaTypes: + sec = p.getId() + p = aq_parent(p.context) + + 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 not in self.rootMetaTypes: + subsec = sec + sec = p.getId() + p = aq_parent(p.context) + + return subsec + + + def getCrumb(self): + """returns breadcrumb for this object""" + return ECHO_helpers.getCrumb(self) + + def getHierCrumbs(self): + """returns a list of hierarchical breadcrumbs from self to the ECHO_root""" + return ECHO_helpers.getHierCrumbs(self) + def exportImportObjects_html(self,RESPONSE): """ImportObject""" @@ -1003,7 +1045,7 @@ class ECHO_collection(CatalogAware, Fold pass return ret - def importCollection(self,path=None,RESPONSE=None): + def importCollection(self,path=None,viewerUrl=None,metaDataUrl=None,replacePathPermanent=None,replacePathExperimental=None,RESPONSE=None): """liest verzeichnisse aus dem pfad und legt sie dann als objekte in den ordner""" if path is None: @@ -1016,15 +1058,20 @@ class ECHO_collection(CatalogAware, Fold if fileName: - tempPath=re.sub("/mpiwg/online","",path) - link="http://echo.mpiwg-berlin.mpg.de/zogilib_book?fn="+tempPath+"/"+fileName+"/pageimg" + if (replacePathExperimental and replacePathExperimental!=''): + path=re.sub(replacePathExperimental,"/mpiwg/online/experimental",path) + + if (replacePathPermanent and replacePathPermanent!=''): + path=re.sub(replacePathPermanent,"/mpiwg/online/permanent",path) + + link=viewerUrl%(path+"/"+fileName+"/pageimg") - metalink=self.path+"/"+fileName+"/index.meta" + metalink=metaDataUrl+"/"+path+"/"+fileName+"/index.meta" try: #link="http://nausikaa2.mpiwg-berlin.mpg.de/cgi-bin/toc/toc.x.cgi?dir="+fileName+"&step=thumb" - newObj=ECHO_resource(fileName,link,metalink,fileName,fileName,fileName,'generated','book','','','','','','') + newObj=ECHO_resource(fileName,link,metalink,fileName,fileName,fileName,'','book','','','','','','') self._setObject(fileName,newObj) genObj=getattr(self,fileName) @@ -1095,38 +1142,7 @@ class ECHO_collection(CatalogAware, Fold if RESPONSE is not None: RESPONSE.write("
Done