Mercurial > hg > documentViewer
comparison documentViewer.py @ 394:ce9fa69f81c3
new toggle option method
| author | casties |
|---|---|
| date | Mon, 08 Nov 2010 15:59:40 +0100 |
| parents | 9b2adae6c6e2 |
| children | 28a03e25a0e8 |
comparison
equal
deleted
inserted
replaced
| 393:bb317af1c197 | 394:ce9fa69f81c3 |
|---|---|
| 395 | 395 |
| 396 docinfo = self.getDocinfo(mode=mode,url=url) | 396 docinfo = self.getDocinfo(mode=mode,url=url) |
| 397 pt = getattr(self.template, 'info_xml') | 397 pt = getattr(self.template, 'info_xml') |
| 398 return pt(docinfo=docinfo) | 398 return pt(docinfo=docinfo) |
| 399 | 399 |
| 400 def getOptionToggle(self, newState=None, optionName='text_options_open', initialState=True): | |
| 401 """returns new option state""" | |
| 402 opt = self.REQUEST.SESSION.get(optionName,None) | |
| 403 if opt is None: | |
| 404 # not in session -- initial | |
| 405 opt = {'lastState': newState, 'state': initialState} | |
| 406 else: | |
| 407 if opt['lastState'] != newState: | |
| 408 # state in session has changed -- toggle | |
| 409 opt['state'] = not opt['state'] | |
| 410 opt['lastState'] = newState | |
| 411 | |
| 412 self.REQUEST.SESSION[optionName] = opt | |
| 413 return opt['state'] | |
| 400 | 414 |
| 401 def isAccessible(self, docinfo): | 415 def isAccessible(self, docinfo): |
| 402 """returns if access to the resource is granted""" | 416 """returns if access to the resource is granted""" |
| 403 access = docinfo.get('accessType', None) | 417 access = docinfo.get('accessType', None) |
| 404 logging.debug("documentViewer (accessOK) access type %s"%access) | 418 logging.debug("documentViewer (accessOK) access type %s"%access) |
