def _redirect_index(self, api): """Redirect to an index page.""" request = api.request status = http.HTTP_FOUND extension = api.config.ns()['extension'] filename = 'index.%s' % extension uri = urilib.create_path_uri(request.directory(), filename, '') headers = { 'location': [uri] } raise HTTPResponse(status, headers=headers)
def create_draco_uri(scheme, host, directory, filename, locale, session, pathinfo, args): """Create a Draco URI from its components. This function is the inverse of parse_draco_uri() """ parts = [] if locale: parts.append(locale) if session: parts.append(session) if pathinfo: parts += [ part for part in pathinfo.split('/') if part ] pathinfo = '/'.join(parts) path = urimod.create_path_uri(directory, filename, pathinfo) uri = urimod.create_uri(scheme, host, path, args) return uri