Mercurial > hg
changeset 14058:3233b39d756f
hgweb: initialize permhooks at definition time
This is simpler than creating it empty and then appending the default
checkauthz hook 50 lines below.
author | Martin Geisler <mg@lazybytes.net> |
---|---|
date | Sat, 30 Apr 2011 13:47:22 +0200 |
parents | ef1217a7f206 |
children | c0e29e10b9ef |
files | mercurial/hgweb/common.py |
diffstat | 1 files changed, 8 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/hgweb/common.py Sat Apr 30 06:58:22 2011 -0700 +++ b/mercurial/hgweb/common.py Sat Apr 30 13:47:22 2011 +0200 @@ -17,12 +17,6 @@ HTTP_METHOD_NOT_ALLOWED = 405 HTTP_SERVER_ERROR = 500 -# Hooks for hgweb permission checks; extensions can add hooks here. Each hook -# is invoked like this: hook(hgweb, request, operation), where operation is -# either read, pull or push. Hooks should either raise an ErrorResponse -# exception, or just return. -# It is possible to do both authentication and authorization through this. -permhooks = [] def checkauthz(hgweb, req, op): '''Check permission for operation based on request data (including @@ -65,8 +59,14 @@ if not result: raise ErrorResponse(HTTP_UNAUTHORIZED, 'push not authorized') -# Add the default permhook, which provides simple authorization. -permhooks.append(checkauthz) +# Hooks for hgweb permission checks; extensions can add hooks here. +# Each hook is invoked like this: hook(hgweb, request, operation), +# where operation is either read, pull or push. Hooks should either +# raise an ErrorResponse exception, or just return. +# +# It is possible to do both authentication and authorization through +# this. +permhooks = [checkauthz] class ErrorResponse(Exception):