[PATCH 1 of 1] hgweb: add support for extension provided check_perm hooks

Sune Foldager cryo at cyanite.org
Fri Nov 6 07:39:37 CST 2009


# HG changeset patch
# User Sune Foldager <cryo at cyanite.org>
# Date 1257514453 -3600
# Node ID 7452d7545527c2339c6212bb5921d4e21eeca926
# Parent  732fc0e9d411e0b94e56779d4ac053ceac0349e4
hgweb: add support for extension provided check_perm hooks

diff --git a/mercurial/hgweb/common.py b/mercurial/hgweb/common.py
--- a/mercurial/hgweb/common.py
+++ b/mercurial/hgweb/common.py
@@ -16,6 +16,8 @@
 HTTP_METHOD_NOT_ALLOWED = 405
 HTTP_SERVER_ERROR = 500
 
+checkpermhooks = []
+
 class ErrorResponse(Exception):
     def __init__(self, code, message=None, headers=[]):
         Exception.__init__(self)
diff --git a/mercurial/hgweb/hgweb_mod.py b/mercurial/hgweb/hgweb_mod.py
--- a/mercurial/hgweb/hgweb_mod.py
+++ b/mercurial/hgweb/hgweb_mod.py
@@ -8,7 +8,7 @@
 
 import os
 from mercurial import ui, hg, hook, error, encoding, templater
-from common import get_mtime, ErrorResponse
+from common import get_mtime, ErrorResponse, checkpermhooks
 from common import HTTP_OK, HTTP_BAD_REQUEST, HTTP_NOT_FOUND, HTTP_SERVER_ERROR
 from common import HTTP_UNAUTHORIZED, HTTP_METHOD_NOT_ALLOWED
 from request import wsgirequest
@@ -278,6 +278,8 @@
         authentication info). Return if op allowed, else raise an ErrorResponse
         exception.'''
 
+        for hook in checkpermhooks:
+            hook(self, req, op)
         user = req.env.get('REMOTE_USER')
 
         deny_read = self.configlist('web', 'deny_read')


More information about the Mercurial-devel mailing list