[albatross-users] problems with a RandomModularSessionApp

Michael C. Neel neel at mediapulse.com
Mon Apr 14 06:11:39 EST 2003


This is a mod_python 3x vs 2x issue.  There are been some things change
in the mod_python api from 2 to 3, and this is one of them.  Updating to
the 3x version is not the solution, as 3x runs only under apache2, while
2x run under apache1.3, and there are a lot of us still using apache1.3.
To fix this correctly, you'll need to check which mod_python you are
running under and use the correct call.

Mike

> -----Original Message-----
> From: albatross-users-admin at object-craft.com.au 
> [mailto:albatross-users-admin at object-craft.com.au] On Behalf 
> Of Tommy !!
> Sent: Thursday, April 10, 2003 2:13 PM
> To: albatross-users at object-craft.com.au; chironsw at swbell.net
> Subject: Re: [albatross-users] problems with a RandomModularSessionApp
> 
> 
> Hi there,
> 
> I posted this bug to the object craft people a few days ago, 
> haven't heard 
> back yet.
> 
> I do, however, have a solution.
> 
> This error _will_ occur with mod_python/albatross - most 
> notably if you use 
> <al-a> tags in your templates.
> 
> To fix it simply replace the line (in apacheapp.py -> you'll 
> have to get 
> your hands dirty with the albatross source code):
> 
> self.__req.connection.server.server_hostname
> 
> with:
> 
> self.__req.server.server_hostname
> 
> Refer to the mod_python Apache API docs to understand why 
> this error occurs. 
> I'm too tired to explain just now :)
> 
> You will find a few other small bugs are also present. More 
> on that later. 
> All the bugs I've come across so far can be resolved with 
> small edits of the 
> albatross source code.
> 
> Long live OSS, eh?
> 
> Kind regards,
> Tom Lee
> 
> 
> 
> 
> 
> 
> >From: Chiron Consulting <chironsw at swbell.net>
> >To: albatross-users at object-craft.com.au
> >Subject: [albatross-users] problems with a RandomModularSessionApp
> >Date: Thu, 10 Apr 2003 12:57:31 +0000
> >MIME-Version: 1.0
> >Received: from mail.object-craft.com.au ([210.23.136.24]) by 
> >mc5-f30.law1.hotmail.com with Microsoft 
> SMTPSVC(5.0.2195.5600); Thu, 10 Apr 
> >2003 11:01:04 -0700
> >Received: from numbat.object-craft.com.au (localhost [127.0.0.1])by 
> >mail.object-craft.com.au (Postfix) with ESMTPid A3EFB16DD5; 
> Fri, 11 Apr 
> >2003 04:01:01 +1000 (EST)
> >Received: from mta6.snfc21.pbi.net (mta6.snfc21.pbi.net 
> [206.13.28.240])by 
> >mail.object-craft.com.au (Postfix) with ESMTP id A228016DD4for 
> ><albatross-users at object-craft.com.au>; Fri, 11 Apr 2003 
> 04:00:27 +1000 
> >(EST)
> >Received: from swbell.net ([208.191.179.211]) by mta6.snfc21.pbi.net 
> >(iPlanet Messaging Server 5.1 HotFix 1.6 (built Oct 18 
> 2002)) with ESMTP id 
> ><0HD500FZJ3B3YI at mta6.snfc21.pbi.net> for 
> >albatross-users at object-craft.com.au; Thu, 10 Apr 2003 
> 10:59:27 -0700 (PDT)
> >X-Message-Info: JGTYoYF78jEHjJx36Oi8+Q1OJDRSDidP
> >Delivered-To: albatross-users at object-craft.com.au
> >Message-id: <3E956A3B.408 at swbell.net>
> >X-Accept-Language: en-us, en
> >User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.0.0) 
> >Gecko/20020529
> >Sender: albatross-users-admin at object-craft.com.au
> >Errors-To: albatross-users-admin at object-craft.com.au
> >X-BeenThere: albatross-users at object-craft.com.au
> >X-Mailman-Version: 2.0.11
> >Precedence: bulk
> >List-Unsubscribe: 
> ><https://www.object-craft.com.au/cgi-bin/mailman/listinfo/alb
> atross-users>,<mailto:albatross-users-request at object-craft.com
> .au?subject=unsubscribe>
> >List-Id: Albatross User's List <albatross-users.object-craft.com.au>
> >List-Post: <mailto:albatross-users at object-craft.com.au>
> >List-Help: 
> ><mailto:albatross-users-request at object-craft.com.au?subject=help>
> >List-Subscribe: 
> ><https://www.object-craft.com.au/cgi-bin/mailman/listinfo/alb
> atross-users>,<mailto:albatross-users-request at object-craft.com
> .au?subject=subscribe>
> >List-Archive: 
> <https://www.object-craft.com.au/pipermail/albatross-users/>
> >Return-Path: albatross-users-admin at object-craft.com.au
> >X-OriginalArrivalTime: 10 Apr 2003 18:01:06.0507 (UTC) 
> >FILETIME=[2883F9B0:01C2FF8B]
> >
> >
> >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
> >
> >_______________________________________________
> >Albatross-users mailing list
> >Albatross-users at object-craft.com.au
> >https://www.object-craft.com.au/cgi-bin/mailman/listinfo/alba
tross-users


_________________________________________________________________
Hotmail now available on Australian mobile phones. Go to  
http://ninemsn.com.au/mobilecentral/hotmail_mobile.asp

_______________________________________________
Albatross-users mailing list
Albatross-users at object-craft.com.au
https://www.object-craft.com.au/cgi-bin/mailman/listinfo/albatross-users




More information about the Albatross-users mailing list