I'd like to detail the future of flexible documents.
Today flexible documents are in fact documents with local persistent
layouts and schemas that can be modified. This means that they have
base schemas/layouts that are global to the site, but part of the
layout is designated as "flexible". When the user modifies it through
the edit interface (adding or removing widgets), a local copy is
created *inside* the document, together with a modified schema (as
adding/removing widgets means adding/removing fields).
This is problematic for several reasons:
- the schema isn't fixed, so there's no way of starting to use Zope 3
schemas (which can't be persistent at the moment), and there are big
variations between schemas for the same nominal "document type",
- there is additional persistent metainformation stored in the
document, which has to be imported/exported,
- because there are local schemas, it's hard to modify things for
"all instances of a given document type",
- in edit mode, you can't create new widgets without saving the
document; this is problematic during creation also.
In the future I want to have a different way of doing flexible
documents:
1. Define new field types, for instance RichTextTupleField,
ImageTupleField, LinkTupleField. For instance they could store python
information like:
richtexts = (('html', "<p>Some HTML</p>"), ('rst', 'Title\n====\n
\nHello'))
images = (image1, image2)
links = (('http://google.com', "Google", "The Google search
engine"), ...)
Each of the basic field (RichTextField, ImageField, ...) would have
associated widgets for individual rendering.
2. Define a new LayoutField that holds layout information, probably a
tuple, see below.
3. Define a new kind of widget called FlexibleWidget which is
parametrized using:
- field_ids = ('richtexts', 'images', 'links')
- layout_field_id = 'layout'
The layout field would store information like (format subject to
change):
images/0:floatright richtexts/0 :clearboth images/1 links/0
richtexts/1
This would do a rendering of individual components of the above data
using something like:
<div style="float:right"><img src="...image1"></div>
<div><p>Some HTML</p></div>
<div style="clear:both"></div>
<div><img src="...image2"></div>
<div><a href="http://google.com">Google</a> The google search engine</
div>
...
This means that the layout itself would be part of the content. So
the FlexibleWidget can have an edit mode where you create/delete
subwidgets directly.
A schema could define a ImageTupleField with additional config saying
minimum 1, maximum 3, which would be used by the FlexibleWidget to
enforce some limits.
All this will make for cleaner schemas and documents, more powerful
editing modes. It will make migration to Zope 3 schemas possible. It
will also simplify import/export of documents.
I'd welcome opinions on this. I'm not sure yet if I can do it before
3.4.0 but it would be very useful, as we could start the migration then.
Florent
--
Florent Guillaume, Nuxeo (Paris, France) Director of R&D
+33 1 40 33 71 59 http://nuxeo.com [EMAIL PROTECTED]
_______________________________________________
cps-devel mailing list
http://lists.nuxeo.com/mailman/listinfo/cps-devel