[Zope-CMF] portal_transformation notes

Romain Slootmaekers romain@zzict.com
Thu, 23 Jan 2003 14:39:55 +0100


seb bacon wrote:
> Chris Withers wrote:
> 
>> seb bacon wrote:
> 
> 
>>> Then you can convert a word document to html to structured text, etc. 
>>> (That'll be a common use case, then ;-)
>>
>>
>>
>> How far have you got on this? :-)
> 
> 
> Well, for current purposes, I just have to convert a few MS docs into 
> text, and can't justify the extra time required to make it really 
> generic; but I've been playing with different "pluggable" designs as I go.
> 
> The code I've written so far is basically some "use an external tool to 
> produce output" stuff (which also works when the tool produces more than 
> one bit of output e.g. html + images) with a fairly generic framework. 
> But it's not a tool and it doesn't chain transformations together 
> automatically, and the conversion logic is hardwired into the File type. 
>  I probably won't get a chance to make this tool either, but I have been 
> thinking about it.
> 
> One thing I'm not clear on is how I would produce transformation chains 
> automatically.  I've not really thought about it a lot, but here are 
> some starting ideas.  

Why does it have to be a chain ?
Why not use the reactor pattern (see tomcat4/catalina for a detailed 
description)
Basically you have a pool of possible transformers and a pool of 
documents in all possible states (from not yet transformed,somewhat 
transformed to almos totally transformed)
A step in the reactor is to take a document, and challenge the 
transformers. The first one that bites gets to transform the document.
the result of this transformation goes back in the pool of documents.
if no transformer fits, the document is done and can be removed from the 
pool.

This way you don't have to build chains, and what's more, a transformer 
can be called more than once in the chain.

Catalina uses the pattern for XML/XSL transformations.

have fun,

Sloot.