version 1.238.2.5, 2011/07/29 18:36:04
|
version 1.238.2.7, 2011/08/04 14:57:02
|
Line 1
|
Line 1
|
|
|
from OFS.SimpleItem import SimpleItem |
from OFS.SimpleItem import SimpleItem |
from Products.PageTemplates.PageTemplateFile import PageTemplateFile |
from Products.PageTemplates.PageTemplateFile import PageTemplateFile |
|
|
Line 227 class MpdlXmlTextServer(SimpleItem):
|
Line 226 class MpdlXmlTextServer(SimpleItem):
|
|
|
def processPageInfo(self, dom, docinfo, pageinfo): |
def processPageInfo(self, dom, docinfo, pageinfo): |
"""processes page info divs from dom and stores in docinfo and pageinfo""" |
"""processes page info divs from dom and stores in docinfo and pageinfo""" |
# process all toplevel divs |
# assume first second level div is pageMeta |
alldivs = dom.findall(".//div") |
alldivs = dom.find("div") |
pagediv = None |
|
for div in alldivs: |
for div in alldivs: |
dc = div.get('class') |
dc = div.get('class') |
|
|
# page content div |
|
if dc == 'pageContent': |
|
pagediv = div |
|
|
|
# pageNumberOrig |
# pageNumberOrig |
elif dc == 'pageNumberOrig': |
if dc == 'pageNumberOrig': |
pageinfo['pageNumberOrig'] = div.text |
pageinfo['pageNumberOrig'] = div.text |
|
|
# pageNumberOrigNorm |
# pageNumberOrigNorm |
Line 247 class MpdlXmlTextServer(SimpleItem):
|
Line 241 class MpdlXmlTextServer(SimpleItem):
|
|
|
# pageNumberOrigNorm |
# pageNumberOrigNorm |
elif dc == 'countFigureEntries': |
elif dc == 'countFigureEntries': |
docinfo['countFigureEntries'] = getInt(div.text) |
docinfo['numFigureEntries'] = getInt(div.text) |
|
|
# pageNumberOrigNorm |
# pageNumberOrigNorm |
elif dc == 'countTocEntries': |
elif dc == 'countTocEntries': |
# WTF: s1 = int(s)/30+1 |
# WTF: s1 = int(s)/30+1 |
docinfo['countTocEntries'] = getInt(div.text) |
docinfo['numTocEntries'] = getInt(div.text) |
|
|
|
# pageHeaderTitle |
|
elif dc == 'pageHeaderTitle': |
|
docinfo['pageHeaderTitle'] = div.text |
|
|
# numTextPages |
# numTextPages |
elif dc == 'countPages': |
elif dc == 'countPages': |
Line 270 class MpdlXmlTextServer(SimpleItem):
|
Line 268 class MpdlXmlTextServer(SimpleItem):
|
return |
return |
|
|
|
|
def getTextPage(self, mode="text_dict", pn=1, docinfo=None, pageinfo=None): |
def getTextPage(self, mode="text", pn=1, docinfo=None, pageinfo=None): |
"""returns single page from fulltext""" |
"""returns single page from fulltext""" |
logging.debug("getTextPage mode=%s, pn=%s"%(mode,pn)) |
logging.debug("getTextPage mode=%s, pn=%s"%(mode,pn)) |
# check for cached text -- but this shouldn't be called twice |
# check for cached text -- but this shouldn't be called twice |
Line 293 class MpdlXmlTextServer(SimpleItem):
|
Line 291 class MpdlXmlTextServer(SimpleItem):
|
characterNormalization = pageinfo.get('characterNormalization', None) |
characterNormalization = pageinfo.get('characterNormalization', None) |
selfurl = docinfo['viewerUrl'] |
selfurl = docinfo['viewerUrl'] |
|
|
if mode == "text_dict": |
if mode == "dict": |
# text_dict is called textPollux in the backend |
# text_dict is called textPollux in the backend |
textmode = "textPollux" |
textmode = "textPollux" |
|
elif not mode: |
|
# default is text |
|
textmode = "text" |
else: |
else: |
textmode = mode |
textmode = mode |
|
|
Line 311 class MpdlXmlTextServer(SimpleItem):
|
Line 312 class MpdlXmlTextServer(SimpleItem):
|
# page content is in <div class="pageContent"> |
# page content is in <div class="pageContent"> |
pagediv = None |
pagediv = None |
# ElementTree 1.2 in Python 2.6 can't do div[@class='pageContent'] |
# ElementTree 1.2 in Python 2.6 can't do div[@class='pageContent'] |
alldivs = dom.findall(".//div") |
# so we look at the second level divs |
|
alldivs = dom.findall("div") |
for div in alldivs: |
for div in alldivs: |
dc = div.get('class') |
dc = div.get('class') |
# page content div |
# page content div |