archetypes.schemaextender
archetypes.schemaextender
Notes from Eric Rose's Penn State Symposium talk: http://plone.org/events/regional/plone-symposium-2008/schema-extender-extends-your-mind
The Old Way
Subclass, Fuss, Migrate, Fail. (Runaway subclassing, hard migrations, not playing nice with others)
The New Way
*Don't replace, extend.*
With Plone 3, BaseObject includes:
def Schema(self):
"""Return a (wrapped) schema instance for this object instance
"""
schema = ISchema(self)
...
Supports multiple extenders using named adapters with loose coupling based on interfaces.
Do like this:
from archetypes.schemaextender.interfaces import IOrderable SchemaExtender
This interface includes the getOrder() method, which you can use to change the field order within a schemata.
So how do we keep the change from spilling over plone sites?
Use a local adapter instead of a global adapter. This limits its effect to within a Site Manager. (It is possible to make a Folder a site manager, since it's an IPossibleSiteManager)
Now there's also IBrowserLayerAwareExtender. see link to discussion at bottom.
How do we get the new field on the View tab?
Viewlets!
- New viewlet manager per content type
- Viewlet that uses that viewlet manager
Booho. This doesn't work with standard types, because their templates don't use viewlets. You have to modify foo_view.pt, etc.
Schema extender doesn't do autogenerated get/set, so your viewlet class will have code like:
def mobilePhone(self):
return self.context.get('mobilePhone')
