Problem
You want to use a method that returns a Directory instance instead of html.
Solution
Use the property decorator.
Example
The down method of the Test class returns an instance instead of a string. Note how easy it is to access self.
1 from quixote.directory import Directory
2
3 class Test(Directory):
4 _q_exports = ['', 'down']
5
6 def __init__(self, depth=0):
7 self.depth = depth
8
9 def _q_index(self):
10 return '<html><head></head><body>' + \
11 str(self.depth) + \
12 '<br />' + \
13 '<a href="down/">Down</a>' + \
14 '</body></html>'
15
16 @property
17 def down(self):
18 return Test(self.depth+1)
19
20 def create_publisher():
21 from quixote.publish import Publisher
22 return Publisher(Test(), display_exceptions='plain')
23
24 if __name__ == '__main__':
25 from quixote.server.simple_server import run
26 print 'Listening on http://localhost:8080/'
27 run(create_publisher, host='localhost', port=8080)
28