[albatross-users] problems with a RandomModularSessionApp
Chiron Consulting
chironsw at swbell.net
Thu Apr 10 22:57:31 EST 2003
New to albatross, delighted with it so far, having a problem that I
can't figure out. Checked the archive, and don't notice anybody else
having it, so I thought I'd ask.
1. Running apache 2.0.44, mod_python 3.0.3, python 2.2, and albatross
1.01 ... everything seems to run fine, examples all work
2. I've got apache configured to handle any/all .html files in the
documentroot directory using my mod_python handler. this worked fine.
3. I built a trivial SimpleApp-based albatross program, which also works
fine:
<code>
# myhandler.py
from albatross import SimpleApp
from albatross.apacheapp import Request
class StartPage:
def page_display(self, ctx):
ctx.run_template('start')
# note: the start template is trivial, with no replaceable parms.
# i plugged those in, and it also works fine.
class myApp(SimpleApp):
def __init__(self):
SimpleApp.__init__(self,
base_url = 'myhandler.py',
template_path = '/usr/local/apache/htdocs/templates',
start_page = 'start',
secret = '-=-secret-=-')
app = myApp()
app.register_page('start', StartPage())
def handler(req):
return app.run(Request(req))
</code>
4. The 'start' template in the above example was a trivial html file,
with no replaceable parms. I added replaceable parms, and implemented a
page_enter() method for the StartPage class, and all went as expected.
5. Here's where I start running into problems. I want to use the
RandomModularSessionApp to build a more sophisticated app. Here's the
mod_python handler code:
<code>
from albatross import RandomModularSessionApp
from albatross.apacheapp import Request
class myApp(RandomModularSessionApp):
def __init__(self):
RandomModularSessionApp.__init__(self,
base_url = 'myhandler.py',
page_path = 'htdocs',
start_page = 'start',
secret = 'same-secret-as-always',
session_appid = 'whatever')
def handler(req):
app = rpApp()
return app.run(Request(req))
</code>
and here's the module for the (still trivial) start page:
def page_display(ctx):
ctx.run_template('start')
With the albatross session server running, an attempt to access this app
at the URL "http://localhost/" generates the following traceback error:
Template traceback (most recent call last):
Traceback (most recent call last):
File "/usr/local/lib/python2.2/site-packages/albatross/app.py", line
143, in run
self.load_page(ctx)
File
"/usr/local/lib/python2.2/site-packages/albatross/randompage.py", line
28, in load_page
ctx.redirect(self.start_page())
File "/usr/local/lib/python2.2/site-packages/albatross/app.py", line
121, in redirect
new_loc = self.redirect_url(loc)
File "/usr/local/lib/python2.2/site-packages/albatross/app.py", line
113, in redirect_url
return urlparse.urlunparse(('http', self.request.get_servername(),
File "/usr/local/lib/python2.2/site-packages/albatross/apacheapp.py",
line 34, in get_servername
return self.__req.connection.server.server_hostname
AttributeError: server
I have no idea what's going on here, or how to fix it. Any ideas?
Thanks,
Greg Goodman
More information about the Albatross-users
mailing list