Hi,

I started to implement readonly functionality in deform/colander.
It is already fully implemented and I am generating complex compound
forms with it. Before I submit a Pull Request for this feature I
wanted to ask if anybody has a use case that would totally not work
with the way its implemented now.

Most work of the implementation was done in colander:
https://github.com/do3cc/colander/commit/707d61b63e6fe9af8336efce91c6f4d3dcb2e8cf

The needed work in deform was a joke in comparison:
https://github.com/do3cc/deform/commit/304269f6f338798c11ecf23e2bf4166c8a853155

Deform contains a simple example for readonly fields in the
deformdemo.

So, this is how it implemented:
SchemaNodes can get a named argument readonly. It defaults to False.
It if is True, a deserialization of this SchemaNode will throw an
exception.
Compund Schemas like Tuples, Sequences and Mappings will either throw
exceptions or ignore elements if cstructs contain data for the
readonly children.
When you create a form with deform, the readonly SchemaNodes will be
rendered with readonly templates. These contain no input elements, so
validating the response will work, because it will never contain
cstruct data for the readonly nodes.
When a SchemaNode is marked readonly, all his children are readonly
too.

This resulted in some interesting problems.
In my use case I have a number of objects of type X, and the customer
wants to create lists of X, grouped by some attributes. They then want
to mark each item on that list off. This information shall not be
stored on X. So my form contains a List of Lists of Mappings, some
fields of the mapping are read only, others not. The lists have a
fixed length.
I cannot implement my Lists with A SequenceSchema. If it is writable,
the user interface would allow to add more items, If I make it
readonly, the complete Mapping would always be rendered readonly.
The alternative are TupleSchemas. But the lists can be filtered by the
user, so I only know during runtime, how many items my TupleSchema
will have. So I am forced to build part of my schema imperatively. As
ChrisM wrote in the documentation, its uglier.

This is the only issue I had so far, if anybody would see moreo
serious issues or has an idea on how to improve it, please speak up!

Best regards,

       Patrick

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