version 1.72, 2008/08/05 16:50:56
|
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 52 def checkXMLfrag(str):
|
Line 53 def checkXMLfrag(str):
|
|
|
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"> |
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>""" |
<txt>%s</txt>""" |
|
|
try: |
try: |
dom=xml.dom.minidom.parseString(xmltempl%str) |
dom=xml.dom.minidom.parseString(xmltempl%utf8ify(str)) |
return str |
return str |
except: |
except: |
str=str.replace("& ","& ") |
str=str.replace("& ","& ") |
|
|
dom=xml.dom.minidom.parseString(xmltempl%str) |
dom=xml.dom.minidom.parseString(xmltempl%utf8ify(str)) |
return str |
return str |
|
|
|
|
Line 246 class VLP_essay(Folder):
|
Line 248 class VLP_essay(Folder):
|
|
|
pages = self.objectItems(['DTML Document','File']) |
pages = self.objectItems(['DTML Document','File']) |
pages.sort(sortFind) |
pages.sort(sortFind) |
|
#logging.debug("pageList=%s"%repr(pages)) |
return pages |
return pages |
|
|
|
|
Line 262 class VLP_essay(Folder):
|
Line 265 class VLP_essay(Folder):
|
|
|
if pageObj is not None: |
if pageObj is not None: |
txt = "" |
txt = "" |
|
if pageObj.meta_type == 'File': |
data = pageObj.data |
data = pageObj.data |
|
#logging.debug("data=%s txt=%s"%(repr(data),txt)) |
while data is not None: |
while data is not None: |
txt += str(data) |
|
if isinstance(data, str): |
if isinstance(data, str): |
|
txt += data |
data = None |
data = None |
else: |
else: |
|
txt += data.data |
data = data.next |
data = data.next |
|
|
|
else: |
|
# not a File object... perhaps its executable |
|
txt += pageObj() |
|
|
xml = checkXMLfrag(txt) |
xml = checkXMLfrag(txt) |
|
|
return xml |
return unicodify(xml) |
|
|
|
|
def getPage(self,pagenum): |
def getPage(self,pagenum): |