Annotation of zogiLib/zogiLib.py, revision 1.19
1.13 casties 1:
1.1 dwinter 2: from Products.PageTemplates.PageTemplateFile import PageTemplateFile
3: from Products.PageTemplates.PageTemplate import PageTemplate
4: from Products.PageTemplates.ZopePageTemplate import ZopePageTemplate
1.4 dwinter 5: from OFS.Image import Image
6: from webdav.common import rfc1123_date
1.1 dwinter 7:
8: import xml.dom.minidom
9: from OFS.Folder import Folder
10: from xml_helpers import getText
11: import os
12: import re
13: import string
14: import urllib
15: from Globals import package_home
16:
17: def getString(self,key,default=''):
18: try:
19: return self.REQUEST[key]
20: except:
21: return default
22:
1.15 casties 23: def sendFile(self, filename, type):
1.17 casties 24: """sends an object or a local file (in the product) as response"""
25: paths = filename.split('/')
26: object = self
27: # look for an object called filename
28: for path in paths:
29: if hasattr(object, path):
30: object = getattr(object, path)
31: else:
32: object = None
33: break
34: if object:
1.18 casties 35: # if the object exists then send it
36: return object.index_html(self.REQUEST.REQUEST, self.REQUEST.RESPONSE)
1.17 casties 37: else:
38: # send a local file with the given content-type
39: fn = os.path.join(package_home(globals()), filename)
40: self.REQUEST.RESPONSE.setHeader("Content-Type", type)
41: self.REQUEST.RESPONSE.write(file(fn).read())
1.15 casties 42: return
43:
1.18 casties 44: class BrowserCheck:
45: """check the browsers request to find out the browser type"""
1.5 dwinter 46:
1.18 casties 47: def __init__(self, zope):
48: self.ua = zope.REQUEST.get_header("HTTP_USER_AGENT")
49: self.isIE = string.find(self.ua, 'MSIE') > -1
50: self.isN4 = (string.find(self.ua, 'Mozilla/4.') > -1) and not self.isIE
51: self.nav = self.ua[string.find(self.ua, '('):]
52: ie = string.split(self.nav, "; ")[1]
53: if string.find(ie, "MSIE") > -1:
54: self.versIE = string.split(ie, " ")[1]
55: self.isMac = string.find(self.ua, 'Macintosh') > -1
56: self.isWin = string.find(self.ua, 'Windows') > -1
57: self.isIEWin = self.isIE and self.isWin
58: self.isIEMac = self.isIE and self.isMac
1.5 dwinter 59:
60:
61: def manage_addZogiLibMainTemplateForm(self):
62: """Form for adding"""
1.18 casties 63: #FIXME:???
64: pt=PageTemplateFile(os.path.join(package_home(globals()), 'zpt/AddOSAS_thumbTemplate.zpt')).__of__(self)
1.5 dwinter 65: return pt()
66:
67:
68:
69:
70: def manage_addZogiLibMainTemplate(self, id,title=None, text=None,
71: REQUEST=None, submit=None):
72: "Add a Page Template with optional file content."
1.18 casties 73: #FIXME:???
1.5 dwinter 74: id = str(id)
75: if REQUEST is None:
76: self._setObject(id, zogiLib_mainTemplate(id, text))
77: ob = getattr(self, id)
78:
79: if title:
80: ob.pt_setTitle(title)
81: return ob
82: else:
83: file = REQUEST.form.get('file')
84: headers = getattr(file, 'headers', None)
85: if headers is None or not file.filename:
86: zpt = zogiLib_mainTemplate(id)
87: else:
88: zpt = zogiLib_mainTemplate(id, file, headers.get('content_type'))
89:
90: self._setObject(id, zpt)
91: ob = getattr(self, id)
92:
93:
94: try:
95: u = self.DestinationURL()
96: except AttributeError:
97: u = REQUEST['URL1']
98:
99: if submit == " Add and Edit ":
100: u = "%s/%s" % (u, quote(id))
101: REQUEST.RESPONSE.redirect(u+'/manage_main')
102: return ''
103:
1.1 dwinter 104:
1.4 dwinter 105: class zogiImage(Image):
106: """einzelnes Image"""
107: meta_type="zogiImage"
108:
1.18 casties 109: manage_options=ZopePageTemplate.manage_options+(
110: {'label':'Main config','action':'changeZogiImageForm'},
111: )
1.4 dwinter 112:
113:
114: def __init__(self,id,title,baseUrl,queryString,content_type='',precondition=''):
115: """init"""
116: self.id=id
117: self.title=title
118: self.baseUrl=baseUrl
119: self.queryString=queryString
120: self.content_type=content_type
121: self.precondition=precondition
122:
123: def getData(self):
124: """getUrlData"""
125: return urllib.urlopen(self.baseUrl+self.queryString)
126:
127: def changeZogiImageForm(self):
128: """Main configuration"""
1.18 casties 129: pt=PageTemplateFile(os.path.join(package_home(globals()), 'zpt/changeZogiImageForm.zpt')).__of__(self)
1.4 dwinter 130: return pt()
131:
132: def changeZogiImage(self,title,baseUrl, queryString,RESPONSE=None):
133: """change it"""
134: self.title=title
135: self.baseUrl=baseUrl
136: self.queryString=queryString
137:
138: if RESPONSE is not None:
139: RESPONSE.redirect('manage_main')
140:
141:
142: def index_html(self, REQUEST, RESPONSE):
143: """
144: Modified version of OFS/Image.py
1.1 dwinter 145:
1.4 dwinter 146: The default view of the contents of a File or Image.
147:
148: Returns the contents of the file or image. Also, sets the
149: Content-Type HTTP header to the objects content type.
150: """
151:
152: # HTTP If-Modified-Since header handling.
153: header=REQUEST.get_header('If-Modified-Since', None)
154: if header is not None:
155: header=header.split( ';')[0]
156: # Some proxies seem to send invalid date strings for this
157: # header. If the date string is not valid, we ignore it
158: # rather than raise an error to be generally consistent
159: # with common servers such as Apache (which can usually
160: # understand the screwy date string as a lucky side effect
161: # of the way they parse it).
162: # This happens to be what RFC2616 tells us to do in the face of an
163: # invalid date.
164: try: mod_since=long(DateTime(header).timeTime())
165: except: mod_since=None
166: if mod_since is not None:
167: if self._p_mtime:
168: last_mod = long(self._p_mtime)
169: else:
170: last_mod = long(0)
171: if last_mod > 0 and last_mod <= mod_since:
172: # Set header values since apache caching will return Content-Length
173: # of 0 in response if size is not set here
174: RESPONSE.setHeader('Last-Modified', rfc1123_date(self._p_mtime))
175: RESPONSE.setHeader('Content-Type', self.content_type)
176: RESPONSE.setHeader('Content-Length', self.size)
177: RESPONSE.setHeader('Accept-Ranges', 'bytes')
178: self.ZCacheable_set(None)
179: RESPONSE.setStatus(304)
180: return ''
181:
182: if self.precondition and hasattr(self,self.precondition):
183: # Grab whatever precondition was defined and then
184: # execute it. The precondition will raise an exception
185: # if something violates its terms.
186: c=getattr(self,self.precondition)
187: if hasattr(c,'isDocTemp') and c.isDocTemp:
188: c(REQUEST['PARENTS'][1],REQUEST)
189: else:
190: c()
191:
192: # HTTP Range header handling
193: range = REQUEST.get_header('Range', None)
194: request_range = REQUEST.get_header('Request-Range', None)
195: if request_range is not None:
196: # Netscape 2 through 4 and MSIE 3 implement a draft version
197: # Later on, we need to serve a different mime-type as well.
198: range = request_range
199: if_range = REQUEST.get_header('If-Range', None)
200: if range is not None:
201: ranges = HTTPRangeSupport.parseRange(range)
202:
203: if if_range is not None:
204: # Only send ranges if the data isn't modified, otherwise send
205: # the whole object. Support both ETags and Last-Modified dates!
206: if len(if_range) > 1 and if_range[:2] == 'ts':
207: # ETag:
208: if if_range != self.http__etag():
209: # Modified, so send a normal response. We delete
210: # the ranges, which causes us to skip to the 200
211: # response.
212: ranges = None
213: else:
214: # Date
215: date = if_range.split( ';')[0]
216: try: mod_since=long(DateTime(date).timeTime())
217: except: mod_since=None
218: if mod_since is not None:
219: if self._p_mtime:
220: last_mod = long(self._p_mtime)
221: else:
222: last_mod = long(0)
223: if last_mod > mod_since:
224: # Modified, so send a normal response. We delete
225: # the ranges, which causes us to skip to the 200
226: # response.
227: ranges = None
228:
229: if ranges:
230: # Search for satisfiable ranges.
231: satisfiable = 0
232: for start, end in ranges:
233: if start < self.size:
234: satisfiable = 1
235: break
236:
237: if not satisfiable:
238: RESPONSE.setHeader('Content-Range',
239: 'bytes */%d' % self.size)
240: RESPONSE.setHeader('Accept-Ranges', 'bytes')
241: RESPONSE.setHeader('Last-Modified',
242: rfc1123_date(self._p_mtime))
243: RESPONSE.setHeader('Content-Type', self.content_type)
244: RESPONSE.setHeader('Content-Length', self.size)
245: RESPONSE.setStatus(416)
246: return ''
247:
248: ranges = HTTPRangeSupport.expandRanges(ranges, self.size)
249:
250: if len(ranges) == 1:
251: # Easy case, set extra header and return partial set.
252: start, end = ranges[0]
253: size = end - start
254:
255: RESPONSE.setHeader('Last-Modified',
256: rfc1123_date(self._p_mtime))
257: RESPONSE.setHeader('Content-Type', self.content_type)
258: RESPONSE.setHeader('Content-Length', size)
259: RESPONSE.setHeader('Accept-Ranges', 'bytes')
260: RESPONSE.setHeader('Content-Range',
261: 'bytes %d-%d/%d' % (start, end - 1, self.size))
262: RESPONSE.setStatus(206) # Partial content
263:
264: data = urllib.urlopen(self.baseUrl+self.queryString).read()
265: if type(data) is StringType:
266: return data[start:end]
267:
268: # Linked Pdata objects. Urgh.
269: pos = 0
270: while data is not None:
271: l = len(data.data)
272: pos = pos + l
273: if pos > start:
274: # We are within the range
275: lstart = l - (pos - start)
276:
277: if lstart < 0: lstart = 0
278:
279: # find the endpoint
280: if end <= pos:
281: lend = l - (pos - end)
282:
283: # Send and end transmission
284: RESPONSE.write(data[lstart:lend])
285: break
286:
287: # Not yet at the end, transmit what we have.
288: RESPONSE.write(data[lstart:])
289:
290: data = data.next
291:
292: return ''
293:
294: else:
295: boundary = choose_boundary()
296:
297: # Calculate the content length
298: size = (8 + len(boundary) + # End marker length
299: len(ranges) * ( # Constant lenght per set
300: 49 + len(boundary) + len(self.content_type) +
301: len('%d' % self.size)))
302: for start, end in ranges:
303: # Variable length per set
304: size = (size + len('%d%d' % (start, end - 1)) +
305: end - start)
306:
307:
308: # Some clients implement an earlier draft of the spec, they
309: # will only accept x-byteranges.
310: draftprefix = (request_range is not None) and 'x-' or ''
311:
312: RESPONSE.setHeader('Content-Length', size)
313: RESPONSE.setHeader('Accept-Ranges', 'bytes')
314: RESPONSE.setHeader('Last-Modified',
315: rfc1123_date(self._p_mtime))
316: RESPONSE.setHeader('Content-Type',
317: 'multipart/%sbyteranges; boundary=%s' % (
318: draftprefix, boundary))
319: RESPONSE.setStatus(206) # Partial content
320:
321: data = urllib.urlopen(self.baseUrl+self.queryString).read()
322: # The Pdata map allows us to jump into the Pdata chain
323: # arbitrarily during out-of-order range searching.
324: pdata_map = {}
325: pdata_map[0] = data
326:
327: for start, end in ranges:
328: RESPONSE.write('\r\n--%s\r\n' % boundary)
329: RESPONSE.write('Content-Type: %s\r\n' %
330: self.content_type)
331: RESPONSE.write(
332: 'Content-Range: bytes %d-%d/%d\r\n\r\n' % (
333: start, end - 1, self.size))
334:
335: if type(data) is StringType:
336: RESPONSE.write(data[start:end])
337:
338: else:
339: # Yippee. Linked Pdata objects. The following
340: # calculations allow us to fast-forward through the
341: # Pdata chain without a lot of dereferencing if we
342: # did the work already.
343: first_size = len(pdata_map[0].data)
344: if start < first_size:
345: closest_pos = 0
346: else:
347: closest_pos = (
348: ((start - first_size) >> 16 << 16) +
349: first_size)
350: pos = min(closest_pos, max(pdata_map.keys()))
351: data = pdata_map[pos]
352:
353: while data is not None:
354: l = len(data.data)
355: pos = pos + l
356: if pos > start:
357: # We are within the range
358: lstart = l - (pos - start)
359:
360: if lstart < 0: lstart = 0
361:
362: # find the endpoint
363: if end <= pos:
364: lend = l - (pos - end)
365:
366: # Send and loop to next range
367: RESPONSE.write(data[lstart:lend])
368: break
369:
370: # Not yet at the end, transmit what we have.
371: RESPONSE.write(data[lstart:])
372:
373: data = data.next
374: # Store a reference to a Pdata chain link so we
375: # don't have to deref during this request again.
376: pdata_map[pos] = data
377:
378: # Do not keep the link references around.
379: del pdata_map
380:
381: RESPONSE.write('\r\n--%s--\r\n' % boundary)
382: return ''
383:
384: RESPONSE.setHeader('Last-Modified', rfc1123_date(self._p_mtime))
385: RESPONSE.setHeader('Content-Type', self.content_type)
386: RESPONSE.setHeader('Content-Length', self.size)
387: RESPONSE.setHeader('Accept-Ranges', 'bytes')
388:
389: # Don't cache the data itself, but provide an opportunity
390: # for a cache manager to set response headers.
391: self.ZCacheable_set(None)
392:
393: data=urllib.urlopen(self.baseUrl+self.queryString).read()
394:
395: if type(data) is type(''):
396: RESPONSE.setBase(None)
397: return data
398:
399: while data is not None:
400: RESPONSE.write(data.data)
401: data=data.next
402:
403: return ''
404:
405:
406: def manage_addZogiImageForm(self):
407: """Form for adding"""
1.18 casties 408: pt=PageTemplateFile(os.path.join(package_home(globals()), 'zpt/addZogiImage.zpt')).__of__(self)
1.4 dwinter 409: return pt()
410:
411:
412: def manage_addZogiImage(self,id,title,baseUrl, queryString,RESPONSE=None):
413: """add dgilib"""
414: newObj=zogiImage(id,title,baseUrl, queryString)
415: self.Destination()._setObject(id,newObj)
416: if RESPONSE is not None:
417: RESPONSE.redirect('manage_main')
418:
419:
420:
1.1 dwinter 421: class zogiLib(Folder):
422: """StandardElement"""
423:
424: meta_type="zogiLib"
425:
1.18 casties 426: manage_options = Folder.manage_options+(
427: {'label':'Main Config','action':'changeZogiLibForm'},
428: )
1.1 dwinter 429:
1.5 dwinter 430: def __init__(self, id,title,digilibBaseUrl, localFileBase,version="book"):
1.1 dwinter 431: """init"""
432:
433: self.id=id
434: self.title=title
1.2 dwinter 435: self.digilibBaseUrl=digilibBaseUrl
1.1 dwinter 436: self.localFileBase=localFileBase
1.18 casties 437: self.layout=version
1.1 dwinter 438:
439:
1.18 casties 440: def getDLInfo(self):
441: """get DLInfo from digilib server"""
442: paramH={}
443: baseUrl=re.sub("servlet/Scaler","dlInfo-xml.jsp",self.digilibBaseUrl)
444: try:
445: url=urllib.urlopen(baseUrl+self.REQUEST['QUERY_STRING'])
446: dom=xml.dom.minidom.parse(url)
447: params=dom.getElementsByTagName('parameter')
448: for param in params:
449: paramH[param.getAttribute('name')]=param.getAttribute('value')
450: return paramH
451: except:
452: return null
453:
1.1 dwinter 454:
1.18 casties 455: def createHeadJS(self):
1.19 ! casties 456: """generate all javascript tags for head"""
1.18 casties 457: pt=PageTemplateFile(os.path.join(package_home(globals()), 'zpt/zogilib_head_js')).__of__(self)
458: return pt()
1.19 ! casties 459:
! 460: def createParamJS(self):
! 461: """generate javascript for parameters only"""
! 462: pt=PageTemplateFile(os.path.join(package_home(globals()), 'zpt/zogilib_param_js')).__of__(self)
! 463: return pt()
! 464:
1.3 dwinter 465:
1.18 casties 466: def createScalerImg(self, requestString = None):
467: """generate Scaler IMG Tag"""
468: bt = self.REQUEST.SESSION['browserType']
469: if not requestString:
470: requestString = self.REQUEST.QUERY_STRING
471: url = self.digilibBaseUrl+requestString
472: tag = ""
473: if bt.isN4:
474: tag += '<ilayer id="scaler">'
475: else:
476: tag += '<div id="scaler">'
477: tag += '<script type="text/javascript">'
478: tag += "var ps = bestPicSize(getElement('scaler'));"
479: tag += 'document.write(\'<img id="pic" src="%s&dw=\'+ps.width+\'&dh=\'+ps.height+\'" />\')'%url
480: tag += '</script>'
481: if bt.isN4:
482: tag += '</ilayer>'
483: else:
484: tag += '</div>'
485: return tag
1.1 dwinter 486:
1.18 casties 487: def createAuxDiv(self):
488: """generate other divs"""
489: bt = self.REQUEST.SESSION['browserType']
490: if bt.isN4:
491: f = 'zpt/zogilib_divsN4.zpt'
492: else:
493: f = 'zpt/zogilib_divs.zpt'
494: pt=PageTemplateFile(os.path.join(package_home(globals()),f)).__of__(self)
495: return pt()
1.3 dwinter 496:
1.9 dwinter 497:
1.18 casties 498: def option_js(self):
499: """option_js"""
500: pt=PageTemplateFile(os.path.join(package_home(globals()), 'zpt/option_js')).__of__(self)
501: return pt()
1.1 dwinter 502:
1.18 casties 503: def dl_lib_js(self):
504: """javascript"""
505: return sendFile(self, 'js/dl_lib.js', 'text/plain')
506:
507: def js_lib_js(self):
508: """javascript"""
509: return sendFile(self, 'js/js_lib.js', 'text/plain')
1.1 dwinter 510:
1.18 casties 511: def optionwindow(self):
512: """showoptions"""
513: pt=PageTemplateFile(os.path.join(package_home(globals()), 'zpt/optionwindow.zpt')).__of__(self)
514: return pt()
1.13 casties 515:
516: def mark1(self):
517: """mark image"""
1.18 casties 518: return sendFile(self, 'images/mark1.gif', 'image/gif')
1.13 casties 519:
520: def mark2(self):
521: """mark image"""
1.18 casties 522: return sendFile(self, 'images/mark2.gif', 'image/gif')
1.13 casties 523:
524: def mark3(self):
525: """mark image"""
1.18 casties 526: return sendFile(self, 'images/mark3.gif', 'image/gif')
1.13 casties 527:
528: def mark4(self):
529: """mark image"""
1.18 casties 530: return sendFile(self, 'images/mark4.gif', 'image/gif')
1.13 casties 531:
532: def mark5(self):
533: """mark image"""
1.18 casties 534: return sendFile(self, 'images/mark5.gif', 'image/gif')
1.13 casties 535:
536: def mark6(self):
537: """mark image"""
1.18 casties 538: return sendFile(self, 'images/mark6.gif', 'image/gif')
1.13 casties 539:
540: def mark7(self):
541: """mark image"""
1.18 casties 542: return sendFile(self, 'images/mark7.gif', 'image/gif')
1.13 casties 543:
544: def mark8(self):
545: """mark image"""
1.18 casties 546: return sendFile(self, 'images/mark8.gif', 'image/gif')
1.13 casties 547:
548: def corner1(self):
549: """mark image"""
1.18 casties 550: return sendFile(self, 'images/olinks.gif', 'image/gif')
1.13 casties 551:
552: def corner2(self):
553: """mark image"""
1.18 casties 554: return sendFile(self, 'images/orechts.gif', 'image/gif')
1.13 casties 555:
556: def corner3(self):
557: """mark image"""
1.18 casties 558: return sendFile(self, 'images/ulinks.gif', 'image/gif')
1.13 casties 559:
560: def corner4(self):
561: """mark image"""
1.18 casties 562: return sendFile(self, 'images/urechts.gif', 'image/gif')
1.13 casties 563:
564:
565:
1.1 dwinter 566:
567: def index_html(self):
568: """main action"""
1.18 casties 569: tp = "zogiLibMainTemplate"
570: if hasattr(self, tp):
571: pt = getattr(self, tp)
572: else:
573: pt=PageTemplateFile(os.path.join(package_home(globals()), 'zpt/zogiLibMain_%s'%self.layout)).__of__(self)
574: return pt()
575:
1.1 dwinter 576:
577:
578: def storeQuery(self):
579: """storeQuery in session"""
1.18 casties 580: dlParams = {}
1.1 dwinter 581: for fm in self.REQUEST.form.keys():
1.18 casties 582: dlParams[fm] = self.REQUEST.form[fm]
583:
584: if 'mo' in dlParams:
585: if len(dlParams['mo']) > 0:
586: modes=dlParams['mo'].split(',')
587: else:
588: modes=[]
589:
590: self.REQUEST.SESSION['query'] = dlParams
591: self.REQUEST.SESSION['dlModes'] = modes
592: self.REQUEST.SESSION['dlInfo'] = self.getDLInfo()
593: self.REQUEST.SESSION['browserType'] = BrowserCheck(self)
1.1 dwinter 594:
1.3 dwinter 595:
1.18 casties 596: def getDLParam(self,param):
597: """returns parameter"""
1.3 dwinter 598: try:
599: return self.REQUEST.SESSION['query'][param]
600: except:
601: return None
602:
1.18 casties 603: def setDLParam(self, param, value):
604: """sets parameter"""
605: self.REQUEST.SESSION['query'][param] = value
606: return
607:
608: def getAllDLParams(self):
609: """parameter string for digilib"""
610: dlParams = self.REQUEST.SESSION['query']
611: # save modes
612: modes = self.REQUEST.SESSION['dlModes']
613: dlParams['mo'] = string.join(modes, ',')
614: # assemble query string
615: ret = ""
616: for param in dlParams.keys():
617: val = str(dlParams[param])
618: if val != "":
619: ret += param + "=" + val + "&"
620: # omit trailing "&"
621: return ret.rstrip('&')
622:
623:
624: def setDLParams(self,pn=None,ws=None,rot=None,brgt=None,cont=None):
625: """setze Parameter"""
626: ret=""
627:
628: if brgt:
629: self.setDLParam('brgt', brgt)
630:
631: if cont:
632: self.setDLParam('cont', cont)
633:
634: if pn:
635: self.setDLParam('pn', pn)
636:
637: if ws:
638: self.setDLParam('ws', ws)
639:
640: if rot:
641: self.setDLParam('rot', rot)
642:
643: return self.display()
644:
645:
646: def display(self):
647: """(re)display page"""
648: params = self.getAllDLParams()
649: self.REQUEST.RESPONSE.redirect(self.REQUEST['URL1']+'?'+params)
650:
651: def getPT(self):
652: """pagenums"""
653: di = self.REQUEST.SESSION['dlInfo']
654: if di:
655: return int(di['pt'])
656: else:
657: return 1
658:
659: def getPN(self):
660: """Pagenum"""
661: pn = self.getDLParam('pn')
1.3 dwinter 662: if pn:
1.18 casties 663: return int(pn)
1.3 dwinter 664: else:
665: return 1
666:
1.18 casties 667: def getBiggerWS(self):
1.3 dwinter 668: """ws+1"""
1.18 casties 669: ws=self.getDLParam('ws')
1.3 dwinter 670: if ws:
671: return int(ws)+1
672: else:
673: return 2
674:
675:
1.18 casties 676: def getSmallerWS(self):
677: """ws-1"""
678: ws=self.getDLParam('ws')
1.3 dwinter 679: if ws:
680: if int(ws)==1:
1.12 casties 681: return 1
1.3 dwinter 682: else:
683: return int(ws)-1
684: else:
685: return 1
1.1 dwinter 686:
1.18 casties 687: def hasMode(self, mode):
688: """returns if mode is in the diglib mo parameter"""
689: return (mode in self.REQUEST.SESSION['dlModes'])
690:
691: def hasNextPage(self):
692: """returns if there is a next page"""
693: pn = self.getPN()
694: pt = self.getPT()
695: return (pn < pt)
696:
697: def hasPrevPage(self):
698: """returns if there is a previous page"""
699: pn = self.getPN()
700: return (pn > 1)
1.1 dwinter 701:
1.3 dwinter 702:
1.1 dwinter 703:
1.18 casties 704: def dl_HMirror(self):
705: """mirror action"""
706: modes = self.REQUEST.SESSION['dlModes']
707: if 'hmir' in modes:
708: modes.remove('hmir')
709: else:
710: modes.append('hmir')
1.1 dwinter 711:
1.18 casties 712: return self.display()
713:
714: def dl_VMirror(self):
715: """mirror action"""
716: modes = self.REQUEST.SESSION['dlModes']
717: if 'vmir' in modes:
718: modes.remove('vmir')
719: else:
720: modes.append('vmir')
1.1 dwinter 721:
1.18 casties 722: return self.display()
1.1 dwinter 723:
1.18 casties 724: def dl_WholePage(self):
725: """zoom out action"""
726: self.setDLParam('ww', 1)
727: self.setDLParam('wh', 1)
728: self.setDLParam('wx', 0)
729: self.setDLParam('wy', 0)
730: return self.display()
731:
732: def dl_PrevPage(self):
733: """next page action"""
734: pn = self.getPN() - 1
735: if pn < 1:
736: pn = 1
737: self.setDLParam('pn', pn)
738: # unmark
739: self.setDLParam('mk', None)
740: return self.display()
741:
742: def dl_NextPage(self):
743: """next page action"""
744: pn = self.getPN() + 1
745: pt = self.getPT()
746: if pn > pt:
747: pn = pt
748: self.setDLParam('pn', pn)
749: # unmark
750: self.setDLParam('mk', None)
751: return self.display()
752:
753: def dl_FirstPage(self):
754: """first page action"""
755: self.setDLParam('pn', 1)
756: # unmark
757: self.setDLParam('mk', None)
758: return self.display()
759:
760: def dl_LastPage(self):
761: """last page action"""
762: self.setDLParam('pn', self.getPT())
763: # unmark
764: self.setDLParam('mk', None)
765: return self.display()
766:
767: def dl_Unmark(self):
768: """action to remove last mark"""
769: mk = self.getDLParam('mk')
770: if mk:
771: marks = mk.split(',')
772: marks.pop()
773: mk = string.join(marks, ',')
774: self.setDLParam('mk', mk)
775: return self.display()
1.1 dwinter 776:
777:
778:
1.18 casties 779: def changeZogiLibForm(self):
780: """Main configuration"""
781: pt=PageTemplateFile(os.path.join(package_home(globals()), 'zpt/changeZogiLibForm.zpt')).__of__(self)
782: return pt()
1.1 dwinter 783:
1.18 casties 784: def changeZogiLib(self,title,digilibBaseUrl, localFileBase, version, RESPONSE=None):
785: """change it"""
786: self.title=title
787: self.digilibBaseUrl=digilibBaseUrl
788: self.localFileBase=localFileBase
789: self.layout=version
1.3 dwinter 790:
1.18 casties 791: if RESPONSE is not None:
792: RESPONSE.redirect('manage_main')
1.8 dwinter 793:
794:
1.1 dwinter 795: def manage_addZogiLibForm(self):
796: """interface for adding zogilib"""
1.18 casties 797: pt=PageTemplateFile(os.path.join(package_home(globals()), 'zpt/addZogiLibForm')).__of__(self)
1.1 dwinter 798: return pt()
799:
1.5 dwinter 800: def manage_addZogiLib(self,id,title,digilibBaseUrl, localFileBase,version="book",RESPONSE=None):
1.1 dwinter 801: """add dgilib"""
1.5 dwinter 802: newObj=zogiLib(id,title,digilibBaseUrl, localFileBase, version)
1.1 dwinter 803: self.Destination()._setObject(id,newObj)
804: if RESPONSE is not None:
805: RESPONSE.redirect('manage_main')
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>