+from django.contrib.auth.decorators import login_required, permission_required
+
+from django.core.urlresolvers import reverse
+from django.http import HttpResponseRedirect, HttpResponse, HttpResponseNotFound
+from django.utils import simplejson as json
+from django.views.generic.simple import direct_to_template
+from django.contrib.auth.decorators import login_required
+
+from explorer import forms, models
+from toolbar import models as toolbar_models
+
+from django.forms.util import ErrorList
+
+import wlrepo
+
+#
+# Some useful decorators
+
+def file_branch(fileid, user=None):
+ parts = fileid.split('$')
+ return ('personal_'+ user.username + '_' if user is not None else '') \
+ + 'file_' + parts[0]
+
+def file_path(fileid):
+ return 'pub_'+fileid+'.xml'
+
+def with_repo(view):
+ """Open a repository for this view"""
+ def view_with_repo(request, *args, **kwargs):
+ kwargs['repo'] = wlrepo.open_library(settings.REPOSITORY_PATH, 'hg')
+ return view(request, *args, **kwargs)
+ return view_with_repo