[Zope-dev] Simplification via custom protocol handlers: cvs://server/project, zope://foo ?

Craeg K Strong cstrong@arielpartners.com
Mon, 01 Apr 2002 15:50:51 -0500


Dieter Maurer wrote:

>Craeg K Strong writes:
> > ...
> > The Zope protocol handler idea is interesting, and I haven't thought 
> > this all the way through yet.
> > Could  <dtml-var blat>  be thought of as referring to "zope://blat" 
> > where the Zope protocol is the default
> > and therefore omitted?
>I do not think, this would be a good correspondence:
>
>  "zope://blat" is kind of an absolute URL while "blat" is by no means
>  absolute.
>
>
>Dieter
>
You're right, it is a different thing.    I was originally thinking that 
you could
imagine a URN with a "zope" namespace ID (meaning the entire contents of 
the ZODB)
and the python expression as the namespace specific string.

However, I believe URNs are supposed to name a specific resource.  By 
contrast,
acquisition means that a dtml-var can name very different resources 
depending on
what is in the ZODB.  It is a variable, not a name.

I am now thinking that the way to avoid my multiple mixin problem in 
Zope-2 is
to break things apart into small pieces that each do a specific thing. 
 For example,
you could have:

- a CVSFile product that makes an object in ZODB retrieve its content 
from a CVS sandbox
- an XPath filter product that applies an xpath to an object in ZODB and 
returns the result
- an XSLT transformer product that applies an xslt to an object in ZODB 
and returns the result
- a STX to Docbook filter product that takes an ASCII file in structured 
text format and returns
    an XML file using the docbook dialect (I think STXDocument does this)

So you could have a structured text document foo.stx in your CVS sandbox.  
A contrived example follows.  Lets say you wanted an HTML page that 
displayed
only a portion of the contents of a structured text file.  The file 
("foo.stx") is in your
CVS sandbox, and you just want the first paragraph as an HTML page.

You would create an instance of CVSFile called foo.stx in ZODB.  foo.stx 
gets its
content from the file "foo.stx" in your CVS sandbox.

You would then create an instance of STXDocument that gets its content
from foo.stx but transforms it into docbook XML.  You might call it foo.xml

You could then create an instance of XPathFilter that gets its content 
from foo.xml
but just picks out some subset of that content based on the specified 
xpath.  You might
call that object "bar.xml"

Finally, You could create an instance of XSLTFile that gets its content 
from bar.xml
and applies an xslt transformer to it to output HTML.  You might call 
this file "index_html"

So inside a single folder in ZODB you could have your four different 
objects:

folder/foo.stx  (instanceof CVSFile)
folder/foo.xml  (instanceof STXDocument)
folder/bar.xml   (instanceof XPathFilter)
folder/index_html  (instanceof XSLTFile)

So by navigating to "folder" you automatically get the HTML webpage with 
the desired content.

How to make this work?   Each Zope Product must be able to either hold 
its content directly
or get its content by referring to another object in ZODB.   Also, if 
the Product maintains a cache
(obviously you don't want to run a transformation more than once on the 
same content) it must
ask the referrred to object if its contents have changed.

Thoughts?

--Craeg