diff --git a/wiki/auth/categorie_public.py b/wiki/auth/categorie_public.py index 6a62070c..04a667b6 100644 --- a/wiki/auth/categorie_public.py +++ b/wiki/auth/categorie_public.py @@ -32,10 +32,31 @@ class PublicCategories(AnonymousAuth): def can_view(self, request): p = urlparse.urlparse(request.url) - categories = Page(request, p.path[1:]).getCategories(request) + if p.path[1:] == "": + return False + if request.page is not None: + sys.stderr.write("Getting page from cache") + page = request.page + else: + page = Page(request, unicode(urllib.unquote(p.path[1:]),'utf-8')) + acl = page.getACL(request) + if acl.acl and [a[0] for a in acl.acl if a[0] == 'All' and a[1].get('read',False)]: + sys.stderr.write("acl All:read\n") + return False + categories = page.getCategories(request) + if categories: + for cat in self.pub_cats: + if cat in categories: + sys.stderr.write("%r dans la page %r\n" % (cat, p.path[1:])) + return True + else: + sys.stderr.write("categories is empty, searching in page body of %s\n" % p.path[1:]) + body = page.getPageText() + for cat in self.pub_cats: + if cat in body: + sys.stderr.write("%r dans la page %r\n" % (cat, p.path[1:])) + return True - for cat in self.pub_cats: - if cat in categories: - return True + sys.stderr.write("%r n'est pas dans la page %r, %r\n" % (cat, p.path[1:], categories)) return False