On Sep 27, 7:09 am, Steve Holden <[EMAIL PROTECTED]> wrote:
> > I couldn't get that to work, but the following did:
>
> >    (r'^contact/$', login_required(ContactFormWizard([ContactFormPartOne,  
> > ContactFormPartTwo])))
>
> > But it complained it couldn't find the __name__ attribute, so I added  
> > the following to my FormWizard subclass:
>
> >    def __name__(self):
> >            """When using decorators, Django tries to get the name of the 
> > function
> >            and since we're a class, we'll fail. So add this method to  
> > compensate."""
> >            return 'OrderFormWizard'
>
> > I have no idea how if this will create problems for us in the future,  
> > but it does actually work.
>
> Well that's good, I guess, but I had overlooked the fact that FormWizard
> is a class. I believe class decorators will be legal in 2.6. So what you
> managed to do correctly was to manually decorate the instance, which is
> what gets called when the URL is dispatched.

FYI, like the FormPreview class in the formtools app, the FormWIzard
class has a __call__() method, which is why the decorator works.  The
URL dispatcher automatically executes this method when your regex
matches.  As a result, instances of the FormWizard class act just like
views.  So in 2.6, even though class decorators will be legal, you'll
still have to have a __call__ method on objects you want to call from
urls.py.

-Aaron
--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to