Fix ACLs
authorBernardo Innocenti <bernie@codewiz.org>
Sun, 23 Sep 2007 06:29:45 +0000 (08:29 +0200)
committerBernardo Innocenti <bernie@codewiz.org>
Sun, 23 Sep 2007 06:29:45 +0000 (08:29 +0200)
geekigeeki.py

index 9fd1adf5a139c1ba32152a9eb6270b2847f8227b..0c1423a97d7534e64d9e9da53cf64e3578e641a5 100755 (executable)
@@ -219,9 +219,6 @@ def do_raw(pagename):
     Page(pagename).send_raw()
 
 def do_savepage(pagename):
-    if privileged_url is None:
-        raise 'editing disallowed for ' + pagename
-
     global form
     pg = Page(pagename)
     if 'preview' in form:
@@ -230,7 +227,7 @@ def do_savepage(pagename):
         pg.save_text(form['savetext'].value)
         pg.send_page()
     elif 'cancel' in form:
-        pg.msg = 'Editing cancelled'
+        pg.msg = 'Editing canceled'
         pg.msg_type = 'notice'
         pg.send_page()
     else:
@@ -592,7 +589,6 @@ class Page:
             else:
                 return link_tag(word, word, 'nonexistent')
 
-
     def get_raw_body(self):
         try:
             return open(self._text_filename(), 'rt').read()
@@ -651,7 +647,7 @@ class Page:
         if self.can_read():
             PageFormatter(self.get_raw_body()).print_html()
         else:
-            print "<p>This page is not visible to you</p>"
+            send_guru("Read access denied by ACLs", "notice")
         send_footer(page_name, self._last_modified())
 
     def _last_modified(self):
@@ -663,6 +659,9 @@ class Page:
 
     def send_editor(self, preview=None):
         send_title(None, 'Edit ' + self.split_title(), msg=self.msg, msg_type=self.msg_type)
+        if not self.can_write():
+            send_guru("Write access denied by ACLs", "error")
+            return
 
         print ('<p><b>Editing ' + self.page_name
             + ' for ' + cgi.escape(remote_user())
@@ -687,6 +686,9 @@ class Page:
         send_footer(self.page_name)
 
     def send_raw(self):
+        if not self.can_read():
+            send_title(None, msg='Read access denied by ACLs', msg_type='notice')
+            return
         emit_header("text/plain")
         print self.get_raw_body()
 
@@ -703,6 +705,11 @@ class Page:
         os.rename(tmp_filename, text)
 
     def save_text(self, newtext):
+        if not self.can_write():
+            self.msg = 'Write access denied by ACLs'
+            self.msg_type = 'error'
+            return
+
         self._write_file(newtext)
         rc = 0
         if post_edit_hook:
@@ -721,7 +728,7 @@ class Page:
             if msg:
                 self.msg += 'Output follows:\n' + msg
         else:
-            self.msg = 'Thankyou for your contribution.  Your attention to detail is appreciated.'
+            self.msg = 'Thank you for your contribution.  Your attention to detail is appreciated.'
             self.msg_type = 'success'
 
 def send_verbatim(filename, mime_type='application/octet-stream'):