--- ECHO_content/ECHO_collection.py 2008/12/17 12:12:26 1.301
+++ ECHO_content/ECHO_collection.py 2010/10/13 13:10:19 1.310
@@ -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.
@@ -57,6 +57,7 @@ import Ft.Xml.XPath
import cStringIO
import sys
+import logging
try:
from psycopg import libpq
@@ -106,6 +107,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"""
@@ -379,7 +381,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()
@@ -700,6 +702,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"""
@@ -721,7 +756,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)
@@ -732,8 +767,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 """