[Repoze-dev] Deform/Colander: allow empty non-String field in schema?

2010-05-26 Thread Chris Shenton
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

  default=...

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 
flags:

  required=False
  allow_empty=True

but allow_empty applies only to String and these seem to have no effect either. 
 I'm looking to do something like:

class StandardFields(colander.MappingSchema):
manufacturer= SchemaNode(String(), default='') # not 
required
obsolete_date   = SchemaNode(Date(),required=False, 
allow_empty=True)
length  = SchemaNode(Float(),   required=False, 
allow_empty=True)
units_per_pack  = SchemaNode(Integer(), required=False, 
allow_empty=True)

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 
DB.

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.

Any suggestions? 

Thanks.

___
Repoze-dev mailing list
Repoze-dev@lists.repoze.org
http://lists.repoze.org/listinfo/repoze-dev


[Repoze-dev] [issue147] Deform default form action . submits to parent folder

2010-05-26 Thread Kiran Jonnalagadda

New submission from Kiran Jonnalagadda j...@pobox.com:

deform.Form takes a parameter 'action' with default value '.'

This default value is unfortunate. If the form is at a URL that has a trailing 
slash, all 
works well, but if the URL doesn't (such as '/login'), the form is submitted to 
the 
parent folder ('/'). The default value should be '', a blank string.

--
assignedto: chrism
messages: 409
nosy: chrism, jace
priority: bug
status: unread
title: Deform default form action . submits to parent folder

__
Repoze Bugs b...@bugs.repoze.org
http://bugs.repoze.org/issue147
__
___
Repoze-dev mailing list
Repoze-dev@lists.repoze.org
http://lists.repoze.org/listinfo/repoze-dev