[Zope3-dev] pattern exploration: view chains (xslt, pdf, etc.)
Steve Alexander
steve@cat-box.net
Sun, 07 Apr 2002 11:17:34 +0100
Gary Poster wrote:
> Working on
> http://dev.zope.org/Wikis/DevSite/Projects/ComponentArchitecture/ManageStaticTextContent
> made me ponder about how to handle a use case like this:
>
> I have some static xml (non-xhtml) documents in a file in Zope. Let's say,
> hypothetically, I uploaded an Excel spreadsheet and used xls2xml to convert
> it to XML.
>
> What if I want to see this in html?
>
> What if I want to see this in a pdf?
>
> What I came up with is the idea of view chains. Imagine this, for instance:
>
> mysite.com/sales.xml/xhtml.xslt;view/htmltopdf;view
>
> or what if I had a zpt I wanted to convert to pdf
>
> mysite.com/myZPT/default;view/htmltopdf;view
>
> I can think of some ways of making this work (views would need marker
> interfaces, for one; and I have some other thoughts), but I first wanted to
> see if this seemed like a useful idea, or if folks had a better idea on how
> to accomplish this sort of thing. Thoughts?
I've implemented a container traversal that gives a different view
depending on the file extension given. So, mydocument.txt gives you the
txt;view which renders plain ascii. mydocument.html gives you html;view,
and mydocument.pdf invokes ReportLab to send back a PDF.
There's one small change I need to make to the BaseRequest interface to
make this non-crufty.
The same change makes the JobBoardEx slightly less crufty.
More on this later...
--
Steve Alexander