Move default text handling outside of get_raw_body()
authorBernie Innocenti <bernie@codewiz.org>
Sat, 15 Oct 2011 01:30:21 +0000 (21:30 -0400)
committerBernie Innocenti <bernie@codewiz.org>
Sat, 15 Oct 2011 01:30:21 +0000 (21:30 -0400)
geekigeeki.py

index c0bb53e0eabdd0379dd27b5ec7570ff7ea264241..4a7ffea7e6250f80fe59a09e9053cf11f4128b4e 100755 (executable)
@@ -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("</body></html>")
+        print('</body></html>')
 
     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),