def service(self, req): script_name = req.environ['SCRIPT_NAME'] if script_name == '/': location = self.location elif location.startswith('/') and self.append_script_name: location = script_name + self.location else: location = self.location raise exc.HTTPTemporaryRedirect(location=location)
def service(self, req): # req.remote_user can possibly be None if AD authentication works, # but there is a problem importing the user database from Tableau. if req.remote_user is None: # FIXME: print to the error log? raise exc.HTTPTemporaryRedirect(location='/login') # FIXME: don't override the existing remote_user, instead create # a different member like 'remote_user_profile'. req.remote_user = UserProfile.get_by_name(req.envid, req.remote_user)
def service_GET(self, req): """Redirect all pages to /setup if the system hasn't been setup. The setup status is determined by whether or not the palette user has a password or not. """ if 'REMOTE_USER' in req.environ: # If REMOTE_USER is set - presumably from auth_tkt, # then setup has already been done. return entry = UserProfile.get(req.envid, 0) # user '0', likely 'palette' if not entry.hashed_password: raise exc.HTTPTemporaryRedirect(location='/setup')
def service(self, req): if 'REMOTE_USER' in req.environ: return path = posixpath.join(req.environ['SCRIPT_NAME'], req.path_info) if path == self.redirect: return if self.redirect: if path and path != '/': location = self.redirect + '?location=' + path else: location = self.redirect app = exc.HTTPTemporaryRedirect(location=location) else: app = exc.HTTPForbidden() return app
def action_view_GET(self, req, page): if not page.exists: return exc.HTTPTemporaryRedirect(location=req.url + '?action=edit') if req.cookies.get('message'): message = req.cookies['message'] else: message = None text = self.view_template.substitute(page=page, req=req, message=message) resp = Response(text) if message: resp.delete_cookie('message') else: resp.last_modified = page.mtime resp.conditional_response = True return resp
def render(self, req, obj=None): # pylint: disable=attribute-defined-outside-init # req.remote_user can possibly be None if AD authentication works, # but there is a problem importing the user database from Tableau. if req.remote_user is None: # FIXME: print to the error log? raise exc.HTTPTemporaryRedirect(location='/login') if not self.required_role is None: if req.remote_user.roleid < self.required_role: raise exc.HTTPForbidden if 'status_color' in req.cookies: color = req.cookies['status_color'] self.status_class = self.build_status_class(color) else: self.status_class = '' if 'status_text' in req.cookies: self.status_text = req.cookies['status_text'].replace("_", " ") else: self.status_text = '' return super(PalettePage, self).render(req, obj=self)
def service(self, req): if internet_explorer(req): raise exc.HTTPTemporaryRedirect(location=self.redirect)
def redirect(url, code=302): raise exc.HTTPTemporaryRedirect(location=url)