+ return rc.FORBIDDEN
+
+
+def validate_form(formclass, source='GET'):
+
+ def decorator(func):
+ @wraps(func)
+ def decorated(self, request, * args, ** kwargs):
+ form = formclass(getattr(request, source), request.FILES)
+
+ if not form.is_valid():
+ errorlist = [{'field': k, 'errors': e} for k, e in form.errors.items()]
+ return api.response.BadRequest().django_response(errorlist)
+
+ kwargs['form'] = form
+ return func(self, request, * args, ** kwargs)
+ return decorated
+ return decorator
+
+def hglibrary(func):
+ @wraps(func)
+ def decorated(self, *args, **kwargs):
+ l = MercurialLibrary(settings.REPOSITORY_PATH)
+ kwargs['lib'] = l
+ return func(self, *args, **kwargs)
+ return decorated
+
+
+
+