Application des patches crans.

darcs-hash:20070601130217-68412-6031a22f65c4203b17066a69c164031db0110c19.gz
This commit is contained in:
glondu 2007-06-01 15:02:17 +02:00
parent 329eea2862
commit d294a22d41
3 changed files with 68 additions and 2 deletions

View file

@ -8,7 +8,13 @@
"""
import re
from MoinMoin import user
from MoinMoin import user, search
#### HACK SAUVAGE 1/4
import sys
sys.path.append('/usr/scripts/gestion/')
from iptools import is_crans
#### FIN DU HACK 1/4
class AccessControlList:
''' Access Control List
@ -107,7 +113,10 @@ class AccessControlList:
Default: ["read", "write", "delete", "admin"]
'''
special_users = ["All", "Known", "Trusted"] # order is important
#special_users = ["All", "Known", "Trusted"] # order is important
#### HACK SAUVAGE 2/4
special_users = ["All", "Known", "Trusted", "Conf"]
#### FIN DU HACK 2/4
def __init__(self, request, lines=[]):
"""Initialize an ACL, starting from <nothing>.
@ -209,6 +218,8 @@ class AccessControlList:
return ''.join(["%s%s%s" % (b,l,e) for l in self.acl_lines])
def _special_All(self, request, name, dowhat, rightsdict):
if dowhat == "read" and self.is_page_public(request):
return True
return rightsdict.get(dowhat)
def _special_Known(self, request, name, dowhat, rightsdict):
@ -220,6 +231,11 @@ class AccessControlList:
return rightsdict.get(dowhat)
return None
#### HACK SAUVAGE 3/4
def _special_Conf(self, request, name, dowhat, rightsdict):
return request.cfg.acl_request(self, request, name, dowhat, rightsdict)
#### FIN DU HACK 3/4
def _special_Trusted(self, request, name, dowhat, rightsdict):
""" check if user <name> is known AND even has logged in using a password.
does not work for subsription emails that should be sent to <user>,
@ -233,6 +249,21 @@ class AccessControlList:
return self.acl_lines == other.acl_lines
def __ne__(self, other):
return self.acl_lines != other.acl_lines
#### HACK SAUVAGE 4/4
def is_page_public(self,request):
## On recherche si la page est publique
if not request.page:
return False
this_page = request.page.page_name
query = search.QueryParser().parse_query(u'CatégoriePagePublique')
page = search.Page(request, this_page)
result = query.search(page)
if result:
return True
else:
return False
#### FIN DU HACK 4/4
class ACLStringIterator: