Diff for /documentViewer/Attic/documentViewer_old.py between versions 1.1.2.1 and 1.1.2.2

version 1.1.2.1, 2011/07/14 17:43:56 version 1.1.2.2, 2011/07/15 19:34:41
Line 9  from Products.zogiLib.zogiLib import bro Line 9  from Products.zogiLib.zogiLib import bro
   
 from Ft.Xml import EMPTY_NAMESPACE, Parse   from Ft.Xml import EMPTY_NAMESPACE, Parse 
 import Ft.Xml.Domlette  import Ft.Xml.Domlette
   
 import xml.etree.ElementTree as ET  
   
 import os.path  import os.path
 import sys  import sys
 import urllib  import urllib
Line 35  def getInt(number, default=0): Line 32  def getInt(number, default=0):
     except:      except:
         return int(default)          return int(default)
   
 def getTextFromNode(node):  def getTextFromNode(nodename):
     """get the cdata content of a node"""      """get the cdata content of a node"""
     if node is None:      if nodename is None:
         return ""          return ""
     # ET:      nodelist=nodename.childNodes
     text = node.text or ""      rc = ""
     for e in node:      for node in nodelist:
         text += gettext(e)          if node.nodeType == node.TEXT_NODE:
         if e.tail:             rc = rc + node.data
             text += e.tail      return rc
   
     # 4Suite:  
     #nodelist=node.childNodes  
     #text = ""  
     #for n in nodelist:  
     #    if n.nodeType == node.TEXT_NODE:  
     #       text = text + n.data  
       
     return text  
   
 def serializeNode(node, encoding="utf-8"):  def serializeNode(node, encoding="utf-8"):
     """returns a string containing node as XML"""      """returns a string containing node as XML"""
     s = ET.tostring(node)      stream = cStringIO.StringIO()
           #logging.debug("BUF: %s"%(stream))
     # 4Suite:      Ft.Xml.Domlette.Print(node, stream=stream, encoding=encoding)
     #    stream = cStringIO.StringIO()      s = stream.getvalue()
     #    Ft.Xml.Domlette.Print(node, stream=stream, encoding=encoding)      #logging.debug("BUF: %s"%(s))
     #    s = stream.getvalue()      stream.close()
     #    stream.close()  
     return s      return s
   
 def browserCheck(self):  def browserCheck(self):
Line 509  class documentViewer(Folder): Line 496  class documentViewer(Folder):
         if txt is None:          if txt is None:
             raise IOError("Unable to get dir-info from %s"%(infoUrl))              raise IOError("Unable to get dir-info from %s"%(infoUrl))
   
         dom = ET.fromstring(txt).getroot()          dom = Parse(txt)
         #dom = Parse(txt)          sizes=dom.xpath("//dir/size")
         sizes=dom.find("//dir/size")  
         #sizes=dom.xpath("//dir/size")  
         logging.debug("documentViewer (getparamfromdigilib) dirInfo:size"%sizes)          logging.debug("documentViewer (getparamfromdigilib) dirInfo:size"%sizes)
                   
         if sizes:          if sizes:
Line 561  class documentViewer(Folder): Line 546  class documentViewer(Folder):
         if txt is None:          if txt is None:
             raise IOError("Unable to read index meta from %s"%(url))              raise IOError("Unable to read index meta from %s"%(url))
                   
         dom = ET.fromstring(txt).getroot()          dom = Parse(txt)
         #dom = Parse(txt)  
         return dom          return dom
           
     def getPresentationInfoXML(self, url):      def getPresentationInfoXML(self, url):
Line 581  class documentViewer(Folder): Line 565  class documentViewer(Folder):
         if txt is None:          if txt is None:
             raise IOError("Unable to read infoXMLfrom %s"%(url))              raise IOError("Unable to read infoXMLfrom %s"%(url))
                           
         dom = ET.fromstring(txt).getroot()          dom = Parse(txt)
         #dom = Parse(txt)  
         return dom          return dom
                                                   
                   
Line 600  class documentViewer(Folder): Line 583  class documentViewer(Folder):
                 path=getParentDir(path)                  path=getParentDir(path)
             dom = self.getDomFromIndexMeta(path)              dom = self.getDomFromIndexMeta(path)
                 
         acctype = dom.find("//access-conditions/access/@type")          acctype = dom.xpath("//access-conditions/access/@type")
         #acctype = dom.xpath("//access-conditions/access/@type")  
         if acctype and (len(acctype)>0):          if acctype and (len(acctype)>0):
             access=acctype[0].value              access=acctype[0].value
             if access in ['group', 'institution']:              if access in ['group', 'institution']:
Line 627  class documentViewer(Folder): Line 609  class documentViewer(Folder):
                   
         logging.debug("documentViewer (getbibinfofromindexmeta cutted) path: %s"%(path))          logging.debug("documentViewer (getbibinfofromindexmeta cutted) path: %s"%(path))
         # put in all raw bib fields as dict "bib"          # put in all raw bib fields as dict "bib"
         bib = dom.find("//bib/*")          bib = dom.xpath("//bib/*")
         #bib = dom.xpath("//bib/*")  
         if bib and len(bib)>0:          if bib and len(bib)>0:
             bibinfo = {}              bibinfo = {}
             for e in bib:              for e in bib:
Line 637  class documentViewer(Folder): Line 618  class documentViewer(Folder):
                   
         # extract some fields (author, title, year) according to their mapping          # extract some fields (author, title, year) according to their mapping
         metaData=self.metadata.main.meta.bib          metaData=self.metadata.main.meta.bib
         bibtype=dom.find("//bib/@type")          bibtype=dom.xpath("//bib/@type")
         #bibtype=dom.xpath("//bib/@type")  
         if bibtype and (len(bibtype)>0):          if bibtype and (len(bibtype)>0):
             bibtype=bibtype[0].value              bibtype=bibtype[0].value
         else:          else:

Removed from v.1.1.2.1  
changed lines
  Added in v.1.1.2.2


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