def send_httperror(status="403 Not Found", query=""):
print("Status: %s" % status)
+ page = Page()
send_title(None, msg_text=("%s: on query '%s'" % (status, query)))
- send_footer()
+ page.send_footer()
def link_tag(dest, text=None, privileged=False, **kvargs):
if text is None:
search_re = re.compile(r"^\b((([A-Z][a-z0-9]+){2,}/)*([A-Z][a-z0-9]+){2,})\b$")
return sorted(filter(search_re.match, os.listdir(dirname or '.')))
-def send_footer(mtime=None, footer="sys/footer"):
- if config_get('debug_cgi', False):
- cgi.print_arguments()
- cgi.print_form(form)
- cgi.print_environ()
- if footer != "off":
- link_inline(footer, kvargs = {
- 'LAST_MODIFIED': strftime(config_get('datetime_fmt', '%a %d %b %Y %I:%M %p'), localtime(mtime))
- })
- print("</body></html>")
-
def _macro_ELAPSED_TIME(*args, **kvargs):
return "%03f" % (clock() - start_time)
print('</p></div>')
class Page:
- def __init__(self, page_name):
+ def __init__(self, page_name="Limbo"):
self.page_name = page_name.rstrip('/');
self.msg_text = ''
self.msg_type = 'error'
def can_read(self):
return self.can("read", True)
+ def send_footer(mtime=None, footer="sys/footer"):
+ if config_get('debug_cgi', False):
+ cgi.print_arguments()
+ cgi.print_form(form)
+ cgi.print_environ()
+ if footer != "off":
+ link_inline(footer, kvargs = {
+ 'LAST_MODIFIED': strftime(config_get('datetime_fmt', '%a %d %b %Y %I:%M %p'), localtime(mtime))
+ })
+ print("</body></html>")
+
def send_naked(self, kvargs=None):
if self.can_read():
WikiFormatter(self.get_raw_body(), kvargs).print_html()
msg_text=self.msg_text, msg_type=self.msg_type, writable=self.can_write(), mtime=self._mtime(),
navbar=self.pragma("navbar", "on"))
self.send_naked()
- send_footer(mtime=self._mtime(), footer=self.pragma("footer", "sys/footer"))
+ self.send_footer(mtime=self._mtime(), footer=self.pragma("footer", "sys/footer"))
def send_editor(self, preview=None):
send_title(None, 'Edit ' + self.split_title(), msg_text=self.msg_text, msg_type=self.msg_type)
print("<div class='preview'>")
WikiFormatter(preview).print_html()
print("</div>")
- send_footer()
+ self.send_footer()
def send_raw(self, mimetype='text/plain', args=[]):
if not self.can_read():
send_guru(msg_text, "error")
else:
send_title(None, msg_text=msg_text)
- send_footer()
+ Page().send_footer()
sys.stdout.flush()