Hello, there.

I'm trying to use deform in a project where we already use the Storm
ORM, and I need something like a "reference field": a field where you
select a "storm object" trough a combobox and that object will be
available in the appstruct. Something like:

{
  'name': u'John',
  'company': <storm object (Company) name='Circus',
}


I think that the best way to acomplish that is to code a new
SchemaType that serializes a "storm object" into a simple string.
Doing the serialization is an easy task, but the problem arises during
deserialization, where we need to look for the object in the database
(which in the Storm scenario is accessed trough a Store object), and
the SchemaNode.deserialize has a fixed signature, so we can't do
something like schema.deserialize(cstruct, store=store).

Basically, the problem is how can we inject the store (or any other
dependency) into our SchemaType's deserialize method?

One solution would be to pass the store to the reference schema type
__init__, but that would not fit, since we like to declare the schema
in the global scope, but we don't have the store there. The other
option would be to pass the store through the schema nodes, so we can
use colander.deferred to declare the schema and bind the store later.
But I kinda dislike these solutions, so I ask you guys what do you
think?

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

Reply via email to