I find all my view method have identical code in start and in end:

anyway to avoid repetition...?

Example:

def typical_view_method(request):

   Check if user is authenticated.
   Get user and group
   Get some session variables

   try:
         Method specific logic
   except Exception, e:
         view_logger.error('error in typical_view_method:%s', e)

    response = HttpResponse(json_data, mimetype = 'application/json')
    response.__setitem__('Cache-Control', 'no-store,no-cache')
    response.__setitem__('Pragma', 'no-cache')
    response.__setitem__('Expires', '-1')
    return response

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to