def action_edit_rules(self, req, resource_fetcher): if not edit_local_files(req.environ): return exc.HTTPForbidden('Editing is forbidden') rules = self.rule_getter(resource_fetcher, self.app, req) file_url = rules.source_location if not file_url.startswith('file:'): return exc.HTTPForbidden('The rule location (%s) is not a local file' % file_url) filename = url_to_filename(file_url) app = Editor(filename=filename, force_syntax='delivxml', title='rule file %s' % os.path.basename(filename)) return app
def action_edit_rules(self, req, resource_fetcher): if not edit_local_files(req.environ): return exc.HTTPForbidden('Editing is forbidden') rules = self.rule_getter(resource_fetcher, self.app, req) file_url = rules.source_location if not file_url.startswith('file:'): return exc.HTTPForbidden( 'The rule location (%s) is not a local file' % file_url) filename = url_to_filename(file_url) app = Editor(filename=filename, force_syntax='delivxml', title='rule file %s' % os.path.basename(filename)) return app
def edit_app(self, environ, start_response): try: if not self.editable: raise exc.HTTPForbidden('This proxy is not editable="1"') if not edit_local_files(environ): raise exc.HTTPForbidden("Editing is forbidden") try: dest_href = uri_template_substitute(self.dest.href, dict(here=posixpath.dirname(self.source_location))) except KeyError: raise exc.HTTPForbidden("Not a static location: %s" % self.dest.href) if not dest_href.startswith("file:/"): raise exc.HTTPForbidden("Not local: %s" % self.dest.href) filename = url_to_filename(dest_href) editor = Editor(base_dir=filename) return editor(environ, start_response) except exc.HTTPException, e: return e(environ, start_response)
def edit_app(self, environ, start_response): try: if not self.editable: raise exc.HTTPForbidden('This proxy is not editable="1"') if not edit_local_files(environ): raise exc.HTTPForbidden('Editing is forbidden') try: dest_href = uri_template_substitute( self.dest.href, dict(here=posixpath.dirname(self.source_location))) except KeyError: raise exc.HTTPForbidden('Not a static location: %s' % self.dest.href) if not dest_href.startswith('file:/'): raise exc.HTTPForbidden('Not local: %s' % self.dest.href) filename = url_to_filename(dest_href) editor = Editor(base_dir=filename) return editor(environ, start_response) except exc.HTTPException, e: return e(environ, start_response)
def format_html_log(self): """Formats this log object as HTML""" content_source = self.link_to(self.request.url, source=True) content_browse = self.link_to(self.request.url, browse=True) theme_browse = self.link_to(self.theme_url, browse=True) if edit_local_files(self.request.environ): ## FIXME: also test for the local-ness of the file edit_rules = (self.request.environ['deliverance.base_url'] + '/.deliverance/edit_rules') else: edit_rules = None return self.log_template.substitute( log=self, middleware=self.middleware, unthemed_url=self._add_notheme(self.request.url), theme_url=self._add_notheme(self.theme_url), content_source=content_source, content_browse=content_browse, theme_browse=theme_browse, edit_rules=edit_rules, **self.tags)