Diff for /ECHO_content/ECHO_helpers.py between versions 1.83 and 1.90

version 1.83, 2007/07/19 11:02:28 version 1.90, 2008/09/08 19:02:30
Line 17  import ECHO_collection Line 17  import ECHO_collection
 import base64  import base64
 import bz2  import bz2
 import xmlrpclib  import xmlrpclib
   import sys
 import logging  import logging
   
 #erstzt logging  #erstzt logging
Line 25  def logger(txt,method,txt2): Line 25  def logger(txt,method,txt2):
     """logging"""      """logging"""
     logging.info(txt+ txt2)      logging.info(txt+ txt2)
   
 displayTypes = ['ZSQLExtendFolder','ZSQLBibliography','ECHO_group','ECHO_collection','ECHO_resource','ECHO_link','ECHO_sqlElement','ECHO_pageTemplate','ECHO_externalLink','ImageCollectionIFrame','VLP_resource','VLP_essay','ECHO_ZCatalogElement','ImageCollection','versionedFileFolder','ECHO_movie']  displayTypes = ['ZSQLExtendFolder','ZSQLBibliography','ECHO_group','ECHO_collection','ECHO_resource','ECHO_link','ECHO_sqlElement','ECHO_pageTemplate','ECHO_externalLink','ImageCollectionIFrame','VLP_resource','VLP_essay','ECHO_ZCatalogElement','ImageCollection','versionedFileFolder','extVersionedFileFolder','ECHO_movie']
   
   
 #decode and compress for xmlrpc communication with OSAS_server  #decode and compress for xmlrpc communication with OSAS_server
Line 35  def encodeRPC(string): Line 35  def encodeRPC(string):
 def decodeRPC(string):  def decodeRPC(string):
     return bz2.decompress(base64.decodestring(string))      return bz2.decompress(base64.decodestring(string))
   
   def unicodify(s):
       """decode str (utf-8 or latin-1 representation) into unicode object"""
       if not s:
           return u""
       if isinstance(s, str):
           try:
               return s.decode('utf-8')
           except:
               return s.decode('latin-1')
       else:
           return s
   
   def utf8ify(s):
       """encode unicode object or string into byte string in utf-8 representation.
          assumes string objects to be utf-8"""
       if not s:
           return ""
       if isinstance(s, str):
           return s
       else:
           return s.encode('utf-8')
   
   
 def content_html(self,type):  def content_html(self,type):
         """template fuer content"""          """template fuer content"""
         #templates = self.ZopeFind(self.aq_parent,obj_ids=[type+"_template"])          #templates = self.ZopeFind(self.aq_parent,obj_ids=[type+"_template"])
Line 43  def content_html(self,type): Line 66  def content_html(self,type):
         #    return templates[0][1]()          #    return templates[0][1]()
   
         if hasattr(self,type+"_template"):          if hasattr(self,type+"_template"):
             logging.info("type: %s"%type)  
             obj=getattr(self,type+"_template")              obj=getattr(self,type+"_template")
             return obj()              return obj()
         else:          else:
Line 61  class ECHO_basis: Line 84  class ECHO_basis:
     management_page_charset="utf-8"      management_page_charset="utf-8"
     isVisible = True      isVisible = True
           
   
       def unicodify(self, s):
           """return unicode object for string (utf-8 or latin1) or unicode object s"""
           return unicodify(s)
       
       # compatibility of old decode method
       decode = unicodify
   
   
       def utf8ify(self, s):
           """return utf-8 encoded string object for string or unicode object s"""
           return utf8ify(s)
   
       
     def manage_addECHO_locale(self,lang,title,label,text=None,content_type=None,RESPONSE=None):      def manage_addECHO_locale(self,lang,title,label,text=None,content_type=None,RESPONSE=None):
             return ECHO_collection.manage_addECHO_locale(self,lang,title,label)              return ECHO_collection.manage_addECHO_locale(self,lang,title,label)
                           
Line 383  class ECHO_basis: Line 420  class ECHO_basis:
         bt = BrowserCheck(self)          bt = BrowserCheck(self)
         id = ob.getFullId()          id = ob.getFullId()
         link = ob.getLinkId()          link = ob.getLinkId()
           if target is None:
               targetattr = ""
           else:
               targetattr = 'target="%s"'%target
                
         if text is None:          if text is None:
             text = ob.getLabel()              text = ob.getLabel()
               
         if text is None:          if text is None:
             text = "link"              text = "link"
               
         tiptext = ob.getTip()          tiptext = ob.getTip()
         tag = ""          tag = ""
         if bt.isN4:          if bt.isN4:
             # N4 needs layer for highlighting              # N4 needs layer for highlighting
             tag += '<ilayer id="a.%s"><a class="maplink" onmouseover="highlightPair(\'%s\', true)" onmouseout="highlightPair(\'%s\', false)" href="%s" target="%s"'%(id,id,id,link,target)              tag += '<ilayer id="a.%s"><a class="maplink" onmouseover="highlightPair(\'%s\', true)" onmouseout="highlightPair(\'%s\', false)" href="%s" %s'%(id,id,id,link,targetattr)
             tag += ">" + text + "</a></ilayer>"              tag += ">" + text + "</a></ilayer>"
         else:          else:
             # a-element              # a-element
             tag = '<a id="a.%s" class="maplink" onmouseover="highlightPair(\'%s\', true)" onmouseout="highlightPair(\'%s\', false)" href="%s" target="%s"'%(id,id,id,link,target)              tag = '<a id="a.%s" class="maplink" onmouseover="highlightPair(\'%s\', true)" onmouseout="highlightPair(\'%s\', false)" href="%s" %s'%(id,id,id,link,targetattr)
             if tiptext:              if tiptext:
                 tag += ' title="%s"'%tiptext                  tag += ' title="%s"'%tiptext
             tag += ">" + text + "</a>"              tag += ">" + text + "</a>"
Line 591  def getSubCols(self, sortfield=None, Line 635  def getSubCols(self, sortfield=None,
                isVisible=True):                 isVisible=True):
                   
         def sort(x,y):          def sort(x,y):
                   try:
                           if type(x[0])==type(y[0]):
                 return cmp(x[0],y[0])                  return cmp(x[0],y[0])
                           else:
                                   if type(x[0])==types.StringType:
                                           tmpX=unicodify(x[0])
                                           tmpY=y[0]
                                   else:
                                           tmpY=unicodify(y[0])
                                           tmpX=x[0]
                                   return cmp(tmpX,tmpY)
                   
                   except:
                           logging.error("Error at ECHO_helpers.sort:AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA")
                           logging.error("                         : %s %s"%sys.exc_info()[0:2])
                           logging.error("Error at ECHO_helpers.sort:"+repr(x)+"--"+repr(type(x[0])))
                           logging.error("Error at ECHO_helpers.sort:"+repr(y)+"--"+repr(type(y[0])))
                           logging.error("Error at ECHO_helpers.sort:BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB")
                           return 0
         def sortfnc(sortfield,x,y):          def sortfnc(sortfield,x,y):
                 try:                  try:
                         xa=x[1].getMDValue(sortfield,generic=generic)                          xa=x[1].getMDValue(sortfield,generic=generic)

Removed from v.1.83  
changed lines
  Added in v.1.90


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