Diff for /MPIWGWeb/Attic/MPIWGHelper.py between versions 1.1.2.8 and 1.1.2.11

version 1.1.2.8, 2009/04/16 15:55:19 version 1.1.2.11, 2010/07/23 17:30:38
Line 1 Line 1
 from types import *  from Products.PageTemplates.PageTemplateFile import PageTemplateFile
   
 import logging  import logging
   
 definedFields=['WEB_title','xdata_01','xdata_02','xdata_03','xdata_04','xdata_05','xdata_06','xdata_07','xdata_08','xdata_09','xdata_10','xdata_11','xdata_12','xdata_13','WEB_project_header','WEB_project_description','WEB_related_pub']  definedFields=['WEB_title','xdata_01','xdata_02','xdata_03','xdata_04','xdata_05','xdata_06','xdata_07','xdata_08','xdata_09','xdata_10','xdata_11','xdata_12','xdata_13','WEB_project_header','WEB_project_description','WEB_related_pub']
   
 checkFields = ['xdata_01']  checkFields = ['xdata_01']
Line 20  def getTextFromNode(nodename): Line 22  def getTextFromNode(nodename):
   
 def getTemplate(self, tpName):  def getTemplate(self, tpName):
     """get a template file either form the instance or from the product"""      """get a template file either form the instance or from the product"""
     ext=self.ZopeFind(self.aq_parent,obj_ids=[tpName])      #ext=self.ZopeFind(self.aq_parent,obj_ids=[tpName])
     if ext:      if hasattr(self,tpName):
         pt = getattr(self,ext[0][1].getId())          pt = getattr(self,tpName)
     else:      else:
         pt=PageTemplateFile(os.path.join(package_home(globals()), 'zpt/'+tpName)).__of__(self)          pt=PageTemplateFile('zpt/'+tpName, globals()).__of__(self)
     assert(pt)      assert(pt)
     return pt      return pt
   
Line 84  def sortI(x,y): Line 86  def sortI(x,y):
         return cmp(x[1],y[1])          return cmp(x[1],y[1])
   
   
 def unicodify(str):  def unicodify(s):
     """decode str (utf-8 or latin-1 representation) into unicode object"""      """decode str (utf-8 or latin-1 representation) into unicode object"""
     #logging.error("unicodify: %s"%str)      if not s:
     if not str:          return u""
         return ""      if isinstance(s, str):
     if type(str) is StringType:  
         try:          try:
             return str.decode('utf-8')              return s.decode('utf-8')
         except:          except:
             return str.decode('latin-1')              return s.decode('latin-1')
     else:      else:
         return str          return s
   
 def utf8ify(str):  def utf8ify(s):
     """encode unicode object or string into byte string in utf-8 representation"""      """encode unicode object or string into byte string in utf-8 representation.
     if not str:         assumes string objects to be utf-8"""
       if not s:
         return ""          return ""
     if type(str) is StringType:      if isinstance(s, str):
         return str          return s
     else:      else:
         return str.encode('utf-8')          return s.encode('utf-8')
   
   
 def shortenString(s, l, ellipsis='...'):  def shortenString(s, l, ellipsis='...'):
Line 130  def getBreadcrumbs(self): Line 132  def getBreadcrumbs(self):
     return crumbs      return crumbs
   
   
 def getSection(self):  def getSection(self, crumbs=None):
     """returns the current section name"""      """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      p = self
     sec = None      sec = None
     # descend parents to the root (and remember the last id)      # descend parents to the root (and remember the last id)
Line 141  def getSection(self): Line 147  def getSection(self):
           
     return sec      return sec
   
 def getSubSection(self):  def getSubSection(self, crumbs=None):
     """returns the current subsection name"""      """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      p = self
     sec = None      sec = None
     subsec = None      subsec = None

Removed from v.1.1.2.8  
changed lines
  Added in v.1.1.2.11


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>