From: Bernie Innocenti Date: Sat, 15 Oct 2011 01:30:21 +0000 (-0400) Subject: Move default text handling outside of get_raw_body() X-Git-Url: https://codewiz.org/gitweb?a=commitdiff_plain;h=e31aacbe31f2dff141354b7c4d97a16bb86978e1;p=geekigeeki.git Move default text handling outside of get_raw_body() --- 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),