Questions tagged [colander]

Colander is a simple framework for validating, serializing and deserializing of data obtained via XML, JSON, an HTML form post or any other equally simple data structure.

The colander python package allows you to:

  • Define a schema declaratively (as a series of Python classes), or imperatively (with a series of function calls).
  • Deserialize a structure of simple types (sequences, mappings, numbers, strings) to produce objects conforming to your schema. The input is validated automatically.
  • Serialize objects conforming to the schema to a simple python structure, suitable for conversion to JSON, XML or HTML form data.

Colander is a good basis for form generation systems, data description systems, and configuration systems.

72 questions
1
vote
0 answers

How to transfer uneditable data with form with colander/deform (pyramid)

I have a small series of forms. The first accepts two fields, a record ID and an institution ID which need to be passed onto the next form as static information, but needs to be passed together with the rest of the data from the second form which…
user632657
  • 473
  • 3
  • 10
1
vote
1 answer

Deform 2 / colander schema with two tabs does not even validate

Trying to make a form with two tabs (in imperative style) for deform 2, colander 1.0. The idea of the form is to choose between adding webpage and it's title manually, or alternatively a feed URL: @property def webpage_form(self): schema =…
Roman Susi
  • 4,135
  • 2
  • 32
  • 47
1
vote
1 answer

Impreratively creating sequence of mapping schemas in Colander and Deform

I am constructing a page where user can leave reviews for any number of products in Colander and Deform. I have grasped all the required elements, but I have still some issues of connecting the dots. Specifically, how I can imperatively…
Mikko Ohtamaa
  • 82,057
  • 50
  • 264
  • 435
1
vote
2 answers

How to translate error messages in Colander

How can I translate the error messages from the colander validators? The documentation just says that it's possible. def valid_text(node, value): raise Invalid(node, u"Some error message") class form(colander.MappingSchema): name =…
Ander
  • 5,093
  • 7
  • 41
  • 70
1
vote
1 answer

Deform - render input type to be number not text

So my problem is I want Deform render an input type number like this: instead of:
GhitaB
  • 3,275
  • 3
  • 33
  • 62
1
vote
1 answer

Prohibit unknown values?

Can I raise an error with colander, if values are in the payload that are not in the schema? Thus, allowing only whitelisted fields? This is a sample: # coding=utf-8 from colander import MappingSchema, String, Length from colander import…
shredding
  • 5,374
  • 3
  • 46
  • 77
1
vote
1 answer

Strange deform/colander behaviour "string indices must be integers"

So I have the following working code, that I have been using for the past few months class UserSchema(colander.MappingSchema): dob = colander.SchemaNode( colander.Date(), title='Date of birth:') if 'submit' in…
crooksey
  • 8,521
  • 6
  • 30
  • 52
1
vote
1 answer

Colander subclassing SchemaNode

I wonder if someone can help me. I'm explore deform and colander in a new project and was following the documentation about subclassing SchemaNode. However, whilst the documentation states that subclass can define the following methods and…
Mr-F
  • 871
  • 7
  • 12
1
vote
1 answer

Pass custom css_class to deform Button

I have a basic form and schema.. class NewSchema(colander.MappingSchema): name = colander.SchemaNode(colander.String(), widget=text_input) schema = NewSchema() myform = Form(schema, buttons=('submit')) Now this works fine,…
crooksey
  • 8,521
  • 6
  • 30
  • 52
1
vote
1 answer

Deform Inter-Field Validation not highlighting field

I followed this example, but I modified it a bit to suit my project This is what I have: class AgentFormValidation(object): def __init__(self, context, request): self.context = context self.request = request def…
Renier
  • 1,523
  • 4
  • 32
  • 60
1
vote
1 answer

Using Colander with Pyramid App

I have RESTFul API written in pyramid. View functions processes data in request.POST and request.matchdict and returns json response. Eg: A method inside view class. @view_config(route_name="temp_name", request_method="PUT") def put_item(self): …
rajpy
  • 2,436
  • 5
  • 29
  • 43
0
votes
1 answer

How to factorize common fields with deform/colander ?

I need to display two forms depending on the context. The second form should contain a name and email text input followed by the first form content in that order, but only when the user is not authenticated. I tried with Python class inheritance…
ascobol
  • 7,554
  • 7
  • 49
  • 70
0
votes
1 answer

Custom templates and validation with Deform and mako

I am using deform in a project that uses pyramid with mako as a templating engine. I rewrote the templates for the widgets I need. I am using a modal for one of the forms so I wrote the mako template and the set the form widget with form.widget =…
Camilo Gomez
  • 111
  • 1
  • 5
0
votes
1 answer

How to change Deform Default validation fail error message?

I need to change the deform validation error message 'There was a problem with your submission Errors have been highlighted below'. How can I customize my own error message or hide this error message?
0
votes
1 answer

colander schema data type define for password input filed?

I create login form(email and password field) schema using deform and colander . but password filed show my password character. how to hide as normal HTML password input filed. email = colander.SchemaNode( colander.Str(), title='Email', …