[Zope3-dev] Re: Changes to the schema package
Philipp von Weitershausen
philipp at weitershausen.de
Thu Jan 8 05:48:33 EST 2004
Garrett Smith wrote:
> Given the relationship between fields and widgets, though, I'm inclined
> to agree with Jim -- can a view (i.e. widget) to such a field really
> succeed without knowing anything about the values/keys?
Sure, the "Python prompt view" ;)) No, seriously, why do we always have
to think about a view. I agree with Gary when he says that it's
reasonable that you just want to express what kind of attribute the
object has, not what kind of values to find in that attribute, be it
dict or list.
> If you want to store _anything_, can you get by with a field like
> IObject? (I don't know if that already exists.)
There's the Object field, which is only for objects implementing a
schema, though. (We could argue about *that* name, too, but that's a
different story).
> Could you give an example of when you'd want value_type/value_key to be
> None and how widgets/forms would handle such a case?
class ISimpleObjectHubbishThing(Interface):
ids_to_objects = Dict(
title=u"Map ids to objects",
key_type=Id()
value_type=None # accept any object
)
For this, you wouldn't want to get a view anyway, probably. Here, it's
more documentation *and* validation than anything else. Remember: it's
still good for validation:
class SimpleObjectHubbishThing:
implements(ISimpleObjectHubbishThing)
ids_to_objects = [] # won't validate (wrong type)
ids_to_objects = {123: object()} # won't validate (wrong key_type)
ids_to_objects = {'some.object', object()} # WILL validate
> I don't really have a strong opinion on this.
Then you wouldn't mind?
Philipp
More information about the Zope3-dev
mailing list