sirgarr wrote:

Martin Aspeli wrote:
schema-by-interface (or rather, schema-by-adapter-lookup) is supported in AT 1.5.


Ah, yes -- I see this in
http://dev.plone.org/archetypes/browser/Archetypes/trunk/Schema/factory.py

And with Plone 3.0 / Zope 2.10, it's possible to register an adapter locally
(e.g., with GenericSetup in componentregistry.xml), so that MyContentType
can behave one way in one Plone Site, and have an extended schema in another
Plone site -- is that correct?

But how would I deal with this (from factory.py's doctext):


 The challenge is that the accessors and mutators of the returned schema
must be available as methods on 'context', with appropriate security
declarations. When the schema is set in a 'schema' class-attribute, this is
taken care of by ClassGen. However, if you wish to provide the schema with a
different adapter, you have three choices:
1. Provide the accessor and mutator methods explicitly in the class. ...

3. Add the methods per-instance yourself.  This is what the ContentFlavors
product does, so you may be better off using that.


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.

You probably want the 3.0 branch of ConcentFlavors, though I'm not sure if it's 100% complete or working (I haven't had time to look at it for a long time).

Martin

--
Acquisition is a jealous mistress


_______________________________________________
Product-Developers mailing list
[email protected]
http://lists.plone.org/mailman/listinfo/product-developers

Reply via email to