Factorisation des hacks dans l'optique d'une ferme de wiki
darcs-hash:20061209174936-9e428-6bfb1f8a82f742f51f28a46e459fe9a2ba70b27a.gz
This commit is contained in:
parent
6fb59f5a0f
commit
1b449c891f
3 changed files with 26 additions and 47 deletions
|
@ -119,7 +119,7 @@ class AccessControlList:
|
|||
|
||||
#special_users = ["All", "Known", "Trusted"]
|
||||
#### HACK SAUVAGE 2/4
|
||||
special_users = ["All", "Known", "Trusted", "Crans", "NoCrans"]
|
||||
special_users = ["All", "Known", "Trusted", "Conf"]
|
||||
#### FIN DU HACK 2/4
|
||||
|
||||
def __init__(self, request, lines=[]):
|
||||
|
@ -226,7 +226,7 @@ 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 is_page_public(request):
|
||||
if dowhat == "read" and self.is_page_public(request):
|
||||
return True
|
||||
return rightsdict.get(dowhat)
|
||||
|
||||
|
@ -240,27 +240,8 @@ class AccessControlList:
|
|||
return None
|
||||
|
||||
#### HACK SAUVAGE 3/4
|
||||
def _requete_interne(self, request):
|
||||
try:
|
||||
if str(request.__class__)=='MoinMoin.request.RequestCLI' or is_crans(request.remote_addr) and (request.remote_addr != u'138.231.136.3' or is_crans(request.mpyreq.headers_in['X-Forwarded-For'].split(",")[-1].strip())):
|
||||
return True
|
||||
except:
|
||||
pass
|
||||
|
||||
return False
|
||||
|
||||
|
||||
def _special_Crans(self, request, name, dowhat, rightsdict):
|
||||
if self._requete_interne(request):
|
||||
return rightsdict.get(dowhat)
|
||||
return None
|
||||
|
||||
def _special_NoCrans(self, request, name, dowhat, rightsdict):
|
||||
if dowhat == "read" and is_page_public(request):
|
||||
return True
|
||||
if not self._requete_interne(request):
|
||||
return rightsdict.get(dowhat)
|
||||
return None
|
||||
def _special_Conf(self, request, name, dowhat, rightsdict):
|
||||
return self.cfg.acl_request(self, request, name, dowhat, rightsdict)
|
||||
#### FIN Du HACK 3/4
|
||||
|
||||
def _special_Trusted(self, request, name, dowhat, rightsdict):
|
||||
|
@ -276,6 +257,22 @@ 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:
|
||||
|
@ -392,18 +389,3 @@ def parseACL(request, body):
|
|||
acl_lines.append(args)
|
||||
return AccessControlList(request, acl_lines)
|
||||
|
||||
#### HACK SAUVAGE 4/4
|
||||
def is_page_public(request):
|
||||
#return True
|
||||
## 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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue