We're doing a BFG app with a MongdoDB backend, and the Deform stuff seems
perfect for us, really enjoying using it so far.
But I can't figure out how to make a field in a schema optional if it's not a
String. (I've done this in Django model schemas where I can use the flag
"null=True" and blank=True" on a non-string type). My reading of the docs says
that setting a field's
it makes a field non-required, and default='' is fine for String types, but not
so helpful for Integer, Date and other nonStrings. I've read doc mentioning
but allow_empty applies only to String and these seem to have no effect either.
I'm looking to do something like:
manufacturer = SchemaNode(String(), default='') # not
obsolete_date = SchemaNode(Date(), required=False,
length = SchemaNode(Float(), required=False,
units_per_pack = SchemaNode(Integer(), required=False,
but find these don't work: my fields are required to be set. Supplying a
default value to indicate a non-required field, e.g.:
units_per_pack = SchemaNode(Integer(), default=0)
also feels wrong, since this will set the actual value to 0 upon storage to the
I am probably missing something in the docs. Perhaps I need a different
approach for non-required fields, like making the schema a String but having a
validator ensure they're my desired type if any value is provided on the form
-- this seems a round-about way to do things.
Repoze-dev mailing list