--- ECHO_content/ECHO_collection.py 2008/12/04 21:27:00 1.299
+++ ECHO_content/ECHO_collection.py 2012/01/18 16:57:00 1.310.2.5
@@ -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.
@@ -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,20 +36,25 @@ 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
+from Acquisition import aq_parent
+try:
+ from Products.MetaDataProvider.MetaDataClient import MetaDataClient
+except:
+ print "no metadataclient"
import urllib
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
@@ -103,6 +104,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 +378,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()
@@ -692,11 +694,64 @@ 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 getHierCrumbs(self):
+ """returns a list of hierarchical breadcrumbs from self to the ECHO_root"""
+ # crumb for this object
+ crumb = {'obj': self,
+ 'url': self.absolute_url(),
+ 'label': self.getLabel()}
+ crumbs = [crumb]
+ # call the parent's method recursively
+ parent = aq_parent(self)
+ if hasattr(parent, 'getHierCrumbs'):
+ if self.title:
+ return parent.getHierCrumbs() + crumbs
+ else:
+ # if there's no title, skip this level
+ return parent.getHierCrumbs()
+
+ return crumbs
+
+
def exportImportObjects_html(self,RESPONSE):
"""ImportObject"""
@@ -718,7 +773,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 +784,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 """
Done