David Pratt wrote:
Hi Raphael. Perhaps a workflow could be a solution.
Hope this helps.
that's indeed an interesting idea! Need to think about it more.
After some more meditation over the code I got most of
what I want now. Since it might be interesting for others
as well, I try to sketch what I did so far:
First, one needs to understand the processing chain:
1. FTP/DAV uploads call 'PUT' from 'webdav.NullResource'
2. This gets the 'PUT_factory' from the parent in spe
(the target) folder.
For CMF this is usually the one from 'PortalFolder'.
3. The 'PUT_factory' contacts the 'content_type_registry' to
figure out what content type should be created for this
4. If a valid type is found, an _empty_ instance thereof is
created using 'parent.invokeFactory'.
5. Then this object is removed from the parent where it just has
been created. This now "kind of homeless" object is returned to
the calling 'PUT' from 'webdav.NullResource'
6. Calling 'parent._verifyObjectPaste' it is now checked whether
it is actually allowed to put the "homeless" object into the
parent and if so ...
7. ... it is placed in there.
(Why is this back-and-forth handling needed at all?)
8. Finally (for 'PUT' from 'webdav.NullResource'), it calls 'PUT'
on the newly created object, passing along (REQUEST, RESPONSE).
9. What this - potentially and usually - content-type specific 'PUT'
does in the end, is up to the type.
Now, what I did:
1. Tell the 'content_type_registry' that a '.bib' upload should generate
2. Provide the 'BibliographyFolder' with a 'PUT' method that checks
whether it lives in another bibfolder or some other folder type.
3. If the new bibfolder lives in another bibfolder, the import is done
to the parent and the new bibfolder gets deleted. Otherwise the
import is done to new folder.
Easy, isn't it ;-)
What I've noticed:
- For various reasons I don't allow nesting of bibfolders but as
I understand the processing chain skechted above I have to allow
bibfolders within bibfolders for this to work. I could live
with some intermediate standard Zope type but I find it restrictive
that it _has_ to be a valid content type (at least without patching
What I'm still looking for:
- Has anyone ever extended the content_type_registry to support
the evaluation of an arbitrary TALES expression given the
upload's body (or the first few hundred bytes/characters thereof)?
Would it be worthwhile having something like that?
Maybe someone finds this interesting ...
Zope-CMF maillist - Zope-CMF@lists.zope.org
See http://collector.zope.org/CMF for bug reports and feature requests