On Saturday 27 June 2009 13:49:28 Brian May wrote: > On Sat, Jun 27, 2009 at 01:17:42PM +0530, Kenneth Gonsalves wrote: > > decorator--------------------------- > > > > class menu_enabled(object): > > def __init__(self,menuname): > > self.menuname = menuname > > > > def __call__(self,f): > > def wrapper(*args,**kwargs): > > try: > > mn = Menuitem.objects.get(name__iexact = self.menuname) > > f(*args,**kwargs) > > except: > > msg = _("You are already registered") > > return HttpResponseRedirect("/2009/message/%s/" % msg) > > > > return wrapper > > ------end of decorator > > > > obviously this f(*args,**kwargs) is not the correct way to call the view. > > Any clues? > > I have never written a decorator, so I may be completely off here, however > shouldn't that be "return f(*args,**kwargs)"? ie. don't you need to return > the value?
Well this is the first time I am writing a decorator for use! and no - this works in python, but in django there is some specific syntax for calling a view function -- regards kg http://lawgon.livejournal.com --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@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 -~----------~----~----~----~------~----~------~--~---