Piki is a minimal wiki
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

access.py 900B

123456789101112131415161718192021222324252627
  1. class access_control(object):
  2. def __init__(self, request, rel_path):
  3. self._request = request
  4. self._rel_path = rel_path
  5. def may_read(self):
  6. return "private" not in self._rel_path or self.may_write()
  7. def may_write(self):
  8. # /!\ rel_path is the filsystem rel_path - caused by the flat folder structure /!\
  9. return self._request.user.is_authenticated and self._request.user.username in ['root', 'dirk']
  10. def may_read_attachment(self):
  11. return self.may_read()
  12. def may_modify_attachment(self):
  13. return self.may_write()
  14. def read_attachment(request, rel_path):
  15. # Interface for external module mycreole
  16. return access_control(request, rel_path).may_read_attachment()
  17. def modify_attachment(request, rel_path):
  18. # Interface for external module mycreole
  19. return access_control(request, rel_path).may_modify_attachment()