Schema by Interface / Content Flavors

sirgarr georgeleejr at gmail.com
Thu Aug 30 21:57:51 UTC 2007



Martin Aspeli wrote:
> 
> sirgarr wrote:
>> >  The challenge is that the accessors and mutators of the returned
>> schema
>> > must be available as methods on 'context', with appropriate security
>> > declarations.
>> 
>> Is it okay practice to add the methods explicitly in the class or
>> monkey-patch it, knowing that they will not be used in some sites (where
>> I
>> don't register a new schema adapter) but that they will be used in
>> others?
> 
> Monkey patching is inherently global, so you can't have different 
> methods in different Plone sites.
> 

Right, I can't have different methods, but is it okay to define methods
getFoo and setFoo on the type with the understanding that they'll be like
neglected random appendages in sites that don't extend the content type with
schema "foo"?

It is confusing that ISchema can be used to pull schema from somewhere else,
but that methods still have to be defined on the class itself - since the
schema isn't useful without the methods.

So it seems that adding one field with a locally registered, custom ISchema
adapter can't be done very cleanly (i.e., without neglected random
appendages!) and easily. ContentFlavors seems to be a robust set-up but
perhaps overly complicated for just wanting to add one field with a custom
ISchema adapter.

Could Archetypes allow mutator and accessor methods to be extended with some
lookup by adapter as well? But then I don't know how you would still be able
to use "context/getFoo". Has there been discussion about how to address the
schema-by-adapter and expect-methods-on-the-class discrepancy -- perhaps
with a simpler version of ContentFlavors?
-- 
View this message in context: http://www.nabble.com/Schema-by-Interface---Content-Flavors-tf4355401s20094.html#a12417047
Sent from the Product Developers mailing list archive at Nabble.com.





More information about the Product-Developers mailing list