[Zope] MVC and Zope

Kevin Carlson khcarlso@bellsouth.net
Sun, 16 Feb 2003 17:46:19 -0500


Hi everyone,

I posted an email yesterday about a problem I had forwarding a request 
from a python script to a dtml-document.  The problem turned out to be 
centered on the way that the relative URLs were generated.  This got me 
thinking about a larger issue, that of implementing a 
model-view-controller type of architecture within Zope.  Lengthy email 
to follow, bear with me...

If you use a python script as your controller and read necessary 
configuration information from the traverse_subpath binding, you could 
set up a table of target dtml documents (or methods), add the necessary 
model elements to the request and pass the entire thing off the the view 
for processing.  This works great in java, but because of the way that 
acquisition is handled in scripts, it seems to be an issue in Zope, 
although I am certain there is a way to code around the limitations.

The problem with doing this is primarily with images, stylesheets, and 
anchor tags that are generated from within the view (or 
dtml-document/method).  If I access a URL like:  
"www.domain.com/search?arg=Whatever", the system clearly navigates to 
the search page and can get the arg from the request.  If I format the 
URL as "www.domain.com/controller/search/Whatever" the system will give 
control to the controller script, which can then see that the search 
page needs to be called with the argument of 'Whatever'.  The problem in 
doing this is that the relative URLs generated by the search page will 
then include a path to the controller script.  Of course something like, 
<img src='images/go.gif'> gets returned to my browser with an absolute 
path of www.domain.com/controller/images/go.gif, which does not get 
found (the image is actually at www.domain.com/images/go.gif).  I 
believe this is primarily due to the fact that scripts "intercept" 
control and pass the less significant path elements onto the 
traverse_subpath binding, which of course, stops acquisition in its tracks.

Whew!  After that long explanation I can finally get to the question...  
Is there a way to read the traverse_subpath and if it contains certain 
text, change the context of the call and return a different object?  I 
noticed a few things in the archives regarding MVC, but didn't notice 
any concrete solution (yet).  Has anyone experienced this before or 
tried to implement MVC within Zope?

Thanks,

Kevin