From e31aacbe31f2dff141354b7c4d97a16bb86978e1 Mon Sep 17 00:00:00 2001 From: Bernie Innocenti Date: Fri, 14 Oct 2011 21:30:21 -0400 Subject: [PATCH] Move default text handling outside of get_raw_body() --- geekigeeki.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/geekigeeki.py b/geekigeeki.py index c0bb53e..4a7ffea 100755 --- a/geekigeeki.py +++ b/geekigeeki.py @@ -568,14 +568,12 @@ class Page: return True return False - def get_raw_body(self, default=None): + def get_raw_body(self): try: return open(self._filename(), 'rb').read() except IOError, err: if err.errno == errno.ENOENT: - if default is None: - default = '//[[%s?a=edit|Describe %s]]//' % (self.page_name, self.page_name) - return default + return '' if err.errno == errno.EISDIR: return self.format_dir() raise err @@ -720,13 +718,16 @@ class Page: link_inline(footer, kvargs = { 'LAST_MODIFIED': strftime(config_get('datetime_fmt', '%Y-%m-%dT%I:%M:%S%p'), localtime(self._mtime())) }) - print("") + print('') def send_naked(self, kvargs=None): if self.can_read(): - WikiFormatter(self.get_raw_body(), kvargs).print_html() + body = self.get_raw_body() + if not body: + body = "//[[%s?a=edit|Describe %s]]//" % (self.page_name, self.page_name) + WikiFormatter(body, kvargs).print_html() else: - send_guru("Read access denied by ACLs", "notice") + send_guru('Read access denied by ACLs', 'notice') def send(self): #css foo.css @@ -758,7 +759,7 @@ class Page: return if preview is None: - preview = self.get_raw_body(default='') + preview = self.get_raw_body() link_inline("sys/EditPage", kvargs = { 'EDIT_BODY': cgi.escape(preview), -- 2.25.1