On 03/05/2011 20:29, Chris McDonough wrote:
On Tue, 2011-05-03 at 17:31 +0100, Chris Withers wrote:
Hi All,

What's the correct way to limit the number of entries in a
SequenceSchema node?

The requirements is something like "each job must have at least one
requirement line, but no more than 5"

Not sure if you mean UI or validation, but:

- UI wise: use the min_length and/or max_length parameters to
SequenceWidget.  See
http://deformdemo.repoze.org/sequence_of_constrained_len/

Validation-wise, put a validator on the schema node, see the same
example.

I meant both, so thanks for both answers :-)

I'm also keen to know if anyone has done a widget which uses a
<textarea>  to produce a sequence of strings, rather than the JS "add one
as a time" approach?

See http://deformdemo.repoze.org/textareacsv/

If I just wanted to have something akin to the old Zope "lines" property type, would the following do the trick?

class Lines(colander.SequenceSchema):
    line = colander.SchemaNode(colander.String())

class Schema(colander.Schema):
    lines = Lines(
            widget = TextAreaCSVWidget(rows=5, cols=1)
            )

If not, what would? :-)

Also, when would you use:

http://deformdemo.repoze.org/widget_adapter/

...instead of TextAreaCSVWidget?

cheers,

Chris

--
Simplistix - Content Management, Batch Processing & Python Consulting
           - http://www.simplistix.co.uk

--
You received this message because you are subscribed to the Google Groups 
"pylons-devel" group.
To post to this group, send email to pylons-devel@googlegroups.com.
To unsubscribe from this group, send email to 
pylons-devel+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/pylons-devel?hl=en.

Reply via email to