Questions tagged [formencode]

FormEncode is a python web validation and form generation package.

FormEncode validation can be used separately from the form generation. The validation works on compound data structures, with all parts being nestable. It is separate from HTTP or any other input mechanism.

FormEncode has two parts:

  • A set of validators used together to create schemas, which convert form data back and forth between Python objects and their corresponding form values
  • A tool called HTML Fill that takes an HTML form and parses it for form fields, filling in values and error messages as it goes from Python objects

Ian Bicking is the author of FormEncode.

Resources: http://formencode.org/ http://pylonsbook.com/en/1.1/working-with-forms-and-validators.html#introducing-formencode

43 questions
38
votes
5 answers

Recommendation for python form validation library

I would like a form validation library that 1.separate html generation from form validation; 2.validation errors can be easily serialized, eg. dumped as a json object What form validation library would you choose in a python web project?
satoru
  • 31,822
  • 31
  • 91
  • 141
11
votes
3 answers

Transform a python dict into string compatible with Content-Type:"application/x-www-form-urlencoded"

I'd like to take a python dict object and transform it into its equivalent string if it were to be submitted as html form data. The dict looks like this: { 'v_1_name':'v_1_value' ,'v_2_name':'v_2_value' } I believe the form string should look…
Chris Dutrow
  • 48,402
  • 65
  • 188
  • 258
4
votes
1 answer

ForEach and NestedVariables in FormEncode to create array of form items in Pyramid

I'm using Pyramid with FormEncode to try and create and validate a list of addresses. I'm using pyramid_simpleform and have been looking at this tutorial http://jimmyg.org/blog/2007/multiple-checkboxes-with-formencode.html and this previous question…
Jen Z
  • 205
  • 1
  • 2
  • 9
4
votes
7 answers

Decoding query strings in PHP

Okay, so I've written a REST API implementation using mod_rewrite and PHP. I'm accepting a query string via the body of HTTP DELETE requests (... collective groan?). Arguments about the wisdom of both previous statements aside, what I've found is…
codemonkey
  • 2,661
  • 2
  • 24
  • 34
3
votes
1 answer

Formencode in pyramid and pyramid_simplefrom: set fixed locale

I know I can run the following code in python shell: import formencode ne = formencode.validators.NotEmpty() formencode.api.set_stdtranslation(languages=["it"]) try: ne.to_python("") except formencode.api.Invalid, e: print str(e) and get…
neurino
  • 11,500
  • 2
  • 40
  • 63
3
votes
1 answer

formencode Schema add fields dynamically

Let's take, for example, a User Schema where the site admin sets the number of requested phone numbers: class MySchema(Schema): name = validators.String(not_empty=True) phone_1 = validators.PhoneNumber(not_empty=True) phone_2 =…
neurino
  • 11,500
  • 2
  • 40
  • 63
3
votes
1 answer

Using Both jQuery And FormEncode To Validate Forms Without Repetition

I'm working on a Pylons-based web app. Because I am sane, I am using jQuery (and plugins) instead of writing raw JavaScript. I am also using FormEncode to validate forms for my app (especially new user registration). FormEncode is great for…
Brighid McDonnell
  • 4,293
  • 4
  • 36
  • 61
2
votes
2 answers

Pylons FormEncode with an array of form elements

I have a Pylons app and am using FormEncode and HtmlFill to handle my forms. I have an array of text fields in my template (Mako) Yardage ${h.text('yardage[]', maxlength=3, size=3)} ${h.text('yardage[]',…
baudtack
  • 29,062
  • 9
  • 53
  • 61
2
votes
1 answer

Python django sqlalchemy and formencode

I create a table in database using sqlalchemy and now want to make a form according to the database using django and valid it use formencode. (mention I use Django Web Framework) The python code is below from sqlalchemy import * from sqlalchemy.orm…
Sabbir
  • 41
  • 5
2
votes
2 answers

formencode nesting custom validators within schema

I want to nest my custom validators within my schema, like this: MySchema(Schema): class MyValidator(validators.FancyValidator): def _to_python(self, value, state): ... class MyOtherValidator(validators.FancyValidator): …
steve
  • 423
  • 6
  • 16
2
votes
1 answer

formencode conditional validation

how do i validate a field conditionally based on the presence of another field. for example, only make "state" required only if "country" is "US". thanks, steve EDIT: so i figured to do this: chained_validators =…
steve
  • 423
  • 6
  • 16
2
votes
2 answers

Rerendering a Pylons form with a querystring parameter after FormEncode validation fails

My question may be the same as this, but the suggested answer didn't seem to help (or I didn't understand it correctly): Pylons FormEncode @validate decorator pass parameters into re-render action I have a simple form that takes a required…
Hollister
  • 3,758
  • 2
  • 20
  • 22
2
votes
0 answers

FormEncode is returning my file upload as a Unicode object - How fix?

class MyValidator(formencode.Schema): allow_extra_fields = True filter_extra_fields = True name =…
dave
  • 7,717
  • 19
  • 68
  • 100
2
votes
1 answer

Using Pylons validate and authenticate_form decorator

The validate and authenticate_form decorators don't seem to play nice together. This is my template: Test ${h.secure_form('/meow/do_post')}
lmz
  • 1,560
  • 1
  • 9
  • 19
2
votes
1 answer

Formencode Compound Validators Inside Schemas

I'm trying to do something that I think should be straightforward, but I'm running into problems getting it to work. Here's what I have right now, which works as expected. some_schema = Schema( multiples = ForEach(UnicodeString(),…
crlane
  • 521
  • 5
  • 16
1
2 3