[Twisted-web] Forms - question

Maciej Kucharz m.kucharz at wheel.pl
Sun Nov 20 04:32:36 MST 2005


I have a question for users of "forms" (http://forms- 
I'm looking for a way to do something like this:

class UserAdd(forms.ResourceMixin, rend.Page):

     def __init__(self, user, step=1, *a, **k):
         apply(forms.ResourceMixin.__init__, (self, user) + a, k)
         self.user = user
         self.step = step

     def form_edit(self, ctx):

         return form

     def formSubmitted(self ,ctx, form, data):
        print form, data
        return UserAdd('myuser', self.step)

I want to render form, depend on "self.step"  (i want have a few form  
steps on my site).
In contruction like above on action submit i have neverending loop.

thanks, for any advice

PS. I simply want to have an effect like in "testformless.py" (from  
nevow examples):
class NameWizard(rend.Page):
     docFactory = loaders.stan(tags.html[tags.h1["What is your  
name"], webform.renderForms()])

     def bind_name(self, ctx):
         return [('name', annotate.String())]

     def name(self, name):
         return QuestWizard(name)

class QuestWizard(rend.Page):
     docFactory = loaders.stan(tags.html[tags.h1["What is your  
quest"], webform.renderForms()])

     def bind_quest(self, ctx):
         return [('quest', annotate.Choice(['Find the Grail', 'Get  
laid', 'Earn twenty bucks', 'Destroy the sun']))]

     def quest(self, quest):
         return FinalWizard((self.original, quest))


More information about the Twisted-web mailing list