+#
+# Some useful decorators
+#
+def with_repo(view):
+ """Open a repository for this view"""
+ def view_with_repo(request, *args, **kwargs):
+ kwargs['repo'] = hg.Repository(settings.REPOSITORY_PATH)
+ return view(request, *args, **kwargs)
+ return view_with_repo
+
+#
+def ajax_login_required(view):
+ """Similar ro @login_required, but instead of redirect,
+ just return some JSON stuff with error."""
+ def view_with_auth(request, *args, **kwargs):
+ if request.user.is_authenticated():
+ return view(request, *args, **kwargs)
+ # not authenticated
+ return HttpResponse( json.dumps({'result': 'access_denied'}) );
+ return view_with_auth
+
+#
+# View all files
+#