140 likes | 230 Views
Next Generation Content Types for Zope 2. Archetypes. Goals. Simple, reusable framework Easy maintenance Rapid Development. Solution. Simple, flexible Schema Reasonable default policy Keep separate concerns separate Normalized content framework. Implementation. Components Fields
E N D
Next Generation Content Types for Zope 2 Archetypes
Goals • Simple, reusable framework • Easy maintenance • Rapid Development
Solution • Simple, flexible Schema • Reasonable default policy • Keep separate concerns separate • Normalized content framework
Implementation • Components • Fields • Widget System • Validation • Storage • References • Transformation • Schema
Field • Fields encapsulate the policy of a single data item • Type mapping • (Ex: String to date or string to int) • Properties • (Ex: required, vocabulary, searchable) • TextField('body')
Widgets • Flexible, dynamic presentation elements associated with each field • Defined as ZPT macros and callable through the schema • TextField('body', widget=StringWidget()) • metal:use-macro=”python:here.widget('body', mode='view')”
Validation • Validation can be handled a number of ways • Custom validation • For field 'body' implement a method validate_body • Validation Tool • StringField('url', validators=('isURL',)
Storage • Sometimes we know that certain fields require special types of storage. • TextField('body', strorage=SQLStorage(...)) • Can control if elements appear as ObjectManaged elements or not • Store large objects in files or databases and not ZODB
References • The ability to explicitly link objects to one another • Can define relationships between any Archetypes based objects • Forward and Backwards references • Tracks move, rename, copy, delete as expected
Transformation • Content can be the product of complex transformations and this is handled seamlessly by the framework • Supported by a pluggable interface • Sample supported formats include • Office Products • (Re)Structured Text • DocBook • RTF
Schema schema = BaseSchema + Schema(( TextField('body', required=1, searchable=1, widget = RichWidget(), ), )) • Simple Schema, Including things expected by Zope and 1 additional Field • Schema are active objects and drive the inner workings of the object
Schema • A class generator process each object providing hooks into the schema where methods are missing. • getBody might transparently map to • self.Schema()['body'].get(self) • This means that custom field implementations can support rich behaviors shared across projects.
Future Directions • Better Transformation intergration • TTW Schema management • UML <-> XMI <-> Archetypes • XML Schema <-> Archetypes
Questions • Also see • http://sf.net/projects/archetypes • http://www.plone.org/ • http://cmf.zope.org • http://zope.org