On Fri, Mar 7, 2008 at 2:24 AM, halish <[EMAIL PROTECTED]> wrote:
>
>  Hello,
>  I'm currently developing a Pylons app with user registration. I have
>  already written the models and registration template with controller
>  (fields used in registration are: username, email and password x2).
>
>  I've read the FormEncode tutorial, but I'm not sure, whether this is
>  particularly what I need, ie. verifying the form against the database.
>
>  How would you do this? Maybe some AJAX?

What do you mean by verifying the form against the database?  To see
if the user typed the same values the database contains?  That could
be done by passing the database data in the 'state' argument, but you
wouldn't be able to use @validate because the current record isn't
known at that point, unless the validator itself figures out the
current record and queries for it.

Normally you create your form the traditional way, passing the
existing values from the controller to the template, and having the
template create the HTML controls with their value attributes.  Then
you render the form.  When the user submits the data, it goes through
@validate, which invokes the validator.  If there are errors, it
(@validate) calls the other action to create the form, runs the return
value through htmlfill to insert the existing values and error
messages, and sends that to the browser.  If there are no errors,
@validate puts the validated data in self.form_result and calls the
action method it's decorating.  The action should then copy the result
data into the database.  So there's normally no direct
validator-database interaction.

If you don't want to use @validate, you have to mimic some of that
behavior in the action.

-- 
Mike Orr <[EMAIL PROTECTED]>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" 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/pylons-discuss?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to