Piki is a minimal wiki
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

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()