Re: deform: is it possible to invalidate a form / field manually ?

2012-02-08 Thread Eric Rasmussen
Hi everyone, I believe the question here is, how do I inject error messages into a Deform-rendered form from outside the Deform/Colander APIs? I run into this most often when trying to gracefully handle errors (such as database integrity errors) that are thrown after I've validated the form.

Re: deform: is it possible to invalidate a form / field manually ?

2012-02-08 Thread Jonathan Vanasco
thanks eric. that is what i'm talking about! i've got my version working with formencode. in addition to the gist above, i decided to just go ahead and set up pyramid_formencode_classic on pypi and github ( https://github.com/jvanasco/pyramid_formencode_classic ) if i have some time this

Re: deform: is it possible to invalidate a form / field manually ?

2012-02-08 Thread Jonathan Vanasco
actually, the param_source should support: GET POST params (GET POST) the idiomatic example would be an email verification routine- someone is emailed a message that contains the form submission in a GET query string, and a formerror would return to a 'blank' form that submits via POST -

Re: deform: is it possible to invalidate a form / field manually ?

2012-02-06 Thread Dirley
Excuse me if I'm missing something (I don't know formencode and also didn't read all your code), but couldn't you declare a callback within your view and set it as a validator of the field? Thus the validator could carry the context of the view. The colander.Function validator could be used for

Re: deform: is it possible to invalidate a form / field manually ?

2012-02-04 Thread Jonathan Vanasco
Well... I could probably do these validations within the validators, I just don't want to. I've got the gist ( https://gist.github.com/1734244 ) working pretty much perfectly to handle my needs right now. I dropped all the 'validators' handling, and am just limiting it to schemas -- because its

deform: is it possible to invalidate a form / field manually ?

2012-02-03 Thread Jonathan Vanasco
via FormEncode under Pylons, I was able to mark a valid field as invalid, and then reprint. i'm wondering if this is possible with deform. a pseudocode example of this in action would be something like this: def login(self): formLogin = deform.Form(FormLogin(_) posted =

Re: deform: is it possible to invalidate a form / field manually ?

2012-02-03 Thread cd34
You can set either a field validation: Validation function: database_username_re = re.compile('^[a-z0-9_]{2,16}$', re.IGNORECASE) def validate_database_param(param): if database_username_re.match(param): return True else: return unicode('Value must be between 2 and 16

Re: deform: is it possible to invalidate a form / field manually ?

2012-02-03 Thread cd34
Forgot to add: Validation on the field takes place on form submission. Validation on the Schema takes place after all field validations are validated. So, an error on a field where it has some constraint will not fire off your check on the Schema. So, if someone put a short password in, and you

Re: deform: is it possible to invalidate a form / field manually ?

2012-02-03 Thread Jonathan Vanasco
Thanks. I very much don't want to have that sort of pattern in programming though -- where the application logic becomes shifted into the form validation. I've run into too many issues with that making maintenance a nightmare, or causing 'expensive' calls to needlessly be made. I really want /

Re: deform: is it possible to invalidate a form / field manually ?

2012-02-03 Thread Jonathan Vanasco
hopefully someone will suggest a deform method... until then, i ported my modified version of the old pylons validation to pyramid... https://gist.github.com/1734244 - i didn't port the decorator, as i rarely use it [ and i couldn't figure out a good way to do it without mandating that a

Re: deform: is it possible to invalidate a form / field manually ?

2012-02-03 Thread Mike Orr
On Fri, Feb 3, 2012 at 5:22 PM, Jonathan Vanasco jonat...@findmeon.com wrote: hopefully someone will suggest a deform method... This sounds like the same situation I've sometimes encountered, that you need to do validation beyond what the field validator and schema validator can do. It can only