Django provides a few decorators that remove alot of that repetitive code. Check the auth section for the logged in decorator
Vitaly Babiy On Sat, Apr 10, 2010 at 11:58 PM, ydjango <neerash...@gmail.com> wrote: > 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<django-users%2bunsubscr...@googlegroups.com> > . > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > > -- 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.