X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=unfold%2Floginrequired.py;h=92f9ddb4f8614718e1179601d93ed1975b32510c;hb=3d4eda1ced96e2fe552a07fd5014563351d8378e;hp=0f46ff79916a30697c4dde15da10f06efb8f8a05;hpb=31540dd504798e0aca69e10d8144fbedc5b16af8;p=myslice.git diff --git a/unfold/loginrequired.py b/unfold/loginrequired.py index 0f46ff79..92f9ddb4 100644 --- a/unfold/loginrequired.py +++ b/unfold/loginrequired.py @@ -6,6 +6,13 @@ from django.views.generic.base import TemplateView from manifold.manifoldresult import ManifoldException +### +# IMPORTANT NOTE +# the implementation of the classes in this file rely on redefining 'dispatch' +# for this reason if you inherit any of these, please do not redefine 'dispatch' yourself, +# but rather redefine 'get' and 'post' instead +### + ########## the base class for views that require a login class LoginRequiredView (TemplateView): @@ -26,13 +33,15 @@ class LoginRequiredView (TemplateView): def logout_on_manifold_exception (fun_that_returns_httpresponse): def wrapped (request, *args, **kwds): - print 'wrapped by logout_on_manifold_exception' +# print 'wrapped by logout_on_manifold_exception' try: return fun_that_returns_httpresponse(request,*args, **kwds) except ManifoldException, manifold_result: # xxx we need a means to display this message to user... from django.contrib.auth import logout - logout(request) + # in some unusual cases, this might fail + try: logout(request) + except: pass return HttpResponseRedirect ('/') except Exception, e: # xxx we need to sugarcoat this error message in some error template... @@ -51,3 +60,11 @@ class LoginRequiredAutoLogoutView (TemplateView): @method_decorator(login_required) def dispatch (self, request, *args, **kwds): return super(LoginRequiredAutoLogoutView,self).dispatch(request,*args,**kwds) + +# we have more and more views that actually send manifold queries +# so for these we need to protect against manifold exceptions +# even though login is not required +class FreeAccessView (TemplateView): + + def dispatch (self, request, *args, **kwds): + return super(FreeAccessView,self).dispatch(request,*args,**kwds)