def __init__(self, recid, tab, format=None): self.recid = recid self.tab = tab self.format = format self.files = WebInterfaceFilesPages(self.recid) self.reviews = WebInterfaceCommentsPages(self.recid, reviews=1) self.comments = WebInterfaceCommentsPages(self.recid) self.usage = self self.references = self self.keywords = self self.holdings = WebInterfaceHoldingsPages(self.recid) self.citations = self self.plots = self self.export = WebInterfaceRecordExport(self.recid, self.format) self.edit = WebInterfaceEditPages(self.recid) self.merge = WebInterfaceMergePages(self.recid) return
def _lookup(self, component, path): """ This handler is invoked for the dynamic URLs (for collections and records)""" if component == 'collection': c = '/'.join(path) def answer(req, form): """Accessing collections cached pages.""" # Accessing collections: this is for accessing the # cached page on top of each collection. argd = wash_urlargd(form, search_interface_default_urlargd) # We simply return the cached page of the collection argd['c'] = c if not argd['c']: # collection argument not present; display # home collection by default argd['c'] = CFG_SITE_NAME # Treat `as' argument specially: if argd.has_key('as'): argd['aas'] = argd['as'] del argd['as'] return display_collection(req, **argd) return answer, [] elif component == CFG_SITE_RECORD and path and path[0] == 'merge': return WebInterfaceMergePages(), path[1:] elif component == CFG_SITE_RECORD and path and path[0] == 'edit': return WebInterfaceEditPages(), path[1:] elif component == CFG_SITE_RECORD and path and path[0] == 'multiedit': return WebInterfaceMultiEditPages(), path[1:] elif component == CFG_SITE_RECORD and path and path[0] in ('managedocfiles', 'managedocfilesasync'): return WebInterfaceManageDocFilesPages(), path elif component == CFG_SITE_RECORD or component == 'record-restricted': try: if CFG_WEBSEARCH_USE_ALEPH_SYSNOS: # let us try to recognize /<CFG_SITE_RECORD>/<SYSNO> style of URLs: # check for SYSNOs with an embedded slash; needed for [ARXIVINV-15] if len(path) > 1 and get_mysql_recid_from_aleph_sysno(path[0] + "/" + path[1]): path[0] = path[0] + "/" + path[1] del path[1] x = get_mysql_recid_from_aleph_sysno(path[0]) if x: recid = x else: recid = int(path[0]) else: recid = int(path[0]) except IndexError: # display record #1 for URL /CFG_SITE_RECORD without a number recid = 1 except ValueError: if path[0] == '': # display record #1 for URL /CFG_SITE_RECORD/ without a number recid = 1 else: # display page not found for URLs like /CFG_SITE_RECORD/foo return None, [] from invenio.intbitset import __maxelem__ if recid <= 0 or recid > __maxelem__: # __maxelem__ = 2147483647 # display page not found for URLs like /CFG_SITE_RECORD/-5 or /CFG_SITE_RECORD/0 or /CFG_SITE_RECORD/2147483649 return None, [] format = None tab = '' try: if path[1] in ['', 'files', 'reviews', 'comments', 'usage', 'references', 'citations', 'holdings', 'edit', 'keywords', 'multiedit', 'merge', 'plots', 'linkbacks']: tab = path[1] elif path[1] == 'export': tab = '' format = path[2] # format = None # elif path[1] in output_formats: # tab = '' # format = path[1] else: # display page not found for URLs like /CFG_SITE_RECORD/references # for a collection where 'references' tabs is not visible return None, [] except IndexError: # Keep normal url if tabs is not specified pass #if component == 'record-restricted': #return WebInterfaceRecordRestrictedPages(recid, tab, format), path[1:] #else: return WebInterfaceRecordPages(recid, tab, format), path[1:] elif component == 'sslredirect': ## Fallback solution for sslredirect special path that should ## be rather implemented as an Apache level redirection def redirecter(req, form): real_url = "http://" + '/'.join(path) redirect_to_url(req, real_url) return redirecter, [] return None, []