Google Mail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
alternate @validate for review / submission
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  2 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Follow-up To:
Add Cc | Add Follow-up to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers that you hear
 
Jonathan Vanasco  
View profile   Translate to Translated (View Original)
 More options 2 Nov, 06:34
From: Jonathan Vanasco <jonat...@findmeon.com>
Date: Sun, 1 Nov 2009 22:34:49 -0800 (PST)
Local: Mon 2 Nov 2009 06:34
Subject: alternate @validate for review / submission
I redid the @validate decorator, because I hate it.

it seems to work, but needs some help.

i put it on pylonshq as a pastie here:
    http://pylonshq.com/pasties/4fb8ce88c6d42b2ee048cf0ef0e678c1

to note:

- decorating with @osn_validate is mostly backwards compatible
- - the main difference is that there is a gatekeeper functionality ,
set true to default.  the gatekeeper will cause an error if the form
doesn't process.  the concept is to get around issues where post_only
could be true, but an arg like "submit=true" is sent via get and
dispatches to your form submit anyways.

- osn_validate wraps osn_form_validator and osn_form_reprint

- osn_form_validator does two takes:
- - returns True or False based on it being valid or not
- - sets up self.osn_form on your controller.
- - you can also submit 'params' to it, to validate outside of get/
post args

osn_form is a osn_FormResults object.  it just stores the following
info:
- is_error
- is_parsed
- errors
- params
- results

why would we store that info ?

because then you can import osn_form_reprint into controllers and
then...

    self.osn_form.errors['age']= 'yay custom errors throws!'
    self.osn_form.errors['sex']= 'more than one!'
    self.osn_form.errors['language']= 'now i can make fun websites
easier!'
    return osn_form_reprint( self , 'print_function' )

a few other  things i did:
-  i changed "self" to "ControllerInstance" , because the term "self"
was confusing to me.
- osn_form is stashed as c. osn_form ; but the results & errors are
copied back to where @validate wants them too
- i created a ValidationStop exception to just stop validating when
needed.  an earlier version of this used it extensively, now its
barely used, but still useful

i'm sure this could be improved upon a bit!


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message, you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jonathan Vanasco  
View profile   Translate to Translated (View Original)
 More options 2 Nov, 06:36
From: Jonathan Vanasco <jonat...@findmeon.com>
Date: Sun, 1 Nov 2009 22:36:23 -0800 (PST)
Local: Mon 2 Nov 2009 06:36
Subject: Re: alternate @validate for review / submission
didn't realize the boilerplate copyright/license was on there... 50%
of that is pylons!

    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message, you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google