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
2
votes
1 answer

Allow Unknown values

I am using colander while de-serializing JSON response. There is a field that is configured to have numbers only, but sometimes the response has null or non-numeric value for this field and then my application throws invalid error. Is there a way I…
RohitS
  • 157
  • 2
  • 6
  • 21
2
votes
2 answers

Variable dictionary in Colander

How can I validate following data structure using colander library? [ { 'bar': ['a', 'b', 'c'], 'variable2': ['b', 'c'], 'foo': ['a', 'c'], }, { 'something': ['foo', 'bar'], }, ] The problem is that…
user1333261
1
vote
0 answers

How to validate one key based on another in Colander Python?

I am using Colander for validation, and would like to validate one key based on another. e.g: I would like to validate field value based on entity value: class ValidationSchema(Validator.MappingSchema): entity =…
vibhor Gupta
  • 103
  • 11
1
vote
1 answer

How to change the label content in a deform/colander form?

I have deform/colander generated html form, that contains this: class ProductSchema(colander.Schema): completename = colander.SchemaNode(colander.String()) The generated form has therefore this label:
1
vote
1 answer

Colander: How do I handle null values for nested schema

Using colander 1.5.1, if I pass null to an attribute defined by a nested schema: class ChildSchema(colander.Schema): a = colander.SchemaNode(colander.Integer(), missing=None) b = colander.SchemaNode(colander.Integer(), missing=None) class…
leigen_zero
  • 21
  • 1
  • 3
1
vote
0 answers

Accepting lists as URL params with Colander

I'm trying to accept a URL-serialized version of the following Python dict using Colander as my validation backend: {'foo': [1,2,3]} The way I've approached this was primarily using colander.SequenceSchema in various configurations, none of which…
0xdd
  • 311
  • 3
  • 15
1
vote
1 answer

How to re-order colander fields in a form?

I used form inheritance to create a new form, for instance: class MyForm(ParentForm): employment_date = colander.SchemaNode( colander.Date(), title=_(u'Employment Date') ) Lets say the order of the ParentForm fields…
b4oshany
  • 692
  • 1
  • 7
  • 15
1
vote
1 answer

Optional Colander Field for object instantiated using custom class

I want to make certain fields in a model made using colander to be optional. I am familiar with using missing=colander.drop but that only works when SchemaNode is defined. In case, the field is defined using a custom class, say customeClass =…
timekeeper
  • 698
  • 15
  • 37
1
vote
2 answers

Adding CSS to Deform Input Form

I am implement a simple form with Colander and Deform; however, I wish to override the default stylsheet and provide my own. However, I have no idea on how to provide my own styling for the form. Here is the code that I am using: class…
Ajax1234
  • 69,937
  • 8
  • 61
  • 102
1
vote
0 answers

Is there a slider in deform framework?

I am trying to add a slider to my deform form and I saw that it is possible to create our own widget using plain HTML. I tried the following with no luck. Any hint? Is there some other library that can be used to augment the number of widgets? class…
tupui
  • 5,738
  • 3
  • 31
  • 52
1
vote
1 answer

deform Sequence of Mapping not updating

I have created a view which output a form containing: class Person(colander.Schema): name = colander.SchemaNode(colander.String()) age = colander.SchemaNode(colander.Integer(), validator=colander.Range(0,…
tupui
  • 5,738
  • 3
  • 31
  • 52
1
vote
1 answer

Manage ManyToMany relationship in Websauna Admin Panel

I have a model where a lot of ManyToMany connections. I need a smart way to manage from Admin Panel. When creating a campaign model I need to connect to other models. Does Websauna have something like Django Inline foms? class Campaign(Base,…
eirenikos
  • 2,296
  • 25
  • 25
1
vote
1 answer

Generation admin panel with custom column type in Websauna

I have a SQLAlchemy model with custom type ChoiceType which comes from sqlalchemy_utils library. class Recipient(Base, BaseMixin): first_name = Column(String()) last_name = Column(String()) social_network =…
eirenikos
  • 2,296
  • 25
  • 25
1
vote
1 answer

@colander.deferred widget data update

I have a Python app based on Pylons and Jinja2. There is a widget: @colander.deferred def deferred_last_results_widget(node, kw): """ Widget for last results widget Empty choice is added to list by default. :param node: name of the node :param kw:…
Piotr
  • 51
  • 6
1
vote
1 answer

Dynamic forms with deform

Making form with deform and whould like to change the pageShema class depending on the choices made by the user. Ex. if he selects option 1 from selectwidget, show him one set of fields, if case of other choice - another. How to do this?
Eve
  • 21
  • 1