X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=myslice%2Fviewutils.py;h=7fbdc77f2f067f227e97880ebc066923b5257c7f;hb=93ac75da63ac1891764f3ddcb82aebe9b12a2660;hp=cb1b31b93e9f53540d2324f9c88abca6be3fb437;hpb=f80330db2c8f4fe168dc45fc38165b9410f8230a;p=unfold.git diff --git a/myslice/viewutils.py b/myslice/viewutils.py index cb1b31b9..7fbdc77f 100644 --- a/myslice/viewutils.py +++ b/myslice/viewutils.py @@ -1,9 +1,5 @@ # a set of utilities to help make the global layout consistent across views -from django.http import HttpResponseRedirect - -from manifold.manifoldresult import ManifoldException - def topmenu_items (current,request=None): has_user=request.user.is_authenticated() result=[] @@ -34,29 +30,3 @@ def the_user (request): else: return request.user.email - -# a decorator for view classes to catch manifold exceptions -# by design views should not directly exercise a manifold query -# given that these are asynchroneous, you would expect a view to just -# return a mundane skeleton -# however of course this is not always true, and if only for metadata -# that for some reason we deal with some other way, it is often a good idea -# for a view to monitor these exceptions - and to take this opportunity to -# logout people if it's a matter of expired session for example -def logout_on_manifold_exception (view_as_a_function): - def wrapped (request, *args, **kwds): - try: - return view_as_a_function(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) - return HttpResponseRedirect ('/') - except Exception, e: - # xxx we need to sugarcoat this error message in some error template... - print "Unexpected exception",e - import traceback - traceback.print_exc() - return HttpResponseRedirect ('/') - return wrapped -