Mercurial > hg > documentViewer
comparison documentViewer.py @ 528:f8a5f63eafc0
new viewMode=thumbs.
author | casties |
---|---|
date | Fri, 13 Apr 2012 16:55:16 +0200 |
parents | 3f375a048402 |
children | 5c7433c2515c |
comparison
equal
deleted
inserted
replaced
527:652cc8d3f1a9 | 528:f8a5f63eafc0 |
---|---|
121 # viewMode templates | 121 # viewMode templates |
122 viewer_text = PageTemplateFile('zpt/viewer_text', globals()) | 122 viewer_text = PageTemplateFile('zpt/viewer_text', globals()) |
123 viewer_xml = PageTemplateFile('zpt/viewer_xml', globals()) | 123 viewer_xml = PageTemplateFile('zpt/viewer_xml', globals()) |
124 viewer_images = PageTemplateFile('zpt/viewer_images', globals()) | 124 viewer_images = PageTemplateFile('zpt/viewer_images', globals()) |
125 viewer_index = PageTemplateFile('zpt/viewer_index', globals()) | 125 viewer_index = PageTemplateFile('zpt/viewer_index', globals()) |
126 viewer_thumbs = PageTemplateFile('zpt/viewer_thumbs', globals()) | |
126 # available layer types | 127 # available layer types |
127 builtinLayers = {'text': ['dict','search','gis','annotator'], | 128 builtinLayers = {'text': ['dict','search','gis','annotator'], |
128 'xml': None, 'images': None, 'index': None} | 129 'xml': None, 'images': None, 'index': None} |
129 availableLayers = builtinLayers; | 130 availableLayers = builtinLayers; |
130 # layer templates | 131 # layer templates |
459 | 460 |
460 docinfo = self.getDocinfo(mode=mode,url=url) | 461 docinfo = self.getDocinfo(mode=mode,url=url) |
461 pt = getattr(self.template, 'info_xml') | 462 pt = getattr(self.template, 'info_xml') |
462 return pt(docinfo=docinfo) | 463 return pt(docinfo=docinfo) |
463 | 464 |
465 def getAuthenticatedUser(self, anon=None): | |
466 """returns the authenticated user object or None. (ignores Zopes anonymous user)""" | |
467 user = getSecurityManager().getUser() | |
468 if user is not None and user.getUserName() != "Anonymous User": | |
469 return user | |
470 else: | |
471 return anon | |
472 | |
464 def isAccessible(self, docinfo): | 473 def isAccessible(self, docinfo): |
465 """returns if access to the resource is granted""" | 474 """returns if access to the resource is granted""" |
466 access = docinfo.get('accessType', None) | 475 access = docinfo.get('accessType', None) |
467 logging.debug("documentViewer (accessOK) access type %s"%access) | 476 logging.debug("documentViewer (accessOK) access type %s"%access) |
468 if access == 'free': | 477 if access == 'free': |
469 logging.debug("documentViewer (accessOK) access is free") | 478 logging.debug("documentViewer (accessOK) access is free") |
470 return True | 479 return True |
471 | 480 |
472 elif access is None or access in self.authgroups: | 481 elif access is None or access in self.authgroups: |
473 # only local access -- only logged in users | 482 # only local access -- only logged in users |
474 user = getSecurityManager().getUser() | 483 user = self.getAuthenticatedUser() |
475 logging.debug("documentViewer (accessOK) user=%s ip=%s"%(user,self.REQUEST.getClientAddr())) | 484 logging.debug("documentViewer (accessOK) user=%s ip=%s"%(user,self.REQUEST.getClientAddr())) |
476 if user is not None: | 485 return (user is not None) |
477 #print "user: ", user | |
478 return (user.getUserName() != "Anonymous User") | |
479 else: | |
480 return False | |
481 | 486 |
482 logging.error("documentViewer (accessOK) unknown access type %s"%access) | 487 logging.error("documentViewer (accessOK) unknown access type %s"%access) |
483 return False | 488 return False |
484 | |
485 | 489 |
486 | 490 |
487 def getDocinfo(self, mode, url, tocMode=None): | 491 def getDocinfo(self, mode, url, tocMode=None): |
488 """returns docinfo depending on mode""" | 492 """returns docinfo depending on mode""" |
489 logging.debug("getDocinfo: mode=%s, url=%s"%(mode,url)) | 493 logging.debug("getDocinfo: mode=%s, url=%s"%(mode,url)) |