>From my code. Feel free if you want to make a reciepe out of it.

class UserForm(Form):
    title = TextField(u'Title', [validators.required(),
validators.length(max=150)])
    description = TextAreaField(u'Content', [validators.required()])
    genre = SelectField(u'Genre', [validators.required()])
    subgenre = TextField(u'Subgenres', [validators.length(max=250)])
    url = TextField(u'URL', [validators.required()])

    form = forms.UserForm(req.form)
    errors = []

    #Add the choices to the genre list.
    form.genre.choices = [(genre.key().name().lower(), genre.name) for
genre in Genre.all().fetch(1000)]
    form.genre.data = 'Psy'.lower()

-- In your view method. Though uses werkzeug (Glashammer) instead of
Django or web.py

    # Validate form
    if req.method == 'POST' and form.validate():
        title_slug = slugify(req.form.get('title'))

        try:
            user  = users.get_current_user()    
            title = req.form.get('title')
            url   = req.form.get('url')
            userpref  = models.UserPref(key_name=title_slug),
                        title=req.form.get('title'),
                        description = req.form.get('description'),
                        user = users.get_current_user(),
                        genre=Genre.get_by_key_name(req.form.get('genre')),
                        url=req.form.get('url'))

            subgenres = req.form.get('subgenre')
            userpref.subgenres = [genre.lower().strip() for genre in
subgenres.split(' ')]s.py
            userpref.put()

        except BadValueError, e:
            #We need to show the error
.           #Your error checking,
        else:
            return redirect(userpref.permalink)

On Tue, Jun 30, 2009 at 5:51 PM, Italo Maia<[email protected]> wrote:
>
> Does anyone have a good recepie for wtforms+appengine integration?
> Like, form generation or request parameters fetch and stuff?
>
> >
>



-- 
Ritesh
http://www.riteshn.com

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to