Diff for /ECHO_content/VLPExtension.py between versions 1.69 and 1.73

version 1.69, 2008/07/31 16:57:45 version 1.73, 2008/08/05 18:26:15
Line 2 Line 2
 This module contains extensions which where originally made for the VLP.  This module contains extensions which where originally made for the VLP.
 """  """
 from OFS.Cache import Cacheable  from OFS.Cache import Cacheable
 from Products.ECHO_content.ECHO_collection import *  
 from Products.PageTemplates.PageTemplateFile import PageTemplateFile  from Products.PageTemplates.PageTemplateFile import PageTemplateFile
 from Products.PageTemplates.PageTemplate import PageTemplate  from Products.PageTemplates.PageTemplate import PageTemplate
 from Products.PageTemplates.ZopePageTemplate import ZopePageTemplate  from Products.PageTemplates.ZopePageTemplate import ZopePageTemplate
 from OFS.Image import File  from OFS.Image import File
 try:  
         from Products.zogiLib import zogiLib  
 except:  
         print "Zogilib not installed, VLP_resource will not work"  
   
 import xml.dom.minidom  import xml.dom.minidom
 import urllib  import urllib
 import xmlrpclib  import xmlrpclib
Line 23  from types import * Line 17  from types import *
 from Globals import package_home  from Globals import package_home
 import transaction  import transaction
   
   from Products.ECHO_content.ECHO_collection import *
   from vlp_xmlhelpers import *
   try:
           from Products.zogiLib import zogiLib
   except:
           print "Zogilib not installed, VLP_resource will not work"
   
   
 def lemmatize(str):  def lemmatize(str):
         """takes a str and addes links the dictionary service"""          """takes a str and addes links the dictionary service"""
Line 47  def makeXML(str): Line 48  def makeXML(str):
                               </page>"""%str                                </page>"""%str
                           
                                             
   def checkXMLfrag(str):
       """checks and returns str as XML fragment"""
       
       xmltempl = """<?xml version="1.0" encoding="utf-8" ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
       <txt>%s</txt>"""
   
       try:
           dom=xml.dom.minidom.parseString(xmltempl%utf8ify(str))
           return str
       except:
           str=str.replace("& ","&amp; ")
   
       dom=xml.dom.minidom.parseString(xmltempl%utf8ify(str))
       return str
       
                        
                           
 def getText(nodelist):  def getText(nodelist):
   
Line 217  class VLP_essay(Folder): Line 234  class VLP_essay(Folder):
         if RESPONSE is not None:          if RESPONSE is not None:
             RESPONSE.redirect('manage_main')              RESPONSE.redirect('manage_main')
   
       def getPageList(self):
           """returns sorted list of (id,object) of page objects"""
   
           def sortFind(x,y):
               return cmp(x[0],y[0])
           
   #        pages=[]
   #        pagestmp=self.ZopeFind(self,obj_metatypes=['DTML Document','File'])
   #        for page in pagestmp:
   #            if not (page[1].getId()[0]=="."):
   #                pages.append(page)
   
           pages = self.objectItems(['DTML Document','File'])                        
           pages.sort(sortFind)
           #logging.debug("pageList=%s"%repr(pages))
           return pages
           
           
       def getPageXMLfrag(self, pageNum=None, pageId=None, pageObj=None):
           """returns XML fragment of page with id"""
           xml = None
           
           if pageNum is not None:
               pl = self.getPageList()
               pageObj = pl[int(pageNum)-1][1]
               
           if pageId is not None:
               pageObj = getattr(self, pageId, None)
               
           if pageObj is not None:
               txt = ""
               if pageObj.meta_type == 'File':
                   data = pageObj.data
                   #logging.debug("data=%s txt=%s"%(repr(data),txt))
                   while data is not None:
                       if isinstance(data, str):
                           txt += data
                           data = None
                       else:
                           txt += data.data
                           data = data.next
           
               else:
                   # not a File object... perhaps its executable
                   txt += pageObj()
                   
               xml = checkXMLfrag(txt)
   
           return unicodify(xml)
   
   
     def getPage(self,pagenum):      def getPage(self,pagenum):
         """gibt essay page mit num aus"""          """gibt essay page mit num aus"""
Line 232  class VLP_essay(Folder): Line 299  class VLP_essay(Folder):
         #print str(pages[int(pagenum)][1]())          #print str(pages[int(pagenum)][1]())
                   
         if pages[int(pagenum)-1][1].meta_type=='File':          if pages[int(pagenum)-1][1].meta_type=='File':
                   
                 #return makeXML(str(pages[int(pagenum)-1][1]))                  #return makeXML(str(pages[int(pagenum)-1][1]))
                 #txt=pages[int(pagenum)-1][1].data.decode('utf-8')                  #txt=pages[int(pagenum)-1][1].data.decode('utf-8')
                 txt=pages[int(pagenum)-1][1].data                  txt=pages[int(pagenum)-1][1].data
                 #print txt.encode('utf-8')                  #print txt.encode('utf-8')
                   
                 return self.xml2html(makeXML(txt),quote="no")                  return self.xml2html(makeXML(txt),quote="no")
         else:          else:
                   
                   
   
                 return self.xml2html(makeXML(pages[int(pagenum)-1][1]()),quote="no")                  return self.xml2html(makeXML(pages[int(pagenum)-1][1]()),quote="no")
                   
     def nextPage(self,pagenum,url):      def nextPage(self,pagenum,url):

Removed from v.1.69  
changed lines
  Added in v.1.73


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