Changeset 613:c57d80a649ea in documentViewer for documentViewer.py
- Timestamp:
- Oct 17, 2013, 2:25:39 PM (11 years ago)
- Branch:
- default
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
documentViewer.py
r612 r613 5 5 from AccessControl import ClassSecurityInfo 6 6 from AccessControl import getSecurityManager 7 from Globals import package_home8 7 9 8 import xml.etree.ElementTree as ET 10 9 11 10 import os 12 import sys13 11 import urllib 14 12 import logging 15 13 import math 16 14 import urlparse 17 import re18 import string19 15 import json 20 16 … … 23 19 from SrvTxtUtils import getInt, utf8ify, getText, getHttpData, refreshingImageFileIndexHtml 24 20 25 def serializeNode(node, encoding="utf-8"):26 """returns a string containing node as XML"""27 s = ET.tostring(node)28 29 # 4Suite:30 # stream = cStringIO.StringIO()31 # Ft.Xml.Domlette.Print(node, stream=stream, encoding=encoding)32 # s = stream.getvalue()33 # stream.close()34 return s35 21 36 22 def getMDText(node): … … 994 980 995 981 def getPageBatch(self, start=1, rows=10, cols=2, pageFlowLtr=True, pageZero=False, minIdx=1, maxIdx=0): 996 """returns dict with array of page information for one screenfull of thumbnails""" 982 """Return dict with array of page information for one screenfull of thumbnails. 983 984 :param start: index of current page 985 :param rows: number of rows in one batch 986 :param cols: number of columns in one batch 987 :param pageFlowLtr: do indexes increase from left to right 988 :param pageZero: is there a zeroth non-visible page 989 :param minIdx: minimum index to use 990 :param maxIdx: maximum index to use 991 :returns: dict with 992 first: first page index 993 last: last page index 994 batches: list of all possible batches(dict: 'start': index, 'end': index) 995 pages: list for current batch of rows(list of cols(list of pages(dict: 'idx': index))) 996 nextStart: first index of next batch 997 prevStart: first index of previous batch 998 """ 997 999 logging.debug("getPageBatch start=%s minIdx=%s maxIdx=%s"%(start,minIdx,maxIdx)) 998 1000 batch = {} … … 1002 1004 1003 1005 np = maxIdx - minIdx + 1 1006 if pageZero: 1007 # correct number of pages for batching 1008 np += 1 1009 1004 1010 nb = int(math.ceil(np / float(grpsize))) 1011 1005 1012 # list of all batch start and end points 1006 1013 batches = [] … … 1017 1024 batch['batches'] = batches 1018 1025 1026 # list of pages for current screen 1019 1027 pages = [] 1020 1028 if pageZero and start == minIdx: … … 1046 1054 1047 1055 if start + grpsize <= maxIdx: 1048 batch['nextStart'] = start + grpsize 1056 if pageZero and start == minIdx: 1057 # correct nextStart for pageZero 1058 batch['nextStart'] = grpsize 1059 else: 1060 batch['nextStart'] = start + grpsize 1049 1061 else: 1050 1062 batch['nextStart'] = None … … 1053 1065 batch['first'] = minIdx 1054 1066 batch['last'] = maxIdx 1067 logging.debug("batch: %s"%repr(batch)) 1055 1068 return batch 1069 1056 1070 1057 1071 def getBatch(self, start=1, size=10, end=0, data=None, fullData=True):
Note: See TracChangeset
for help on using the changeset viewer.