From danb at champonline.com Wed Apr 2 00:26:52 2003 From: danb at champonline.com (Dan Bergan) Date: Tue, 01 Apr 2003 08:26:52 -0600 Subject: [albatross-users] pagination question Message-ID: <3E89A1AC.3080604@champonline.com> I have a strange problem with pagination. I saw a posting from a couple months ago for a similar question, but I didn't see an solution. Here's the behavior that I'm seeing. I have categories that each contain multiple items. When I click on a category, it shows me the items, and I have pagination set at 8 items. At first glance, it seemed that everything was working perfectly. When I click on a category with more than 8 items, the "next page" link shows up, and I can move to the next 8 items. Then my "previous page" link shows up and that works correctly as well. If I click on a category with fewer than 8 items, then there is no "next page" or "previous page" link, as I would expect. The problem shows up when I first click on a category with more than 8 items. Then I click on my "next page" link. (So, I'm looking at items 9 - 16). Then I use my browsers "Back" button to return my category listing page. If I now choose a different category, then the items that show up will be items 9 - 16 (not items 1 - 8 as I would expect). And, if that category has fewer than 8 items, it will show me a blank page with only a "previous page" link. Do I have to do something to reset my list iterator? Am I forgetting to do something to make it start at the beginning of the list? Thanks, Dan Bergan From gnb at itga.com.au Wed Apr 2 08:55:26 2003 From: gnb at itga.com.au (Gregory Bond) Date: Wed, 02 Apr 2003 08:55:26 +1000 Subject: [albatross-users] pagination question In-Reply-To: Your message of Tue, 01 Apr 2003 08:26:52 -0600. Message-ID: <200304012255.IAA23295@lightning.itga.com.au> > 9 - 16). Then I use my browsers "Back" button to return my category > listing page. This is your problem! Stateful applications (where the state is maintained at the server, i.e. Albatross SessionServer or SessionFile mixins) tend to break badly with the use of back buttons. This is because the back button doesn't contact the server, it just shows the previous page, so what the user is seeing on the screen doesn't match where the application thinks it is up to. There are no good solutions to this problem that I've found except tell the users, "Don't do that." Easy for me, with a user base under a dozen! The Albatross RandomPage mixins help with that problem, but that involves quite a different application structure. From andrewm at object-craft.com.au Wed Apr 2 11:06:19 2003 From: andrewm at object-craft.com.au (Andrew McNamara) Date: Wed, 02 Apr 2003 11:06:19 +1000 Subject: [albatross-users] pagination question In-Reply-To: Message from Gregory Bond of "Wed, 02 Apr 2003 08:55:26 +1000." <200304012255.IAA23295@lightning.itga.com.au> References: <200304012255.IAA23295@lightning.itga.com.au> Message-ID: <20030402010619.DD4B03C221@coffee.object-craft.com.au> >> 9 - 16). Then I use my browsers "Back" button to return my category >> listing page. > >This is your problem! > >Stateful applications (where the state is maintained at the server, i.e. >Albatross SessionServer or SessionFile mixins) tend to break badly with the use >of back buttons. This is because the back button doesn't contact the server, >it just shows the previous page, so what the user is seeing on the screen >doesn't match where the application thinks it is up to.[...] The only option I can think of is to keep multiple versions of the state and include a version number in each request. This gives you an effect like that of hidden field sessions, and is probably enough in 90% of applications, but doesn't fully solve the problem. It might be possible to give the application enough information to allow it to make sensible choices when the user backtracks (or forks their browser). -- Andrew McNamara, Senior Developer, Object Craft http://www.object-craft.com.au/ From danb at champonline.com Wed Apr 2 16:11:10 2003 From: danb at champonline.com (Dan Bergan) Date: Wed, 02 Apr 2003 00:11:10 -0600 Subject: [albatross-users] pagination question In-Reply-To: <20030402010619.DD4B03C221@coffee.object-craft.com.au> References: <200304012255.IAA23295@lightning.itga.com.au> <20030402010619.DD4B03C221@coffee.object-craft.com.au> Message-ID: <3E8A7EFE.6040603@champonline.com> Andrew McNamara wrote: >The only option I can think of is to keep multiple versions of the state >and include a version number in each request. This gives you an effect >like that of hidden field sessions, and is probably enough in 90% of >applications, but doesn't fully solve the problem. It might be possible >to give the application enough information to allow it to make sensible >choices when the user backtracks (or forks their browser). > Ok, I made this a lot harder than I needed to! When I process the request (getting the list of products for a category), I just needed to re-initialize my ListIterator to None and everything works fine. So, in my template I have: (and so on...) and in my page_process() method I check the request, and if I am processing a new category, then I set ctx.locals.rec = None and everything works perfectly. I guess I didn't realize that the ListIterator "rec" would still be hanging around (but based on the behavior I was seeing, it makes perfect sense.) I've done this to myself a couple of times now... Albatross is a great framework, now I just have to keep reminding myself that I don't have to make it a difficult framework! Thanks, Dan From francis.meyvis at sonycom.com Thu Apr 3 01:58:28 2003 From: francis.meyvis at sonycom.com (Francis Meyvis) Date: Wed, 02 Apr 2003 17:58:28 +0200 Subject: [albatross-users] onRequest() & pagination Message-ID: <3E8B08A4.2070601@sonycom.com> Hoi, I've two questions (I've a workaround for the first) Question 1 I've this (simplified) form like this The REQUEST_URI, when selecting something from the popup menu, arriving in my cgi-application has the correct parameters at the end (something like "...?filterSelect=filterSelect"). But my context does not recognize it as a req_equals(). Is this normal or I'm a misunderstanding something? If I add next form element, the request is recognized however (I just tried this, I have no explanation) Question 2 This is related to pagination. The paginated list looks like this [] item 9 [x] item 10 [x] item 11 [] item 12 ... [] item 16 The check box options are remembered in a variable "selections". Is there a trick to remember the items that where selected in pages 1, 3, etc? Now the cgi-application when inspecting "selections" only sees item 10 and 11 while actually also items 5, 6, 17, 20 were. Thank you, francis From djc at object-craft.com.au Thu Apr 3 10:54:29 2003 From: djc at object-craft.com.au (Dave Cole) Date: 03 Apr 2003 10:54:29 +1000 Subject: [albatross-users] onRequest() & pagination In-Reply-To: <3E8B08A4.2070601@sonycom.com> References: <3E8B08A4.2070601@sonycom.com> Message-ID: >>>>> "Francis" == Francis Meyvis writes: Francis> Question 1 I've this (simplified) form like this Francis> Francis> onChange="this.form.submit()"/> Francis> Francis> The REQUEST_URI, when selecting something from the popup Francis> menu, arriving in my cgi-application has the correct Francis> parameters at the end (something like Francis> "...?filterSelect=filterSelect"). But my context does not Francis> recognize it as a req_equals(). Is this normal or I'm a Francis> misunderstanding something? It is normal (unfortunately). The problem is caused by Albatross recording the form elements constructed via tags, then restricting browser request merging to the values named in the tags. Currently the tag does not try to parse the action attribute to determine if there are additional values which should be accepted from the browser request. Francis> If I add next form element, the request is recognized however Francis> (I just tried this, I have no explanation) Francis> This makes the field "filterSelect" visible to the form recording process which occurs during / template expansion. This is explained at the bottom of this page (look for the text "__albform__"): http://www.object-craft.com.au/projects/albatross/albatross/fig-popview-sitemap.html Francis> Question 2 This is related to pagination. The paginated list Francis> looks like this Francis> Francis> [] item 9 Francis> [x] item 10 Francis> [x] item 11 Francis> [] item 12 ... Francis> [] item 16 Francis> The check box options are remembered in a variable Francis> "selections". Is there a trick to remember the items that Francis> where selected in pages 1, 3, etc? Now the cgi-application Francis> when inspecting "selections" only sees item 10 and 11 while Francis> actually also items 5, 6, 17, 20 were. You don't really give enough information here so I will present one way in which you could solve this problem (untested). ctx.locals.items = [...] ctx.locals.selected = ['10', '11'] ctx.add_session_vars('selected') item
- Dave -- http://www.object-craft.com.au From chironsw at swbell.net Thu Apr 10 22:57:31 2003 From: chironsw at swbell.net (Chiron Consulting) Date: Thu, 10 Apr 2003 12:57:31 +0000 Subject: [albatross-users] problems with a RandomModularSessionApp Message-ID: <3E956A3B.408@swbell.net> 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: # 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)) 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: 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)) 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 From the_edge2020 at hotmail.com Fri Apr 11 04:12:44 2003 From: the_edge2020 at hotmail.com (Tommy !!) Date: Fri, 11 Apr 2003 04:12:44 +1000 Subject: [albatross-users] problems with a RandomModularSessionApp Message-ID: 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 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 >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 >; 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: >, >List-Id: Albatross User's List >List-Post: >List-Help: > >List-Subscribe: >, >List-Archive: >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: > > > ># 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)) > > > >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: > > > >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)) > > > >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/albatross-users _________________________________________________________________ Hotmail now available on Australian mobile phones. Go to http://ninemsn.com.au/mobilecentral/hotmail_mobile.asp From the_edge2020 at hotmail.com Mon Apr 14 02:54:07 2003 From: the_edge2020 at hotmail.com (Tommy !!) Date: Mon, 14 Apr 2003 02:54:07 +1000 Subject: [albatross-users] problems with a RandomModularSessionApp Message-ID: Hi again Greg, Excuse the delay in posting this, life's tough when you're a student :P I'll continue on with the bugs I've discovered and fixed ... As a refresher, for anyone who missed my last post, there is a nasty bug in apacheapp.py. Simple little typo, really. But it's nasty enough to stop your program cold when using mod_python with albatross, as poor old Greg found out. The fix is as follows: replace line 34 with the following: return self.__req.server.server_hostname And the new stuff, which you will almost certainly encounter with SessionFileApp-style applications: In sessionfile.py, you may encounter problems when your session is first created due to a KeyError being raised in SessionFileContextMixin._get_sesid_from_cookie. The reason being that it tries to grab the session ID from the cookie (as the method name implies) - the thing is, the cookie hasn't been set when it's called. Thus, the line 'return os.path.basename( c[self.app.ses_appid()].value )' throws a KeyError since the SimpleCookie c does not have the cookie set just yet since the session has just started. Ouch. There's a few ways to fix this. All work to the same effect, however, so I'll present the simplest: # BEGIN FIXED CODE, LINE 36, sessionfile.py try: return os.path.basename( c[self.app.ses_appid()].value ) except OSError: pass # # FIX: catch a KeyError exception that may be thrown in the try # clause. # except KeyError: pass return None # END FIXED CODE And there you have it. Little problems like this are here and there in Albatross. Strangely, I still haven't heard back from the object-craft team regarding the initial bug you mentioned. Oh well. Take it easy, I'll post more bugs as I/if I find them. Kind regards, Tom L >From: Chiron Consulting >To: Tommy !! >Subject: Re: [albatross-users] problems with a RandomModularSessionApp >Date: Thu, 10 Apr 2003 13:33:03 +0000 >MIME-Version: 1.0 >Received: from mta5.snfc21.pbi.net ([206.13.28.241]) by >mc5-f32.law1.hotmail.com with Microsoft SMTPSVC(5.0.2195.5600); Thu, 10 Apr >2003 13:42:16 -0700 >Received: from swbell.net ([208.191.179.211]) by mta5.snfc21.pbi.net >(iPlanet Messaging Server 5.1 HotFix 1.6 (built Oct 18 2002)) with ESMTP id ><0HD500INI4YB4J at mta5.snfc21.pbi.net> for the_edge2020 at hotmail.com; Thu, 10 >Apr 2003 11:34:59 -0700 (PDT) >X-Message-Info: JGTYoYF78jEHjJx36Oi8+Q1OJDRSDidP >Message-id: <3E95728F.40108 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 >References: >Return-Path: chironsw at swbell.net >X-OriginalArrivalTime: 10 Apr 2003 20:42:16.0648 (UTC) >FILETIME=[AC5E6480:01C2FFA1] > > >>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 > >Great. That did it. > >>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. > >Please post them at your earliest convenience, the sooner the better. Any >fixes you can post are things I won't have to find and fix for myself. >Unless you can get the object-craft people to integrate them and release a >new minor version. > >>Long live OSS, eh? > >Eh, indeed! Thanks loads. > >-- >Greg Goodman >Chiron Consulting > _________________________________________________________________ MSN Instant Messenger now available on Australian mobile phones.?Go to http://ninemsn.com.au/mobilecentral/hotmail_messenger.asp From the_edge2020 at hotmail.com Mon Apr 14 02:57:53 2003 From: the_edge2020 at hotmail.com (Tommy !!) Date: Mon, 14 Apr 2003 02:57:53 +1000 Subject: [albatross-users] problems with a RandomModularSessionApp Message-ID: Argh ... indentation of the code went screwy. You get the idea anyway. Tom L >From: "Tommy !!" >To: albatross-users at object-craft.com.au, chironsw at swbell.net >Subject: Re: [albatross-users] problems with a RandomModularSessionApp >Date: Mon, 14 Apr 2003 02:54:07 +1000 >MIME-Version: 1.0 >X-Originating-IP: [203.221.71.164] >X-Originating-Email: [the_edge2020 at hotmail.com] >Received: from mail.object-craft.com.au ([210.23.136.24]) by >mc7-f37.law1.hotmail.com with Microsoft SMTPSVC(5.0.2195.5600); Sun, 13 Apr >2003 09:55:04 -0700 >Received: from numbat.object-craft.com.au (localhost [127.0.0.1])by >mail.object-craft.com.au (Postfix) with ESMTPid 9535D16DD8; Mon, 14 Apr >2003 02:55:02 +1000 (EST) >Received: from hotmail.com (f10.sea2.hotmail.com [207.68.165.10])by >mail.object-craft.com.au (Postfix) with ESMTP id 9A54116DD4for >; Mon, 14 Apr 2003 02:54:10 +1000 >(EST) >Received: from mail pickup service by hotmail.com with Microsoft SMTPSVC; >Sun, 13 Apr 2003 09:54:08 -0700 >Received: from 203.221.71.164 by sea2fd.sea2.hotmail.msn.com with HTTP;Sun, >13 Apr 2003 16:54:07 GMT >X-Message-Info: JGTYoYF78jEHjJx36Oi8+Q1OJDRSDidP >Delivered-To: albatross-users at object-craft.com.au >Message-ID: >X-OriginalArrivalTime: 13 Apr 2003 16:54:08.0253 (UTC) >FILETIME=[4CB052D0:01C301DD] >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: >, >List-Id: Albatross User's List >List-Post: >List-Help: > >List-Subscribe: >, >List-Archive: >Return-Path: albatross-users-admin at object-craft.com.au > >Hi again Greg, > >Excuse the delay in posting this, life's tough when you're a student :P > >I'll continue on with the bugs I've discovered and fixed ... > >As a refresher, for anyone who missed my last post, there is a nasty bug in >apacheapp.py. Simple little typo, really. But it's nasty enough to stop >your program cold when using mod_python with albatross, as poor old Greg >found out. > >The fix is as follows: > >replace line 34 with the following: > > return self.__req.server.server_hostname > >And the new stuff, which you will almost certainly encounter with >SessionFileApp-style applications: > >In sessionfile.py, you may encounter problems when your session is first >created due to a KeyError being raised in >SessionFileContextMixin._get_sesid_from_cookie. The reason being that it >tries to grab the session ID from the cookie (as the method name implies) - >the thing is, the cookie hasn't been set when it's called. > >Thus, the line 'return os.path.basename( c[self.app.ses_appid()].value )' >throws a KeyError since the SimpleCookie c does not have the cookie set >just yet since the session has just started. Ouch. > >There's a few ways to fix this. All work to the same effect, however, so >I'll present the simplest: > ># BEGIN FIXED CODE, LINE 36, sessionfile.py > >try: > return os.path.basename( c[self.app.ses_appid()].value ) >except OSError: > pass ># ># FIX: catch a KeyError exception that may be thrown in the try ># clause. ># >except KeyError: > pass > >return None > ># END FIXED CODE > >And there you have it. Little problems like this are here and there in >Albatross. > >Strangely, I still haven't heard back from the object-craft team regarding >the initial bug you mentioned. Oh well. > >Take it easy, I'll post more bugs as I/if I find them. > >Kind regards, >Tom L > > > > > > >>From: Chiron Consulting >>To: Tommy !! >>Subject: Re: [albatross-users] problems with a RandomModularSessionApp >>Date: Thu, 10 Apr 2003 13:33:03 +0000 >>MIME-Version: 1.0 >>Received: from mta5.snfc21.pbi.net ([206.13.28.241]) by >>mc5-f32.law1.hotmail.com with Microsoft SMTPSVC(5.0.2195.5600); Thu, 10 >>Apr 2003 13:42:16 -0700 >>Received: from swbell.net ([208.191.179.211]) by mta5.snfc21.pbi.net >>(iPlanet Messaging Server 5.1 HotFix 1.6 (built Oct 18 2002)) with ESMTP >>id <0HD500INI4YB4J at mta5.snfc21.pbi.net> for the_edge2020 at hotmail.com; Thu, >>10 Apr 2003 11:34:59 -0700 (PDT) >>X-Message-Info: JGTYoYF78jEHjJx36Oi8+Q1OJDRSDidP >>Message-id: <3E95728F.40108 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 >>References: >>Return-Path: chironsw at swbell.net >>X-OriginalArrivalTime: 10 Apr 2003 20:42:16.0648 (UTC) >>FILETIME=[AC5E6480:01C2FFA1] >> >> >>>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 >> >>Great. That did it. >> >>>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. >> >>Please post them at your earliest convenience, the sooner the better. Any >>fixes you can post are things I won't have to find and fix for myself. >>Unless you can get the object-craft people to integrate them and release a >>new minor version. >> >>>Long live OSS, eh? >> >>Eh, indeed! Thanks loads. >> >>-- >>Greg Goodman >>Chiron Consulting >> > > >_________________________________________________________________ >MSN Instant Messenger now available on Australian mobile phones.?Go to >http://ninemsn.com.au/mobilecentral/hotmail_messenger.asp > >_______________________________________________ >Albatross-users mailing list >Albatross-users at object-craft.com.au >https://www.object-craft.com.au/cgi-bin/mailman/listinfo/albatross-users _________________________________________________________________ Hotmail now available on Australian mobile phones. Go to http://ninemsn.com.au/mobilecentral/hotmail_mobile.asp From neel at mediapulse.com Mon Apr 14 06:11:39 2003 From: neel at mediapulse.com (Michael C. Neel) Date: Sun, 13 Apr 2003 16:11:39 -0400 Subject: [albatross-users] problems with a RandomModularSessionApp In-Reply-To: Message-ID: <000001c301f8$e51a2940$af00a8c0@CLAPTON> 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 > 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 > >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 > >; 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: > > atross-users>, .au?subject=unsubscribe> > >List-Id: Albatross User's List > >List-Post: > >List-Help: > > > >List-Subscribe: > > atross-users>, .au?subject=subscribe> > >List-Archive: > > >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: > > > > > > > ># 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)) > > > > > > > >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: > > > > > > > >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)) > > > > > > > >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 From vlindberg at verio.net Tue Apr 22 03:38:36 2003 From: vlindberg at verio.net (VanL) Date: Mon, 21 Apr 2003 11:38:36 -0600 Subject: [albatross-users] Patch to albatross app.py Message-ID: <3EA42C9C.7000403@verio.net> Hello, Just started using albatross. In app.py: If you delete the .pyc file in a Modular App, you get the following error: Template traceback (most recent call last): Traceback (most recent call last): File "/usr/local/webmanager/pylib/albatross/app.py", line 143, in run self.load_page(ctx) File "/usr/local/webmanager/pylib/albatross/app.py", line 252, in load_page ctx.set_page(name) File "/usr/local/webmanager/pylib/albatross/app.py", line 86, in set_page self.app.load_page(self) File "/usr/local/webmanager/pylib/albatross/app.py", line 253, in load_page self.load_page_module(ctx, name) File "/usr/local/webmanager/pylib/albatross/app.py", line 262, in load_page_module mtime = os.stat(page.__file__)[stat.ST_MTIME] OSError: [Errno 2] No such file or directory: '/www/htdocs/albatross/testing/Test.pyc' In this case, Test.py was replaced by test.py. To fix this, change line 260-268 of app.py from page = self.__cache.get(path) if page: mtime = os.stat(page.__file__)[stat.ST_MTIME] if mtime > page.__mtime__: reload(page) page.__mtime__ = mtime if not page: dirname, name = os.path.split(path) to page = self.__cache.get(path) pageexists = os.path.exists(page) if page and pageexists: mtime = os.stat(page.__file__)[stat.ST_MTIME] if mtime > page.__mtime__: reload(page) page.__mtime__ = mtime if not page or not pageexists: dirname, name = os.path.split(path) Thanks, VanL From vlindberg at verio.net Tue Apr 22 03:50:02 2003 From: vlindberg at verio.net (VanL) Date: Mon, 21 Apr 2003 11:50:02 -0600 Subject: [albatross-users] Patch to albatross app.py In-Reply-To: <3EA42C9C.7000403@verio.net> References: <3EA42C9C.7000403@verio.net> Message-ID: <3EA42F4A.4000107@verio.net> Hello, Sorry, I forgot one part of it. (Pasted from an older version). Here is the full fix: page = self.__cache.get(path) if page: pageexists = os.path.exists(page.__file__) else: pageexists = 0 if page and pageexists: mtime = os.stat(page.__file__)[stat.ST_MTIME] if mtime > page.__mtime__: reload(page) page.__mtime__ = mtime if not page or not pageexists: dirname, name = os.path.split(path) VanL wrote: > Hello, > > Just started using albatross. > In app.py: > > If you delete the .pyc file in a Modular App, you get the following > error: > Template traceback (most recent call last): > > Traceback (most recent call last): > File "/usr/local/webmanager/pylib/albatross/app.py", line 143, in run > self.load_page(ctx) > File "/usr/local/webmanager/pylib/albatross/app.py", line 252, in > load_page > ctx.set_page(name) > File "/usr/local/webmanager/pylib/albatross/app.py", line 86, in > set_page > self.app.load_page(self) > File "/usr/local/webmanager/pylib/albatross/app.py", line 253, in > load_page > self.load_page_module(ctx, name) > File "/usr/local/webmanager/pylib/albatross/app.py", line 262, in > load_page_module > mtime = os.stat(page.__file__)[stat.ST_MTIME] > OSError: [Errno 2] No such file or directory: > '/www/htdocs/albatross/testing/Test.pyc' > > In this case, Test.py was replaced by test.py. > > To fix this, change line 260-268 of app.py from > > page = self.__cache.get(path) > if page: > mtime = os.stat(page.__file__)[stat.ST_MTIME] > if mtime > page.__mtime__: > reload(page) > page.__mtime__ = mtime > if not page: > dirname, name = os.path.split(path) > > to > > page = self.__cache.get(path) > pageexists = os.path.exists(page) > if page and pageexists: > mtime = os.stat(page.__file__)[stat.ST_MTIME] > if mtime > page.__mtime__: > reload(page) > page.__mtime__ = mtime > if not page or not pageexists: > dirname, name = os.path.split(path) > > > > Thanks, > > VanL > > _______________________________________________ > Albatross-users mailing list > Albatross-users at object-craft.com.au > https://www.object-craft.com.au/cgi-bin/mailman/listinfo/albatross-users From vlindberg at verio.net Wed Apr 23 04:03:15 2003 From: vlindberg at verio.net (VanL) Date: Tue, 22 Apr 2003 12:03:15 -0600 Subject: [albatross-users] Getting things *out* of session_vars? Message-ID: <3EA583E3.6050101@verio.net> Hello, I am using sentinel values in my session_vars to check that a user has both completed a required form and that the user hasn't done something silly, like press back. I am dutifully adding these values to session_vars, but when I test from them on the next page, I can't find them and I am redirected back. I think that I am looking in the wrong place. I am looking in ctx.locals. Is there another place that I should be looing for saved variables? ctx.session, perhaps? Thanks, VanL From neel at mediapulse.com Wed Apr 23 07:22:44 2003 From: neel at mediapulse.com (Michael C. Neel) Date: Tue, 22 Apr 2003 17:22:44 -0400 Subject: [albatross-users] Getting things *out* of session_vars? Message-ID: Are you etting up a cxt.locals member befor adding to the session? ie first ctx.local.var = "test" then... ctx.add_session_vars("var") mike -----Original Message----- From: VanL [mailto:vlindberg at verio.net] Sent: Tuesday, April 22, 2003 2:03 PM To: albatross-users at object-craft.com.au Subject: [albatross-users] Getting things *out* of session_vars? Hello, I am using sentinel values in my session_vars to check that a user has both completed a required form and that the user hasn't done something silly, like press back. I am dutifully adding these values to session_vars, but when I test from them on the next page, I can't find them and I am redirected back. I think that I am looking in the wrong place. I am looking in ctx.locals. Is there another place that I should be looing for saved variables? ctx.session, perhaps? Thanks, VanL _______________________________________________ Albatross-users mailing list Albatross-users at object-craft.com.au https://www.object-craft.com.au/cgi-bin/mailman/listinfo/albatross-users From vlindberg at verio.net Wed Apr 23 08:36:51 2003 From: vlindberg at verio.net (VanL) Date: Tue, 22 Apr 2003 16:36:51 -0600 Subject: [albatross-users] Getting things *out* of session_vars? In-Reply-To: References: Message-ID: <3EA5C403.9000501@verio.net> My code looks like this: all_vars = [var1, var2, var3] for v in all_vars: if not ctx.req_equals(var) or ctx.get_value(var) != 'some good value': ctx.locals.error = 'var is set to bad value' # If you get to here, all validation checks passed for v in all_vars: ctx.add_session_var(v) Sorry if some of the function names are slightly wrong, I am away from the code currently. But this should be enough to give you an idea. VanL Michael C. Neel wrote: >Are you etting up a cxt.locals member befor adding to the session? > >ie first >ctx.local.var = "test" > then... >ctx.add_session_vars("var") > >mike > >-----Original Message----- >From: VanL [mailto:vlindberg at verio.net] >Sent: Tuesday, April 22, 2003 2:03 PM >To: albatross-users at object-craft.com.au >Subject: [albatross-users] Getting things *out* of session_vars? > > >Hello, > >I am using sentinel values in my session_vars to check that a user has >both completed a required form and that the user hasn't done something >silly, like press back. > >I am dutifully adding these values to session_vars, but when I test from > >them on the next page, I can't find them and I am redirected back. I >think that I am looking in the wrong place. > >I am looking in ctx.locals. Is there another place that I should be >looing for saved variables? ctx.session, perhaps? > >Thanks, > >VanL > >_______________________________________________ >Albatross-users mailing list Albatross-users at object-craft.com.au >https://www.object-craft.com.au/cgi-bin/mailman/listinfo/albatross-users > > From neel at mediapulse.com Wed Apr 23 08:41:07 2003 From: neel at mediapulse.com (Michael C. Neel) Date: Tue, 22 Apr 2003 18:41:07 -0400 Subject: [albatross-users] Getting things *out* of session_vars? Message-ID: You need to add the following line to the second part: for v in all_vars: setarrt(ctx.locals,v, None) ctx.add_session_var(v) I'm not sure where you would get the default value from, but if it needs to be set to something other than none you'll need to change it. Also, make sure this happens in page_enter, not page_process, or you'll wipe everything each request. Hth. Mike -----Original Message----- From: VanL [mailto:vlindberg at verio.net] Sent: Tuesday, April 22, 2003 6:37 PM To: Michael C. Neel; albatross-users at object-craft.com.au Subject: Re: [albatross-users] Getting things *out* of session_vars? My code looks like this: all_vars = [var1, var2, var3] for v in all_vars: if not ctx.req_equals(var) or ctx.get_value(var) != 'some good value': ctx.locals.error = 'var is set to bad value' # If you get to here, all validation checks passed for v in all_vars: ctx.add_session_var(v) Sorry if some of the function names are slightly wrong, I am away from the code currently. But this should be enough to give you an idea. VanL Michael C. Neel wrote: >Are you etting up a cxt.locals member befor adding to the session? > >ie first >ctx.local.var = "test" > then... >ctx.add_session_vars("var") > >mike > >-----Original Message----- >From: VanL [mailto:vlindberg at verio.net] >Sent: Tuesday, April 22, 2003 2:03 PM >To: albatross-users at object-craft.com.au >Subject: [albatross-users] Getting things *out* of session_vars? > > >Hello, > >I am using sentinel values in my session_vars to check that a user has >both completed a required form and that the user hasn't done something >silly, like press back. > >I am dutifully adding these values to session_vars, but when I test >from > >them on the next page, I can't find them and I am redirected back. I >think that I am looking in the wrong place. > >I am looking in ctx.locals. Is there another place that I should be >looing for saved variables? ctx.session, perhaps? > >Thanks, > >VanL > >_______________________________________________ >Albatross-users mailing list Albatross-users at object-craft.com.au >https://www.object-craft.com.au/cgi-bin/mailman/listinfo/albatross-user >s > > From vlindberg at verio.net Wed Apr 23 11:41:54 2003 From: vlindberg at verio.net (VanL) Date: Tue, 22 Apr 2003 19:41:54 -0600 Subject: [albatross-users] Getting things *out* of session_vars? In-Reply-To: References: Message-ID: <3EA5EF62.4050304@verio.net> Hello, Michael C. Neel wrote: >You need to add the following line to the second part: > >for v in all_vars: > setarrt(ctx.locals,v, None) > ctx.add_session_var(v) > I neglected to say this, but for most vars I *am* doing this on page_enter. The problem occurs on the next page: [Previous code here] [Passes all validation checks] [add session vars] ctx.set_page('nextpage') On the nextpage def page_process(ctx): if not hasattr(ctx.locals, 'var_set_on_previous_page'): # Var set on previous page is not here. Bounce back ctx.set_page('prevpage') I keep on getting bounced back to prevpage, which makes me think that the session vars aren't in ctx.locals. Hence my original question, how do I get stuff out of session_vars? On a related note, I do have a page_enter function def page_enter(ctx): # Initialization here if not hasattr(ctx.locals, somevar): setattr(ctx.locals, 'somevar', '') However, I have to call this function manually, in page_display: def page_display(ctx): page_enter(ctx) [continue] Is that right? I got the impression that a function of that name would be called automagically. I am using mod_python 2.78, albatross 1.01, python2.2, apache 1.3-recent something. This is a ModularSessionFileApp. VanL From neel at mediapulse.com Thu Apr 24 01:48:50 2003 From: neel at mediapulse.com (Michael C. Neel) Date: Wed, 23 Apr 2003 11:48:50 -0400 Subject: [albatross-users] Getting things *out* of session_vars? Message-ID: You have to create the ctx.local.(var) for all vars you will be adding to the session before you add them. This was brought up on the list, and some alternate methods to the system talked about, I don't know if the next release made any changes though. You should not have to call page_enter yourself. Without seeing the app, page objects, and the templates used it hard to say why you are having to do that. With a little more info, someone on the list might be able to see exactly whats going wrong. Mike -----Original Message----- From: VanL [mailto:vlindberg at verio.net] Sent: Tuesday, April 22, 2003 9:42 PM To: Michael C. Neel Cc: albatross-users at object-craft.com.au Subject: Re: [albatross-users] Getting things *out* of session_vars? Hello, Michael C. Neel wrote: >You need to add the following line to the second part: > >for v in all_vars: > setarrt(ctx.locals,v, None) > ctx.add_session_var(v) > I neglected to say this, but for most vars I *am* doing this on page_enter. The problem occurs on the next page: [Previous code here] [Passes all validation checks] [add session vars] ctx.set_page('nextpage') On the nextpage def page_process(ctx): if not hasattr(ctx.locals, 'var_set_on_previous_page'): # Var set on previous page is not here. Bounce back ctx.set_page('prevpage') I keep on getting bounced back to prevpage, which makes me think that the session vars aren't in ctx.locals. Hence my original question, how do I get stuff out of session_vars? On a related note, I do have a page_enter function def page_enter(ctx): # Initialization here if not hasattr(ctx.locals, somevar): setattr(ctx.locals, 'somevar', '') However, I have to call this function manually, in page_display: def page_display(ctx): page_enter(ctx) [continue] Is that right? I got the impression that a function of that name would be called automagically. I am using mod_python 2.78, albatross 1.01, python2.2, apache 1.3-recent something. This is a ModularSessionFileApp. VanL From vlindberg at verio.net Thu Apr 24 06:34:02 2003 From: vlindberg at verio.net (VanL) Date: Wed, 23 Apr 2003 14:34:02 -0600 Subject: [albatross-users] Getting things *out* of session_vars? In-Reply-To: References: Message-ID: <3EA6F8BA.6050001@verio.net> Here is a pretty minimal example that shows the page_enter problem. login.py: ================================ def page_enter(ctx): if not hasattr(ctx.locals, 'login_message'): setattr(ctx.locals, 'login_message', 'Please enter your username and password:') if not hasattr(ctx.locals, 'user'): setattr(ctx.locals, 'user', '') def page_process(ctx): if ctx.req_equals('login'): if hasattr(ctx.locals, 'user') and hasattr(ctx.locals, 'passwd'): user, passwd = ctx.get_value('user'), ctx.get_value('passwd') if user and passwd: if authenticate(user, passwd): ctx.add_session_vars('user', 'passwd') ctx.set_page('controlpanel') return def page_display(ctx): ctx.run_template('login.html') ========================================== login.html: ===================================

========================================== Run this and it shows up fine the first time. If you submit true values for user and passwd, it will forward just fine. However, if you submit bad values: Template traceback (most recent call last): File "/www/htdocs/albatross/new_cust_wizard/login.html", line 16, in al-form File "/www/htdocs/albatross/new_cust_wizard/login.html", line 21, in al-value Traceback (most recent call last): [Snip] File "", line 0, in ? NameError: name 'login_message' is not defined I thought that once I had defined a default value in page_enter, it would stay set. That is why I thought that perhaps page_enter was not being called. Could someone point out my error? Thanks, VanL From neel at mediapulse.com Thu Apr 24 07:05:34 2003 From: neel at mediapulse.com (Michael C. Neel) Date: Wed, 23 Apr 2003 17:05:34 -0400 Subject: [albatross-users] Getting things *out* of session_vars? Message-ID: ctx.add_session_vars('user', 'passwd') should be done in page_enter. And (someone correct me if I'm wrong) but in page_enter you can count on locals being empty. So you can simply have: def page_enter(ctx): ctx.locals.login_message = 'Please enter your username and password:' ctx.locals.user = '' ctx.locals.passwd = '' ctx.add_session_vars('user', 'passwd', 'login_message') hth, Mike -----Original Message----- From: VanL [mailto:vlindberg at verio.net] Sent: Wednesday, April 23, 2003 4:34 PM To: Michael C. Neel Cc: albatross-users at object-craft.com.au Subject: Re: [albatross-users] Getting things *out* of session_vars? Here is a pretty minimal example that shows the page_enter problem. login.py: ================================ def page_enter(ctx): if not hasattr(ctx.locals, 'login_message'): setattr(ctx.locals, 'login_message', 'Please enter your username and password:') if not hasattr(ctx.locals, 'user'): setattr(ctx.locals, 'user', '') def page_process(ctx): if ctx.req_equals('login'): if hasattr(ctx.locals, 'user') and hasattr(ctx.locals, 'passwd'): user, passwd = ctx.get_value('user'), ctx.get_value('passwd') if user and passwd: if authenticate(user, passwd): ctx.add_session_vars('user', 'passwd') ctx.set_page('controlpanel') return def page_display(ctx): ctx.run_template('login.html') ========================================== login.html: ===================================

========================================== Run this and it shows up fine the first time. If you submit true values for user and passwd, it will forward just fine. However, if you submit bad values: Template traceback (most recent call last): File "/www/htdocs/albatross/new_cust_wizard/login.html", line 16, in al-form File "/www/htdocs/albatross/new_cust_wizard/login.html", line 21, in al-value Traceback (most recent call last): [Snip] File "", line 0, in ? NameError: name 'login_message' is not defined I thought that once I had defined a default value in page_enter, it would stay set. That is why I thought that perhaps page_enter was not being called. Could someone point out my error? Thanks, VanL From djc at object-craft.com.au Thu Apr 24 09:31:32 2003 From: djc at object-craft.com.au (Dave Cole) Date: 24 Apr 2003 09:31:32 +1000 Subject: [albatross-users] Getting things *out* of session_vars? In-Reply-To: References: Message-ID: > ctx.add_session_vars('user', 'passwd') should be done in page_enter. > And (someone correct me if I'm wrong) but in page_enter you can > count on locals being empty. So you can simply have: > > def page_enter(ctx): > ctx.locals.login_message = 'Please enter your username and password:' > ctx.locals.user = '' > ctx.locals.passwd = '' > ctx.add_session_vars('user', 'passwd', 'login_message') That should certainly do it. The way to answer whether or not to place something in the session is to decide if you want it to survive a round trip to and from the browser. If you want ctx.locals.login_message to be in ctx.locals when you display the next page you either have to place it in the session, or recreate it in your page_process() method/function. The sequence of calls to your page_* code goes a bit like this: # session loaded before this point if this_is_a_new_session: ctx.set_page(first_page) page_process(ctx) page_display(ctx) # session saved after here Calling ctx.set_page(name) loads the new page and then calls page_enter(). This happens at the start of a new session, and when code in page_process() changes page via ctx.set_page(). - Dave -- http://www.object-craft.com.au From korg at darkqueen.org Fri Apr 25 12:13:26 2003 From: korg at darkqueen.org (Cameron Blackwood) Date: Fri, 25 Apr 2003 12:13:26 +1000 Subject: [albatross-users] Albatross login page? In-Reply-To: Your message of "Fri, 25 Apr 2003 06:25:03 +1000." <20030424202503.10707.9606.Mailman@numbat.object-craft.com.au> Message-ID: <200304250213.h3P2DQS05260@firewall.darkqueen.org> Ive just been thinking wheels and reinventing them :) Lots of people must need a login class for Albatross, right? (To identify a user from some sort of data base/password thingie.) That got me thinking: is there any 'sample archive' of such albatross code? It seems like a kind of useful thing to have. I've got a simple one (with no encryption on the password transfer etc), but I havnt really explored albatross internals enough to know if one could do it with any sort of security/encryption or what the 'best' way to do it is. Opinions? Ideas? cheers, cam -- / `Rev Dr' cameron.blackwood at darkqueen.org Roleplaying, virtual goth \ < http://darkqueen.org Poly, *nix, Python, C/C++, genetics, ATM > \ [+61 3] 9809 1523[h] skeptic, Evil GM(tm). Sysadmin for hire / ---------- Random Quote ---------- The nice thing about Windows is - It does not just crash, it displays a dialog box and lets you press 'OK' first. (Arno Schaefer's .sig)