def script_name():
return os.environ.get('SCRIPT_NAME', '')
+#TODO: move post-edit hook into wiki, then kill this
def script_path():
return os.path.split(os.environ.get('SCRIPT_FILENAME', ''))[0]
else:
return os.environ.get('QUERY_STRING', '') or 'FrontPage'
-def privileged_path():
- return config_get('privileged_url') or script_name()
+def is_privileged():
+ purl = config_get('privileged_url')
+ return (purl is not None) and os.environ.get('SCRIPT_URI', '').startswith(purl)
def remote_user():
user = os.environ.get('REMOTE_USER', '')
def relative_url(pathname, privileged=False):
if not is_external_url(pathname):
if privileged:
- url = privileged_path()
+ url = config_get('privileged_url') or script_name()
else:
url = script_name()
pathname = url + '/' + pathname
rel, href = link
print(' <link rel="%s" href="%s" />' % (rel, relative_url(href)))
- editable = name and writable and config_get('privileged_url') is not None
+ editable = name and writable and is_privileged()
if editable:
print(' <link rel="alternate" type="application/x-wiki" title="Edit this page" href="%s" />' \
% relative_url('?a=edit&q=' + name, privileged=True))
def save(self, newdata, changelog):
if not self.can_write():
- self.msg_text = 'Write access denied by ACLs'
- self.msg_type = 'error'
+ self.msg_text = 'Write access denied by Access Control List'
+ return
+ if not is_privileged():
+ self.msg_text = 'Unauthenticated access denied'
return
self._write_file(newdata)