X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=myslice%2Fviewutils.py;h=eaa2dcb5e885adbfedda93d24d5589b6038a0822;hb=fc29adc67fe378ae2b962fe99bd2bc1513d9dffd;hp=3fa8ceba4d17b22647dadcb886d5bbdf78f182a7;hpb=f8ab9d13886a50daf7500e0b4d669e37f91ab4de;p=myslice.git diff --git a/myslice/viewutils.py b/myslice/viewutils.py index 3fa8ceba..eaa2dcb5 100644 --- a/myslice/viewutils.py +++ b/myslice/viewutils.py @@ -23,36 +23,9 @@ def topmenu_items (current,request=None): return result def the_user (request): - "This code below is broken" + "retrieves logged in user's email, or empty string" if not request.user.is_authenticated (): -# print 'void user!' return '' 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 -