Hello Ian-

I like your idea of having one servlet that dispatches requests to a bunch of other objects that are not servlets. I'm having a little problem though, with getting the request to go to that servlet and not to the other objects. That's a little hard to read, let me explain it with this diagram:
/MyContext/
Main.py (This is my servlet which loads all the files below it like One.py, Two.py, etc.)
One.py (This object is NOT a servlet, it just has an html() method that returns my HTML text.)
Two.py (This is another object with just an html() method)

The idea is that a request to http://myserver/MyContext/One.py should be received by Main.py, and it will:
• Cut off the extraURLPath, which will be "/One.py"
• Main loads the MyContext.One.One object and calls it's .html() method.
• Main writes that text to the response object and returns.

The problem is, how do I get Webware to load and call the Main object as opposed to the One.py object?

-winston


But you could build what you are looking for ontop of Webware. Maybe like:

class Main(Page):

def awake(self, trans):
Page.awake(self, trans)
path = self.request().extraURLPath()
self.object = traverse_path(root, path)

def writeHTML(self):
self.write(self.object(trans))

import base
root = base.root_object
def traverse_path(object, path):
if not path:
return object
assert path.startswith('/')
first = path.split('/')[1]
rest = path.split('/', 2)
if len(rest) == 3:
rest = '/' + rest[2]
else:
rest = ''
return traverse_path(get_part(object, first), rest)

def get_part(object, attr):
# Maybe use getattr or something else
return object[attr]

--
Ian Bicking / [EMAIL PROTECTED] / http://blog.ianbicking.org

<x-tad-smaller>_________________________________________
winston wolff - (646) 827-2242 - http://www.stratolab.com - learning by creating
</x-tad-smaller>

Reply via email to