On Thu, 28 Dec 2006 12:14:13 +0100, Martin Aspeli
<[EMAIL PROTECTED]> wrote:
Florian Schulze wrote:
Dang! I knew this was coming. I thought about this for some time now
and didn't find a good solution to add a tab here which is not Schema
based. There was a thread on archetypes-devel about making interfaces
and adapters for Schema and Field stuff, so you could add stuff here,
but I don't know the state of it. The problem is, that this is one big
form and currently only archetypes handles everything on save, ideally
it would delegate the validation and mutation etc, so one could add
custom fields here. We also would need to see how this works together
with KSS inline validation, but if AT delegates, then it shouldn't be a
problem.
You can do this now if you use ContentFlavors (the 3.0 branch), which is
in AT svn. The necessary wiring is in AT, but CF probably needs a bit of
updating as I'm intending to bend Kapil's use cases a bit. The necessary
wiring is in AT.
On the other hand, if we don't mind ATCT depending on
plone.app.redirector, we can do this the usual way, with a write-only
field and a custom mutator.
I just looked at the source, so I might be wrong. AFAICS there are two
problems:
1. If we want to change something in the Schema globaly, then we have to
overwrite the adapter from BaseObject to ISchema. Overwrites shouldn't be
used in a framework though.
2. AT expects the mutators to be available in the context. I'm not really
sure about this.
Let's see how we could to the alias stuff:
- We either overwrite the adapter from BaseObject to ISchema or use a
more explicit one from the ATCT base object (which would make it work for
ATCT types only).
- In the new adapter we return the original Schema plus the new fields
for the alias stuff
- When the form is saved BaseObject._processForm iterates over all the
fields of the Schema, gets the widget, calls widget.processForm, then gets
field.getMutator and calls it
- To make this work we return our own field with our own widget and
mutator
I think what's missing here is a way to provide an adapter from BaseObject
to ISchema which is extendable by products. Maybe we could make
archetypes_tool a local utility and provide a way to register additional
Schema parts. I currently have no real idea how this could work properly.
Maybe we should also use interfaces for Fields and Widgets in _processForm
to make this more flexible.
Any ideas and insights welcome.
Regards,
Florian Schulze
_______________________________________________
Framework-Team mailing list
Framework-Team@lists.plone.org
http://lists.plone.org/mailman/listinfo/framework-team