From rbb at techgame.net Thu Nov 7 09:27:36 2002 From: rbb at techgame.net (Brian Brown) Date: Wed, 6 Nov 2002 15:27:36 -0700 Subject: [albatross-users] Transferring a site Message-ID: I've been developing a site on my MacOSX notebook with mod_python and Albatross. Works great. I've just tried to get it going on an OpenBSD box using mod_python/apache and Albatross, without much success. Mod_python is loading fine, Albatross installed without a hitch. I've tried with both an .htaccess file as well as setting the config for my directory in the httpd.conf - when I try to to run anything, Albatross returns apache.OK and sends out the default "Oops!" page instead of any content from the site. I have looked at everything 100 times and made sure my PythonPath was set in the httpd.conf, but to no avail.... anyone have any suggestions? I don't think this is an Albatross problem, but I'm not sure. Albatross 1.01, python 2.2, mod_python 2.7.8, latest apache 1.3 series. Thanks! Brian From gregh at object-craft.com.au Thu Nov 7 11:42:47 2002 From: gregh at object-craft.com.au (Greg Hamilton) Date: Thu, 7 Nov 2002 11:42:47 +1100 Subject: [albatross-users] Transferring a site In-Reply-To: <50A604B0-F1E3-11D6-B6E0-003065F89450@techgame.net> Message-ID: Are you able to run a simple 'Hello World' cgi script ? This is all stuff you've almost certainly already checked and it might not be relevant anyway as I don't know anything about configuring Apache with mod_python : For a regular CGI config you need to tell Apache it can execute scripts in your either by using the ScriptAlias directive or something like this - Options All MultiViews ExecCGI .... The AddHandler directive is handy for letting Apache know which file types to execute as cgi- eg. AddHandler cgi-script .cgi .py .pl I would definitely try to run the Albatross app without mod_python to eliminate mod_python as a possible cause of the problem. Good luck Greg Hamilton On Thursday, November 7, 2002, at 10:56 AM, Brian Brown wrote: > > On Wednesday, November 6, 2002, at 03:55 PM, Greg Hamilton wrote: > >> Brian, >> >> it sounds like an Apache configuration problem to me. >> >> Have you tried running without mod_python ? >> > No, not yet > > >> Is the main module of your Albatross app executable ? I have a >> feeling some types of file transfer (ftp ?) don't maintain file >> permissions so transferring from your laptop to the OpenBSD box may >> have broken the app. >> > > All the code is in cvs, so that should be an issue, I just did a cvs > checkout on the site. > > >> Have you checked the Apache error log ? If you have an Apache config >> problem or something is going wrong with your Python code that >> doesn't result in a traceback displayed in your browser then the >> error should end up in the Apache error log. >> > > The error logs show no errors, which leads me to believe that my main > app is returning apache.OK > > here is what I have the PythonHandler set to(nbc.py) > from mod_python import apache > from albatross import RandomModularSessionApp, SessionAppContext > from albatross.apacheapp import Request > > class AppContext(SessionAppContext): > def __init__(self, appctx): > SessionAppContext.__init__(self, appctx) > self.locals.menulist = { 'Home':'home', > 'Ministries':'ministries', > 'Beliefs':'beliefs', > 'Information': 'info' > } > self.submenulist = {'Contact Us': 'contact', 'About > Us':'about'} > self.add_session_vars('submenulist') > self.locals.realpath = "/u01/www/sites/norwood/Site/pages" > > def set_sub(self, menu): > self.submenulist = menu > > def get_sub(self): > return self.submenulist > > class App(RandomModularSessionApp): > def __init__(self): > RandomModularSessionApp.__init__(self, > base_url = 'nbc', > #page_path = './pages', > page_path = > '/u01/www/sites/norwood/Site/pages', > #module_path = > '/u01/www/sites/norwood/Site', > #template_path = > '/u01/www/sites/norwood/Site', > start_page = 'home', > secret = 'secret', > session_appid = 'nbc1' > ) > def create_context(self): > return AppContext(self) > > > def handler(req): > app.run(Request(req)) > return apache.OK > > app = App() > > # load the macros > app.load_template('/u01/www/sites/norwood/Site/pages/ > macros.html').to_html( > app) > ----------- > And here is the apache config part that is relevant(although I've had > it in and out of a VirtualHost directive) : > > > AllowOverride All > PythonPath > "['/u01/www/sites/norwood/Site','/usr/local/lib/python2.2','/usr/ > local/lib/ > python2.2/site-packages','/usr/local/lib/python2.2/site- > packages/albatross','/usr/local/lib/python2.2/site- > packages/mod_python','/usr/local/lib/python2.2/lib-dynload']" > #AddHandler python-program .py .html > Options All MultiViews > SetHandler python-program > PythonHandler nbc > PythonDebug On > > > > >> Greg Hamilton >> >> On Thursday, November 7, 2002, at 09:27 AM, Brian Brown wrote: >> >>> I've been developing a site on my MacOSX notebook with mod_python >>> and Albatross. Works great. I've just tried to get it going on an >>> OpenBSD box using mod_python/apache and Albatross, without much >>> success. >>> >>> Mod_python is loading fine, Albatross installed without a hitch. >>> I've tried with both an .htaccess file as well as setting the >>> config for my directory in the httpd.conf - when I try to to run >>> anything, Albatross returns apache.OK and sends out the default >>> "Oops!" page instead of any content from the site. I have looked at >>> everything 100 times and made sure my PythonPath was set in the >>> httpd.conf, but to no avail.... anyone have any suggestions? I >>> don't think this is an Albatross problem, but I'm not sure. >>> >>> Albatross 1.01, python 2.2, mod_python 2.7.8, latest apache 1.3 >>> series. >>> >>> Thanks! >>> >>> Brian >>> >>> _______________________________________________ >>> Albatross-users mailing list >>> Albatross-users at object-craft.com.au >>> https://www.object-craft.com.au/cgi-bin/mailman/listinfo/albatross- >>> users >>> >> > -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: text/enriched Size: 5326 bytes Desc: not available URL: From andrewm at object-craft.com.au Thu Nov 7 12:49:08 2002 From: andrewm at object-craft.com.au (Andrew McNamara) Date: Thu, 07 Nov 2002 12:49:08 +1100 Subject: [albatross-users] Transferring a site In-Reply-To: Message from Brian Brown of "Wed, 06 Nov 2002 15:27:36 PDT." References: Message-ID: <20021107014908.A0E393C416@coffee.object-craft.com.au> >I've been developing a site on my MacOSX notebook with mod_python and >Albatross. Works great. I've just tried to get it going on an OpenBSD >box using mod_python/apache and Albatross, without much success. One trick I often use when I have no other clues is truss/strace/ktrace (it's name varies, but the functionality is the same - attach to a running process and display the system calls it performs). >Mod_python is loading fine, Albatross installed without a hitch. I've >tried with both an .htaccess file as well as setting the config for my >directory in the httpd.conf - when I try to to run anything, Albatross >returns apache.OK and sends out the default "Oops!" page instead of any >content from the site. I have looked at everything 100 times and made >sure my PythonPath was set in the httpd.conf, but to no avail.... anyone >have any suggestions? I don't think this is an Albatross problem, but >I'm not sure. Have you checked the apache error log? Another gotchya I ran into was my mod_python build was running a different version of python to the main install on my machine (this is because the python interpreter is linked into the mod_python module). The old version of python used by mod_python didn't have Albatross installed... 8-) Also, as Greg suggests, try to get a simple "Hello, World!" style mod_python to work first (without involving Albatross), and if that works, an Albatross version of the same thing. -- Andrew McNamara, Senior Developer, Object Craft http://www.object-craft.com.au/ From korg at darkqueen.org Fri Nov 8 14:21:23 2002 From: korg at darkqueen.org (Cameron Blackwood) Date: Fri, 08 Nov 2002 14:21:23 +1100 Subject: [albatross-users] Newbie albatross question :) Message-ID: <200211080321.gA83LNT25760@firewall.darkqueen.org> I guess, given that the objects are selected from the url, ctx.set_page('postlogin') shouldnt work from any of the Random*App classes. Or is it just me? :) 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 courtroom was pregnant (pun intended) with anxious silence as the judge solemnly considered his verdict in the paternity suit before him. Suddenly, he reached into the folds of his robes, drew out a cigar and ceremoniously handed it to the defendant. "Congratulations!" declaimed the jurist. "You have just become a father!" From korg at darkqueen.org Fri Nov 8 15:26:32 2002 From: korg at darkqueen.org (Cameron Blackwood) Date: Fri, 08 Nov 2002 15:26:32 +1100 Subject: [albatross-users] Oh, and another tricky one.. :) Message-ID: <200211080426.gA84QWX26475@firewall.darkqueen.org> This might be ugly, but Im trying to access an albatross object as an 'img src=', but the state isnt being extracted. It's calling an object, but it's calling the start object and the state is empty. Has anyone else abused ablbatross like this? (Im from a ZPublisher background and I want to be able to have my object 'draw' itself as an image :). 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 ---------- Laetrile is the pits. From korg at darkqueen.org Fri Nov 8 15:40:58 2002 From: korg at darkqueen.org (Cameron Blackwood) Date: Fri, 08 Nov 2002 15:40:58 +1100 Subject: [albatross-users] Oh, and another tricky one.. :) In-Reply-To: Your message of "Fri, 08 Nov 2002 15:26:32 +1100." <200211080426.gA84QWX26475@firewall.darkqueen.org> Message-ID: <200211080440.gA84ew026681@firewall.darkqueen.org> "Cameron Blackwood" writes In message <200211080426.gA84QWX26475 at firewall.darkq ueen.org>: | | This might be ugly, but Im trying to access an albatross | object as an 'img src=', but the state isnt being extracted. | | It's calling an object, but it's calling the start object | and the state is empty. OK, I'll read my debugging output more next time. It is calling the current 'object'. | | Has anyone else abused ablbatross like this? | | (Im from a ZPublisher background and I want to be able to | have my object 'draw' itself as an image :). | | 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 ---------- | Laetrile is the pits. | _______________________________________________ | Albatross-users mailing list | Albatross-users at object-craft.com.au | https://www.object-craft.com.au/cgi-bin/mailman/listinfo/albatross-users | -- / `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 ---------- Consider the following axioms carefully: "Everything's better when it sits on a Ritz." and "Everything's better with Blue Bonnet on it." What happens if one spreads Blue Bonnet margarine on a Ritz cracker? The thought is frightening. Is this how God came into being? Try not to consider the fact that "Things go better with Coke". From korg at darkqueen.org Fri Nov 8 16:50:58 2002 From: korg at darkqueen.org (Cameron Blackwood) Date: Fri, 08 Nov 2002 16:50:58 +1100 Subject: [albatross-users] Oh, and another tricky one.. :) In-Reply-To: Your message of "Fri, 08 Nov 2002 15:40:58 +1100." <200211080440.gA84ew026681@firewall.darkqueen.org> Message-ID: <200211080550.gA85owH27182@firewall.darkqueen.org> "Cameron Blackwood" writes In message <200211080440.gA84ew026681 at firewall.darkq ueen.org>: | | "Cameron Blackwood" writes In message <200211080426.gA84QWX26475 at firewall.d | arkq | ueen.org>: | | | | This might be ugly, but Im trying to access an albatross | | object as an 'img src=', but the state isnt being extracted. | | | | It's calling an object, but it's calling the start object | | and the state is empty. | | OK, I'll read my debugging output more next time. | | It is calling the current 'object'. *sigh* Hangs head in shame. My logging code was at fault. I have a UserPage object which has a form for various actions etc and also has an image. If I set the form settings and then hit the 'submit' button, it calls the UserPage's page_process and decodes the form inputs and then calls it again for the img. The image doesnt get the form changes, but if I make the UserPage set a state variable with the form info, then the UserPage/image call has access to the info. So it all works fine!! :^) Thanks and sorry for the bandwidth. (Now, I just need to change the Content-type type... :) -- / `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 ---------- "Good health" is merely the slowest rate at which one can die. From andrewm at object-craft.com.au Fri Nov 8 19:24:25 2002 From: andrewm at object-craft.com.au (Andrew McNamara) Date: Fri, 08 Nov 2002 19:24:25 +1100 Subject: [albatross-users] Oh, and another tricky one.. :) In-Reply-To: Message from "Cameron Blackwood" of "Fri, 08 Nov 2002 16:50:58 +1100." <200211080550.gA85owH27182@firewall.darkqueen.org> References: <200211080550.gA85owH27182@firewall.darkqueen.org> Message-ID: <20021108082425.E28673C188@coffee.object-craft.com.au> >I have a UserPage object which has a form for various >actions etc and also has an image. > >If I set the form settings and then hit the 'submit' button, >it calls the UserPage's page_process and decodes the form >inputs and then calls it again for the img. > >The image doesnt get the form changes, but if I make the >UserPage set a state variable with the form info, then >the UserPage/image call has access to the info. > >So it all works fine!! :^) I had a similar problem with a frame based application. I did briefly try using the RandomPage mixin, but eventually went back to having one class for all frames (the frame URL simply includes a argument such as "?detail=1"). The result isn't all it could be. I'm trying to think of a better alternative. >Thanks and sorry for the bandwidth. No problems there. >(Now, I just need to change the Content-type type... :) We have a suped-up version of the popview demo application that understands MIME. It's capable of displaying images inline, and this requires setting headers. To do this, I added some methods to the Context object: class PopviewAppContext(AppContext, NameRecorderMixin, SessionFileContextMixin, logMixin.LogMixin): def __init__(self, app): AppContext.__init__(self, app) NameRecorderMixin.__init__(self) SessionFileContextMixin.__init__(self) self.set_mimetype() self.set_mimedisposition() def write_headers(self): SessionFileContextMixin.write_headers(self) self.request.write_header('Pragma', 'no-cache') self.request.write_header('Content-Type', self.mimetype) self.request.write_header('Content-Disposition', self.mimedisposition) def set_mimetype(self, type = 'text/html'): self.mimetype = type def set_mimedisposition(self, disposition = 'inline', filename = None): if filename: self.mimedisposition = '%s; filename="%s"' % \ (disposition, filename.replace('_', '-')) else: self.mimedisposition = disposition -- Andrew McNamara, Senior Developer, Object Craft http://www.object-craft.com.au/ From andrewm at object-craft.com.au Fri Nov 8 19:34:06 2002 From: andrewm at object-craft.com.au (Andrew McNamara) Date: Fri, 08 Nov 2002 19:34:06 +1100 Subject: [albatross-users] Newbie albatross question :) In-Reply-To: Message from "Cameron Blackwood" of "Fri, 08 Nov 2002 14:21:23 +1100." <200211080321.gA83LNT25760@firewall.darkqueen.org> References: <200211080321.gA83LNT25760@firewall.darkqueen.org> Message-ID: <20021108083406.781723C188@coffee.object-craft.com.au> >I guess, given that the objects are selected from the url, > > ctx.set_page('postlogin') > >shouldnt work from any of the Random*App classes. Or is it >just me? :) I think it's done with redirects, but I can't see the logic for the moment. Dave should be able to answer this one when he gets a sec. I was using the RandomPage mixin for an app, but I found that redirects didn't sit well with modern security conscious browsers when they occurred on form submission. -- Andrew McNamara, Senior Developer, Object Craft http://www.object-craft.com.au/ From korg at darkqueen.org Sat Nov 9 02:44:58 2002 From: korg at darkqueen.org (Cameron Blackwood) Date: Sat, 09 Nov 2002 02:44:58 +1100 Subject: [albatross-users] Newbie albatross question :) In-Reply-To: Your message of "Fri, 08 Nov 2002 19:34:06 +1100." <20021108083406.781723C188@coffee.object-craft.com.au> Message-ID: <200211081544.gA8Fiwi31518@firewall.darkqueen.org> Andrew McNamara writes In message <20021108083406.781723C188 at coffee.object-craf t.com.au>: | >I guess, given that the objects are selected from the url, | > | > ctx.set_page('postlogin') | > | >shouldnt work from any of the Random*App classes. Or is it | >just me? :) | | I think it's done with redirects, but I can't see the logic for the | moment. Dave should be able to answer this one when he gets a sec. | | I was using the RandomPage mixin for an app, but I found that redirects | didn't sit well with modern security conscious browsers when they occurred | on form submission. Im liking what I see of albatross :). It's like microzope, with persistance and dtlm type pages and easy cgi's. :) Yum. This was one of the things that moved me away from bobo/zpublisher. :-/ I think the form submission was lost when I redirected, so I had to write _bobo_traverse's which are less than exciting (and dont give you access to the Response, so you cant redirect anyway ;) Not that that would be a problem with albatross, Id just have to save the form into the stored state :) before I redirect. (zpublisher is only the object publishing bit of zope, not the object database/persistance part). I tried Random*App too, but have gone back to the simple. I considered the Page stuff, but *shrugs* Ill change it if it's a problem. :) One annoyance I found in changing, is that the keywords used by the __init__ of the App classes wont accept keywords from other App classes. Im using: from albatross import SimpleSessionFileApp as Albatross_Application Then I can just use Albatross_Application. Great. But.... I cant just change that to SimpleApp, because then the constructor complains about the args. Wouldnt it be nice if it just ignored extra args? Still I guess Id have to rewrite my code anyway, but still, it was a nice thought. Ok, it's a dumb idea. :) Actually, now is probably a good time for some feedback. Docs ==== >From reading the documentation, the difference between App, SessionApp, SessionFileApp and context and applications isnt all that clear. Add in Mixin's and other stuff and it's something that causes some confusion. (Atleast I found it to be so). Let me explain further on that. I know that App, SessionApp and SessionFileApp are just client, server daemon and server file storage classes. But the name App suggests _no_ session. Wouldnt it be better to call them SessionClientApp, SessionDaemonApp and SessionFileApp? And why does the App care how the Session is stored? Isnt that a context thing? And then there are Random, Module, Simple, which are ByURL, ByPythonModule, ByPythonObject, yeah? I guess I start to get confused when I get to RandomModularSessionFileApp Class. It's a little unclear for newbies. Maybe a few better examples, all the different ways of making a 'login', 'user info', 'account info', 'transfer duckets', 'logout' type application? I mean I know that I learn by looking at code, and some of the code examples are a little vague. Content-type: ============= I wanted to return images, so I did this: class MyContext(Albatross_Context,My_Ablatross_Class): def __init__(s,app): Albatross_Context.__init__(s,app) s.content_type='text/html' s.DEBUG('init Content-Type:%s'%(s.content_type)) def write_headers(s): SessionFileContextMixin.write_headers(s) s.request.write_header('Pragma', 'no-cache') s.DEBUG('write Content-Type:%s'%(s.content_type)) s.request.write_header('Content-Type', s.content_type) My reading of the code suggested that if I used Request.write_header("Content-Type","blah/blah") then it should have worked, but it didnt seem to reliably. I guess it doesnt in cgiapp.py at all. Given: self.request.write_header('Pragma', 'no-cache') self.request.write_header('Content-Type', 'text/html') seems to occur so often through out the code. See: SimpleAppContext.write_header SessionAppContext.write_header SessionFileAppContext.write_header Wouldnt it be better to make it a method of AppContext, so that it could be easily overwritten? I (from my 1 days looking) think that the context is rebuilt for each request, so if I change my content-type I guess it's a little counter intuitive that it changes back. Maybe you could have a function (in AppContext): def write_standard_headers(self): if self.nocache: self.request.write_header('Pragma', 'no-cache') if self.overwrite_type: self.request.write_header('Content-Type', self.overwrite_type) self.overwrite_type=None else: self.request.write_header('Content-Type', 'text/html') def only_this_request_and_no_more_change_content_type(self,newtype): self.overwrite_type=newtype :) and then just use self.write_standard_headers in SimpleAppContext, SessionAppContext & SessionFileAppContext. I should probably stop now. :-/ Cause Im not sure this is making sense :) cheers, cam | | -- | Andrew McNamara, Senior Developer, Object Craft | http://www.object-craft.com.au/ | -- / `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 ---------- One expresses well the love he does not feel. -- J.A. Karr From korg at darkqueen.org Sat Nov 9 02:50:04 2002 From: korg at darkqueen.org (Cameron Blackwood) Date: Sat, 09 Nov 2002 02:50:04 +1100 Subject: [albatross-users] Oh, and another tricky one.. :) In-Reply-To: Your message of "Fri, 08 Nov 2002 19:24:25 +1100." <20021108082425.E28673C188@coffee.object-craft.com.au> Message-ID: <200211081550.gA8Fo4d31603@firewall.darkqueen.org> Andrew McNamara writes In message <20021108082425.E28673C188 at coffee.object-craf t.com.au>: | self.request.write_header('Pragma', 'no-cache') | self.request.write_header('Content-Type', self.mimetype) | self.request.write_header('Content-Disposition', | self.mimedisposition) Ok, I just used: myctxhack.write_header('Content-Type', 'blah/blerg') ctx.write_content( open('image/file.blerg','r').read() ) Hacky, I know. I havnt ever played with Content-Disposition's before, but then I guess i dont need to mime encode images :) -- / `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 ---------- "Israel today announced that it is giving up. The Zionist state will dissolve in two weeks time, and its citizens will disperse to various resort communities around the world. Said Prime Minister Yitzhak Shamir, 'Who needs the aggravation?'" -- Dennis Miller, "Satuday Night Live" News From rbb at techgame.net Sat Nov 9 05:23:39 2002 From: rbb at techgame.net (Brian Brown) Date: Fri, 8 Nov 2002 11:23:39 -0700 Subject: [albatross-users] Transferring a site In-Reply-To: Message-ID: <343BD65F-F347-11D6-902E-003065F89450@techgame.net> On Wednesday, November 6, 2002, at 03:27 PM, Brian Brown wrote: > I've been developing a site on my MacOSX notebook with mod_python and > Albatross. Works great. I've just tried to get it going on an OpenBSD > box using mod_python/apache and Albatross, without much success. > > Mod_python is loading fine, Albatross installed without a hitch. I've > tried with both an .htaccess file as well as setting the config for my > directory in the httpd.conf - when I try to to run anything, Albatross > returns apache.OK and sends out the default "Oops!" page instead of any > content from the site. I have looked at everything 100 times and made > sure my PythonPath was set in the httpd.conf, but to no avail.... > anyone have any suggestions? I don't think this is an Albatross > problem, but I'm not sure. > > Albatross 1.01, python 2.2, mod_python 2.7.8, latest apache 1.3 series. First, thanks to Andrew and Greg for lot's of troubleshooting suggestions... I figured out what was going on. Albatross and mod_python were fine... the issue was with some of my page modules that were importing and using StructuredText. I hadn't moved that package to the server. Unfortunately, Albatross was not passing the error up to apache... it was just returning the default "Oops! URL home not found." error, and apache was logging a 200 instead of a 404. There really wasn't any way for me to figure out why it was failing. I was looking at all the code for the umpteenth time and saw the "import StructuredText" and bang! I tried putting that module on the server. Everything works fine now. Is there any way to get those types of error propogated? Of course now, I know what these mysterious symptoms mean! Thanks! Brian From brian at ablelinktech.com Sat Nov 9 05:18:19 2002 From: brian at ablelinktech.com (Brian Brown) Date: Fri, 8 Nov 2002 11:18:19 -0700 Subject: [albatross-users] Transferring a site In-Reply-To: Message-ID: <7528C3BE-F346-11D6-902E-003065F89450@ablelinktech.com> On Wednesday, November 6, 2002, at 03:27 PM, Brian Brown wrote: > I've been developing a site on my MacOSX notebook with mod_python and > Albatross. Works great. I've just tried to get it going on an OpenBSD > box using mod_python/apache and Albatross, without much success. > > Mod_python is loading fine, Albatross installed without a hitch. I've > tried with both an .htaccess file as well as setting the config for my > directory in the httpd.conf - when I try to to run anything, Albatross > returns apache.OK and sends out the default "Oops!" page instead of any > content from the site. I have looked at everything 100 times and made > sure my PythonPath was set in the httpd.conf, but to no avail.... > anyone have any suggestions? I don't think this is an Albatross > problem, but I'm not sure. > > Albatross 1.01, python 2.2, mod_python 2.7.8, latest apache 1.3 series. > First, thanks to Andrew and Greg for lot's of troubleshooting suggestions... I figured out what was going on. Albatross and mod_python were fine... the issue was with some of my page modules that were importing and using StructuredText. I hadn't moved that package to the server. Unfortunately, Albatross was not passing the error up to apache... it was just returning the default "Oops! URL home not found." error, and apache was logging a 200 instead of a 404. There really wasn't any way for me to figure out why it was failing. I was looking at all the code for the umpteenth time and saw the "import StructuredText" and bang! I tried putting that module on the server. Everything works fine now. Is there any way to get those types of error propogated? Of course now, I know what these mysterious symptoms mean! Thanks! Brian > Thanks! > > Brian > > _______________________________________________ > Albatross-users mailing list > Albatross-users at object-craft.com.au > https://www.object-craft.com.au/cgi-bin/mailman/listinfo/albatross-users From djc at object-craft.com.au Sun Nov 10 11:25:03 2002 From: djc at object-craft.com.au (Dave Cole) Date: 10 Nov 2002 11:25:03 +1100 Subject: [albatross-users] Newbie albatross question :) In-Reply-To: <20021108083406.781723C188@coffee.object-craft.com.au> References: <200211080321.gA83LNT25760@firewall.darkqueen.org> <20021108083406.781723C188@coffee.object-craft.com.au> Message-ID: >>>>> "Andrew" == Andrew McNamara writes: >> I guess, given that the objects are selected from the url, >> >> ctx.set_page('postlogin') >> >> shouldnt work from any of the Random*App classes. Or is it just >> me? :) Andrew> I think it's done with redirects, but I can't see the logic Andrew> for the moment. Dave should be able to answer this one when Andrew> he gets a sec. Yes, that is right. Andrew> I was using the RandomPage mixin for an app, but I found that Andrew> redirects didn't sit well with modern security conscious Andrew> browsers when they occurred on form submission. That is slightly annoying. I suppose you have to be aware of that limitation when you use redirects. - Dave -- http://www.object-craft.com.au From djc at object-craft.com.au Sun Nov 10 12:01:41 2002 From: djc at object-craft.com.au (Dave Cole) Date: 10 Nov 2002 12:01:41 +1100 Subject: [albatross-users] Newbie albatross question :) In-Reply-To: <200211081544.gA8Fiwi31518@firewall.darkqueen.org> References: <200211081544.gA8Fiwi31518@firewall.darkqueen.org> Message-ID: >>>>> "Cameron" == Cameron Blackwood writes: Cameron> Im liking what I see of albatross :). It's like microzope, Cameron> with persistance and dtlm type pages and easy cgi's. :) Yum. The "easy cgi's" is probably the most important thing about Albatross. Building small to medium web applications which capture and process complex user input is where Albatross is intended to shine. Cameron> This was one of the things that moved me away from Cameron> bobo/zpublisher. :-/ I think the form submission was lost Cameron> when I redirected, so I had to write _bobo_traverse's which Cameron> are less than exciting (and dont give you access to the Cameron> Response, so you cant redirect anyway ;) Cameron> Not that that would be a problem with albatross, Id just have Cameron> to save the form into the stored state :) before I redirect. Yes. The Python pickling makes sessions very powerful once your data becomes more complex. Cameron> I tried Random*App too, but have gone back to the simple. I Cameron> considered the Page stuff, but *shrugs* Ill change it if it's Cameron> a problem. :) Once you use server-side sessions you are able to mostly avoid using forms to propagate state. This means that the redirect becomes useable again. Cameron> One annoyance I found in changing, is that the keywords used Cameron> by the __init__ of the App classes wont accept keywords from Cameron> other App classes. Hmmm... I am not sure that there is much we can do about that without introducing very hard to find problems. Cameron> Docs ==== Cameron> From reading the documentation, the difference between Cameron> App, SessionApp, SessionFileApp and context and applications Cameron> isnt all that clear. Add in Mixin's and other stuff and it's Cameron> something that causes some confusion. (Atleast I found it to Cameron> be so). Choosing good names for these things is really difficult. I agree with you - our choice of names is not as good as it should be. Cameron> Let me explain further on that. I know that App, SessionApp Cameron> and SessionFileApp are just client, server daemon and server Cameron> file storage classes. But the name App suggests _no_ Cameron> session. Wouldnt it be better to call them SessionClientApp, Cameron> SessionDaemonApp and SessionFileApp? And why does the App Cameron> care how the Session is stored? Isnt that a context thing? An execution context is only intended to exist long enough to service one browser request. The application can live longer if you deploy in a non-cgi environment. When you use a session server it makes sense for the application to manage the connection so that in a non-cgi environment you open the connection once and service multiple browser requests with that connection. We plan to add a standalone server deployment option which would mean that the application would simply maintain sessions in a dictionary. Hopefully this explains why we chose to split the management of sessions between the application and execution context. Cameron> And then there are Random, Module, Simple, which are ByURL, Cameron> ByPythonModule, ByPythonObject, yeah? Much better naming!!! We could try to come up with a better naming scheme and keep the old confusing names as aliases for a couple of releases. Cameron> I guess I start to get confused when I get to Cameron> RandomModularSessionFileApp Class. It's a little unclear for Cameron> newbies. It is still confusing for me. I find naming one of the most difficult tasks in programming. Cameron> I mean I know that I learn by looking at code, and some of Cameron> the code examples are a little vague. [snip discussion of headers] This is one area where some reorganisation would probably be very helpful. At the moment you are expected to subclass the execution context and override the write_headers() method. Maybe the write_headers() method should write out a list/dictionary of headers for which a default was established in the constructor. During request processing all you would then need to do is alter the headers. Something like: ctx.set_header('Content-Type', 'image/png') - Dave -- http://www.object-craft.com.au From djc at object-craft.com.au Sun Nov 10 12:20:00 2002 From: djc at object-craft.com.au (Dave Cole) Date: 10 Nov 2002 12:20:00 +1100 Subject: [albatross-users] Transferring a site In-Reply-To: <7528C3BE-F346-11D6-902E-003065F89450@ablelinktech.com> References: <7528C3BE-F346-11D6-902E-003065F89450@ablelinktech.com> Message-ID: >>>>> "Brian" == Brian Brown writes: Brian> First, thanks to Andrew and Greg for lot's of troubleshooting Brian> suggestions... I figured out what was going on. Albatross and Brian> mod_python were fine... the issue was with some of my page Brian> modules that were importing and using StructuredText. I hadn't Brian> moved that package to the server. Unfortunately, Albatross was Brian> not passing the error up to apache... it was just returning the Brian> default "Oops! URL home not found." error, and apache was Brian> logging a 200 instead of a 404. In the RandomPageModuleMixin the code traps an ImportError when it tries to load the page module. It assumes that the request page module was the module which could not be loaded. This is a bad assumption it seems :-) Looks like the only was around this is to modify the code try: self.load_page_module(ctx, page) except ImportError: to this try: self.load_page_module(ctx, page) except ImportError, e: if not str(e).endswith(page): raise This unfortunately relies on the formatting of the ImportError exception. Brian> There really wasn't any way for me to figure out why it was Brian> failing. I was looking at all the code for the umpteenth time Brian> and saw the "import StructuredText" and bang! I tried putting Brian> that module on the server. Everything works fine now. Brian> Is there any way to get those types of error propogated? Of Brian> course now, I know what these mysterious symptoms mean! I am going to add code like the above into Albatross. - Dave -- http://www.object-craft.com.au From tree at basistech.com Sun Nov 10 13:25:13 2002 From: tree at basistech.com (Tom Emerson) Date: Sat, 9 Nov 2002 21:25:13 -0500 Subject: [albatross-users] Newbie albatross question :) In-Reply-To: References: <200211080321.gA83LNT25760@firewall.darkqueen.org> <20021108083406.781723C188@coffee.object-craft.com.au> Message-ID: <15821.50057.747366.361577@magrathea.basistech.com> Could someone give some guidance on the use of redirects versus set_page? Is the point that each major function carried out by an application is handled by its own application object? Or, I guess the question that I'm asking, is what is a good way to structure a large application that isn't as stateful as the pop sample but still requires state (such as login information). -- Tom Emerson Basis Technology Corp. Software Architect http://www.basistech.com "Beware the lollipop of mediocrity: lick it once and you suck forever" From tchur at optushome.com.au Sun Nov 10 14:38:18 2002 From: tchur at optushome.com.au (Tim Churches) Date: Sun, 10 Nov 2002 14:38:18 +1100 Subject: [albatross-users] Newbie albatross question :) Message-ID: <200211100338.gAA3cIj23341@mail018.syd.optusnet.com.au> An embedded and charset-unspecified text was scrubbed... Name: not available URL: From korg at darkqueen.org Sun Nov 10 15:07:45 2002 From: korg at darkqueen.org (Cameron Blackwood) Date: Sun, 10 Nov 2002 15:07:45 +1100 Subject: [albatross-users] Newbie albatross question :) In-Reply-To: Your message of "10 Nov 2002 12:01:41 +1100." Message-ID: <200211100407.gAA47jh21625@firewall.darkqueen.org> More questions below... :) Dave Cole writes In message : | | The "easy cgi's" is probably the most important thing about Albatross. | Building small to medium web applications which capture and process | complex user input is where Albatross is intended to shine. *nod* Yep. Ive had to fight some things, but now I think I have a handle on it. One thing that I did spend __AGES__ on was trying to track down : [Sun Nov 10 03:27:19 2002] [error] [client 10.0.0.1] Premature end of script headers: /home/httpd/cgi-bin/20c It turns out that Id accidently deleted my: def page_display(s,ctx): ctx.run_template('login.html') So albatross was processing my object and then displaying nothing. Man, that sucked!! It took me about an hour to find. (I deleted it as I cut and pasted some of my methods into a parent class, so I thought it was that.) Maybe albatross should return 'no output generated by object NAME' or something from the flush()? I cant see any reason why you'd want to not return _anything_. Maybe an overwritable 'default/no output' return would be a good thing? | | Cameron> I tried Random*App too, but have gone back to the simple. I | Cameron> considered the Page stuff, but *shrugs* Ill change it if it's | Cameron> a problem. :) | | Once you use server-side sessions you are able to mostly avoid using | forms to propagate state. This means that the redirect becomes | useable again. Actually I do have a question... step1 ===== Im using: from albatross import SessionFileAppContext as Albatross_Context from albatross import SimpleSessionFileApp as Albatross_Application from albatross import SessionFileContextMixin # <---to hack the content type from albatross.cgiapp import Request and Im finding that if i have an error in my code that makes a traceback dump, then my state is lost. (IE, if i fix the code and then hit reload (which then gives the warning about 'post'ing the data again), I am back to my login screen (which is my startup page)). Is this because my context is being saved as 'empty' because * the context is created at the start of the request * my code is processed and bombs out * the empty context is saved? or something silly like that? (Or would this problem go away if I use Client based state? I just changed it to SimpleAppContext and now if I get an error, I can reload the page and my state remains. Hmmm.) step2 ===== Ok, Im dumb. :) It turns out that it was caused by my not setting ctx.add_session_vars in each 'create_context'. step3 ===== Errr, ok maybe it wasnt that either. Um. Ok. Confused now. Somehow my context is being lost if I get a traceback (I put a button which causes a divide by zero error in my code. If I hit reload, then my login screen appears. If I use SimpleAppContext rather than SessionFileAppContext then my problem goes away (becuase the state is stored in the form, so when I 'repost' it reloads the state, I guess) Questions ========= So, I guess Im asking what happens in the SessionFileAppContext state then and how do I get around this? And just to check, but I dont need to add create_context() each create_context() do I? Once it's in the state it's there for good? | | Cameron> One annoyance I found in changing, is that the keywords used | Cameron> by the __init__ of the App classes wont accept keywords from | Cameron> other App classes. | | Hmmm... I am not sure that there is much we can do about that without | introducing very hard to find problems. Well the documentation uses the form: ModularSessionApp.__init__(self, base_url = 'popview.py', module_path = '.', template_path = '.', start_page = 'login', secret = '-=-secret-=-', session_appid = 'popview4') Ok, this us ugly, so stick with me here.... def __init__(self,*static_args,**keywords): static_arg_names=[ 'base_url', 'module_path', 'template_path', 'start_page', 'secret', 'session_appid' ] if len(static_args)>len(static_arg_names): print 'too many args... ' sys.curl_up_and_die(-1) for i in range(len(static_args)): keywords[ static_arg_names[i] ]=static_args[i] for i in range(len(static_arg_names)): if not keywords.has_key: print 'You didnt supply the arg',static_arg_names sys.curl_up_and_die(-1) base_url=keywords['base_url'] secret=keywords['secret'] template_path=keywords['template_path'] # etc # and then the standard __init__ code So if people used: __init__(self,'popview.py','.','.','login','-=-secret-=-','popview4') or __init__(self, base_url = 'popview.py', module_path = '.', template_path = '.', start_page = 'login', secret = '-=-secret-=-', session_appid = 'popview4') it should work fine in both cases. _But_, if the same stuff is done to all the __init__ functions, then I could change the class from SimpleSessionFileApp to SimpleApp and the extra args would just be ignored (if i used the 2nd format!) This would be a 'good thing' as it would mean you could change storage systems easily. It should be transparent, yeah? | Maybe the write_headers() method should write out a list/dictionary of | headers for which a default was established in the constructor. | During request processing all you would then need to do is alter the | headers. | | Something like: | | ctx.set_header('Content-Type', 'image/png') Yep. Im in heaven :) Perfect :) | | - Dave 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 ---------- God decided to take the devil to court and settle their differences once and for all. When Satan heard of this, he grinned and said, "And just where do you think you're going to find a lawyer?" From djc at object-craft.com.au Mon Nov 11 10:57:31 2002 From: djc at object-craft.com.au (Dave Cole) Date: 11 Nov 2002 10:57:31 +1100 Subject: [albatross-users] Newbie albatross question :) In-Reply-To: <15821.50057.747366.361577@magrathea.basistech.com> References: <200211080321.gA83LNT25760@firewall.darkqueen.org> <20021108083406.781723C188@coffee.object-craft.com.au> <15821.50057.747366.361577@magrathea.basistech.com> Message-ID: >>>>> "Tom" == Tom Emerson writes: Tom> Could someone give some guidance on the use of redirects versus Tom> set_page? Is the point that each major function carried out by an Tom> application is handled by its own application object? Tom> Or, I guess the question that I'm asking, is what is a good way Tom> to structure a large application that isn't as stateful as the Tom> pop sample but still requires state (such as login information). set_page() is used in applications where the entire application hides behind a single URL. The application then keeps the name of the current page in the session. redirect() is used in applications where the current page is determined by the URL requested by the browser. If you want users to be able to bookmark pages in the application you are going to have to use an application which inherits from RandomPageModuleMixin. In order to ensure that a user has logged in you would have to do something like this: - - - pagemodule.py - - - - - - - - - - - - - - - - - - - - - - # Have login logic in separate module import security def page_process(ctx): if security.page_process(ctx): # process normal requests def page_display(ctx): if security.page_display(ctx): # display normal page - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - security.py - - - - - - - - - - - - - - - - - - - - - - - def process_login_request(ctx): # Check ctx.locals.username, ctx.locals.passwd, return TRUE if OK def page_process(ctx): if ctx.req_equals('login'): ctx.locals._is_logged_on = process_login_request(ctx) return ctx.locals._is_logged_on def page_display(ctx): if ctx.locals._is_logged_on: return 1 ctx.run_template('login.html') return 0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Dave -- http://www.object-craft.com.au From gnb at itga.com.au Mon Nov 11 11:11:53 2002 From: gnb at itga.com.au (Gregory Bond) Date: Mon, 11 Nov 2002 11:11:53 +1100 Subject: [albatross-users] Our first custom tag Message-ID: <200211110011.LAA23340@lightning.itga.com.au> We have an informal in-house style that says alternating rows of table data should have different background colors, so that it is easy to keep track of which row is which. This is done by alternating the "class" attribute of each "" tag. (Most of our existing intranet is built with HTMLgen, which is kind-of "inside-out" compared to Albatross, in that it is a program to generate HTML, rather than an HTML file containing program-like elements. Things like alternating class attributes is easy to do in this style of system.) In trying to use Albatross, I wound up doing lots of code like Not only is this ugly to look at and a lot to type, it really messes with the head of the HTML editor (I use xemacs) and buggers the indentation. So we wrote an extension tag to hide all this nastyness. I include it here in case anyone else finds it interesting. [To the Albatross team: Feel free to make this part of the official distribution. This might also make a good case study in custom tags for the manual!] #! /usr/local/bin/python ''' A collection of useful custom tag classes for use with the albatross library. To make these available, simply pass the class object to the register_tagclasses() member of the application object. E.g.: import itgatags .... class MyApp(SimpleApp): def __init__(self): SimpleApp.__init__(self,......) for page_class in (.......): self .register_page(page_class.name, page_class()) for tag_class in (itgatags.TR,): self .register_tagclasses(tag_class) ''' from albatross.tags import ExprAttrMixin from albatross import EnclosingTag class TR(EnclosingTag, ExprAttrMixin): ''' ... Similar to , except that it evaluates expr (which must be an integer) and then chooses a "class=" attribute for the tag from those listed in the "classes" arg by taking " % <# of classes>". is often "i.index()" where i is an iterator created by . This is useful for having rows of the table with alternating or successive styles. Elements of the "classes" list may be empty (i.e. "alt1,") or the empty string ("alt1,'',alt2") which will produce a without a "class=" attribute. "classes" may be omitted and defaults to ",alt" (i.e. alternating normal and "class=alt" styles. Naturally, you will need some sort of stylesheet definitions for these classes. Example:
.......
This will produce a table where the odd rows are normal, but the 2nd and 4th rows have special class (and hence presumably special formatting). ... Similar to the above, but instead of evaluating an expression, this uses a counter with the given name in the ctx.locals space (creating it with the value 0 if necessary). The counter will be incremented after it is used. This is useful if a single table contains rows from multiple tags, or summary lines at the bottom, or similar. It can also count the number of rows for you! Example:
....... TOTAL:........
Rows Added. Using a counter rather than the iterator.index() method ensures that the TOTAL row has the appropriate and consistant class attribute. ''' name = 'alx-tr' def __init__(self, ctx, filename, line_num, attribs): EnclosingTag.__init__(self, ctx, filename, line_num, attribs) if self.has_attrib('expr'): self.compile_expr() self.counter = '' elif self.has_attrib('counter'): self.counter = self.get_attrib('counter') else: self.raise_error('missing "counter" or "expr" attribute') if self.has_attrib('classes'): cs = self.get_attrib('classes') self.classes = [] for c in cs.split(','): if c == "''" or c == '""': c = '' self.classes.append(c) else: self.classes = ['', 'alt'] def to_html(self, ctx): if self.counter: if ctx.has_value(self.counter): val = ctx.get_value(self.counter) else: val = 0 else: # expr val = int(ctx.eval_expr(self.expr)) cls = self.classes[val % len(self.classes)] if cls: ctx.write_content('' % cls) else: ctx.write_content('') self.content.to_html(ctx) ctx.write_content('\n') if self.counter: ctx.set_value(self.counter, val + 1) From djc at object-craft.com.au Mon Nov 11 11:17:46 2002 From: djc at object-craft.com.au (Dave Cole) Date: 11 Nov 2002 11:17:46 +1100 Subject: [albatross-users] Newbie albatross question :) In-Reply-To: <200211100407.gAA47jh21625@firewall.darkqueen.org> References: <200211100407.gAA47jh21625@firewall.darkqueen.org> Message-ID: > One thing that I did spend __AGES__ on was trying to track > down : > > [Sun Nov 10 03:27:19 2002] [error] [client 10.0.0.1] Premature end of script headers: /home/httpd/cgi-bin/20c > > It turns out that Id accidently deleted my: > > def page_display(s,ctx): > ctx.run_template('login.html') > > So albatross was processing my object and then displaying nothing. > Man, that sucked!! It took me about an hour to find. (I deleted it > as I cut and pasted some of my methods into a parent class, so I > thought it was that.) > > Maybe albatross should return 'no output generated by object NAME' > or something from the flush()? > > I cant see any reason why you'd want to not return _anything_. > Maybe an overwritable 'default/no output' return would be a good > thing? The is a bit of an oversight in Albatross. It should be raising an exception if you do not define page_display() > step1 > ===== > Im using: > > from albatross import SessionFileAppContext as Albatross_Context > from albatross import SimpleSessionFileApp as Albatross_Application > from albatross import SessionFileContextMixin # <---to hack the content type > from albatross.cgiapp import Request > > and Im finding that if i have an error in my code that makes a > traceback dump, then my state is lost. (IE, if i fix the code and > then hit reload (which then gives the warning about 'post'ing the > data again), I am back to my login screen (which is my startup > page)). > > Is this because my context is being saved as 'empty' because > * the context is created at the start of the request > * my code is processed and bombs out > * the empty context is saved? > or something silly like that? This is intentional. If you look at the Application.run() method you will see that it removes the session when it catches an exception. It is a minor annoyance when you are developing, but it prevents you getting stuck in an exception dead end. Consider the situation where an exception is being raised due to some bad data in the session. This could cause the application to raise an exception for every browser request. That would be bad. > step2 > ===== > Ok, Im dumb. :) > > It turns out that it was caused by my not setting > ctx.add_session_vars in each 'create_context'. Easy enough mistake to make. > step3 > ===== > Errr, ok maybe it wasnt that either. > > Um. Ok. Confused now. > > Somehow my context is being lost if I get a traceback (I put a > button which causes a divide by zero error in my code. If I hit > reload, then my login screen appears. Yup. See above. > If I use SimpleAppContext rather than SessionFileAppContext then my > problem goes away (becuase the state is stored in the form, so when > I 'repost' it reloads the state, I guess) Yes. The application cannot remove the session currently held at the browser. > Questions > ========= > So, I guess Im asking what happens in the SessionFileAppContext > state then and how do I get around this? At the moment the only way to get around it would be to replace the run() Application method with your own which did not remove the session when an exception is trapped. > And just to check, but I dont need to add create_context() each > create_context() do I? Once it's in the state it's there for good? Not sure I follow you here. > Well the documentation uses the form: > ModularSessionApp.__init__(self, > base_url = 'popview.py', > module_path = '.', > template_path = '.', > start_page = 'login', > secret = '-=-secret-=-', > session_appid = 'popview4') [snip] > _But_, if the same stuff is done to all the __init__ functions, then > I could change the class from SimpleSessionFileApp to SimpleApp and > the extra args would just be ignored (if i used the 2nd format!) > > This would be a 'good thing' as it would mean you could change > storage systems easily. It should be transparent, yeah? I can see the merit in doing that. The only downside is you lose the ability to detect misspelling of keyword arguments for which there are defaults. Maybe this is a small price to pay. - Dave -- http://www.object-craft.com.au From andrewm at object-craft.com.au Mon Nov 11 11:20:29 2002 From: andrewm at object-craft.com.au (Andrew McNamara) Date: Mon, 11 Nov 2002 11:20:29 +1100 Subject: [albatross-users] Newbie albatross question :) In-Reply-To: Message from Dave Cole of "11 Nov 2002 10:57:31 +1100." References: <200211080321.gA83LNT25760@firewall.darkqueen.org> <20021108083406.781723C188@coffee.object-craft.com.au> <15821.50057.747366.361577@magrathea.basistech.com> Message-ID: <20021111002029.F007C3C188@coffee.object-craft.com.au> >If you want users to be able to bookmark pages in the application you >are going to have to use an application which inherits from >RandomPageModuleMixin. I think most browsers will also save as bookmarks URL's that include arguments: http://localhost/cgi-bin/popview/popview.py?list=1 This may be an alternative where the Random mixins are more than you want. -- Andrew McNamara, Senior Developer, Object Craft http://www.object-craft.com.au/ From neel at mediapulse.com Tue Nov 12 05:02:13 2002 From: neel at mediapulse.com (Michael C. Neel) Date: Mon, 11 Nov 2002 13:02:13 -0500 Subject: [albatross-users] Our first custom tag Message-ID: Have you considered using a lookup? You could have a lookup: class="alt1" class="alt2" class="alt3" ...placed in a global template, then use: > ..in the page. Mike > -----Original Message----- > From: Gregory Bond [mailto:gnb at itga.com.au] > Sent: Sunday, November 10, 2002 7:12 PM > To: albatross-users at object-craft.com.au > Subject: [albatross-users] Our first custom tag > > > We have an informal in-house style that says alternating rows > of table data > should have different background colors, so that it is easy > to keep track of > which row is which. This is done by alternating the "class" > attribute of each > "" tag. (Most of our existing intranet is built with > HTMLgen, which is > kind-of "inside-out" compared to Albatross, in that it is a > program to > generate HTML, rather than an HTML file containing > program-like elements. > Things like alternating class attributes is easy to do in > this style of > system.) > > In trying to use Albatross, I wound up doing lots of code like > > > > > > > Not only is this ugly to look at and a lot to type, it really > messes with the > head of the HTML editor (I use xemacs) and buggers the indentation. > > So we wrote an extension tag to hide all this > nastyness. I include > it here in case anyone else finds it interesting. > > [To the Albatross team: Feel free to make this part of the official > distribution. This might also make a good case study in > custom tags for the > manual!] > > > > #! /usr/local/bin/python > ''' > A collection of useful custom tag classes for use with the > albatross library. > > To make these available, simply pass the class object to the > register_tagclasses() member of the application object. > > E.g.: > > import itgatags > > .... > class MyApp(SimpleApp): > def __init__(self): > SimpleApp.__init__(self,......) > for page_class in (.......): > self .register_page(page_class.name, page_class()) > for tag_class in (itgatags.TR,): > self .register_tagclasses(tag_class) > > > > ''' > > from albatross.tags import ExprAttrMixin > from albatross import EnclosingTag > > class TR(EnclosingTag, ExprAttrMixin): > ''' > ... > > Similar to , except that it evaluates expr (which must be an > integer) and then chooses a "class=" attribute for the tag > from those listed in the "classes" arg by taking " % <# of > classes>". is often "i.index()" where i is an iterator > created by . > > This is useful for having rows of the table with alternating or > successive styles. Elements of the "classes" list may be empty > (i.e. "alt1,") or the empty string ("alt1,'',alt2") which will > produce a without a "class=" attribute. > > "classes" may be omitted and defaults to ",alt" (i.e. alternating > normal and "class=alt" styles. Naturally, you will need some sort > of stylesheet definitions for these classes. > > Example: > > > > > > >
.......
> This will produce a table where the odd rows are normal, but the > 2nd and 4th rows have special class (and hence presumably special > formatting). > > ... > > Similar to the above, but instead of evaluating an expression, > this uses a counter with the given name in the ctx.locals space > (creating it with the value 0 if necessary). The counter will be > incremented after it is used. This is useful if a single table > contains rows from multiple tags, or summary lines at the > bottom, or similar. It can also count the number of rows for you! > > Example: > > > > > > > >
.......TOTAL:........ > >
> Rows Added. > > Using a counter rather than the iterator.index() method ensures > that the TOTAL row has the appropriate and consistant class > attribute. > > ''' > name = 'alx-tr' > > def __init__(self, ctx, filename, line_num, attribs): > EnclosingTag.__init__(self, ctx, filename, line_num, attribs) > if self.has_attrib('expr'): > self.compile_expr() > self.counter = '' > elif self.has_attrib('counter'): > self.counter = self.get_attrib('counter') > else: > self.raise_error('missing "counter" or "expr" attribute') > if self.has_attrib('classes'): > cs = self.get_attrib('classes') > self.classes = [] > for c in cs.split(','): > if c == "''" or c == '""': > c = '' > self.classes.append(c) > else: > self.classes = ['', 'alt'] > > def to_html(self, ctx): > if self.counter: > if ctx.has_value(self.counter): > val = ctx.get_value(self.counter) > else: > val = 0 > else: # expr > val = int(ctx.eval_expr(self.expr)) > > cls = self.classes[val % len(self.classes)] > if cls: > ctx.write_content('' % cls) > else: > ctx.write_content('') > > self.content.to_html(ctx) > ctx.write_content('\n') > > if self.counter: > ctx.set_value(self.counter, val + 1) > > > > > _______________________________________________ > Albatross-users mailing list > Albatross-users at object-craft.com.au > https://www.object-craft.com.au/cgi-bin/mailman/listinfo/albat ross-users From gnb at itga.com.au Tue Nov 12 10:12:14 2002 From: gnb at itga.com.au (Gregory Bond) Date: Tue, 12 Nov 2002 10:12:14 +1100 Subject: [albatross-users] Accessing the list of names in the context? Message-ID: <200211112312.KAA19682@lightning.itga.com.au> I'm trying to work out a way of debugging what's in the context at various points. I tried this: The current local context is:
  • =
but this doesn't work: [snip....] File "templates/cncancel/header.html", line 45, in al-for Traceback (most recent call last): [snip...] File "/usr/local/lib/python2.1/site-packages/albatross/context.py", line 320, in eval_expr return eval(expr, self.__globals, self.locals.__dict__) File "", line 0, in ? NameError: name '__dict__' is not defined which makes sense, given the code in the traceback! I can obviously get around this by adding a line like "ctx.locals.dict = cts.locals.__dict__" everythwere, byt that means debugging involves changes to both the template and the .py file. Any way of doing this that doesn't involve editing the .py file? Is it worth having the context do this assignment anyway? From gnb at itga.com.au Tue Nov 12 10:18:20 2002 From: gnb at itga.com.au (Gregory Bond) Date: Tue, 12 Nov 2002 10:18:20 +1100 Subject: [albatross-users] Our first custom tag In-Reply-To: Your message of Mon, 11 Nov 2002 13:02:13 -0500. Message-ID: <200211112318.KAA20789@lightning.itga.com.au> >> > Hmm, hadn't used al-lookup before, so I never thought of it. And I wasn't entirely sure if tags worked inside HTML tags, although on reflection it seems reasonable. Perhaps add a comment about this in the manual? From tree at basistech.com Tue Nov 12 10:17:48 2002 From: tree at basistech.com (Tom Emerson) Date: Mon, 11 Nov 2002 18:17:48 -0500 Subject: [albatross-users] Accessing the list of names in the context? In-Reply-To: <200211112312.KAA19682@lightning.itga.com.au> References: <200211112312.KAA19682@lightning.itga.com.au> Message-ID: <15824.15004.450173.677232@magrathea.basistech.com> Gregory Bond writes: > I'm trying to work out a way of debugging what's in the context at various > points. I tried this: > > The current local context is: >
    > [...] Instead of doing this, try using to see the local variables in the context being executed. This has worked for me in the past. -tree -- Tom Emerson Basis Technology Corp. Software Architect http://www.basistech.com "Beware the lollipop of mediocrity: lick it once and you suck forever" From tree at basistech.com Tue Nov 12 10:20:52 2002 From: tree at basistech.com (Tom Emerson) Date: Mon, 11 Nov 2002 18:20:52 -0500 Subject: [albatross-users] Our first custom tag In-Reply-To: <200211112318.KAA20789@lightning.itga.com.au> References: <200211112318.KAA20789@lightning.itga.com.au> Message-ID: <15824.15188.437427.747804@magrathea.basistech.com> Gregory Bond writes: > >> > > > Hmm, hadn't used al-lookup before, so I never thought of it. I may be wrong, but shouldn't that be > And I wasn't entirely sure if tags worked inside HTML tags, although > on reflection it seems reasonable. It gets gnarly when you are trying to generate XHTML, but yes, it works. Remember that Albatross is using a hairy regex to do its tag parsing. -- Tom Emerson Basis Technology Corp. Software Architect http://www.basistech.com "Beware the lollipop of mediocrity: lick it once and you suck forever" From gnb at itga.com.au Tue Nov 12 10:22:58 2002 From: gnb at itga.com.au (Gregory Bond) Date: Tue, 12 Nov 2002 10:22:58 +1100 Subject: [albatross-users] Accessing the list of names in the context? In-Reply-To: Your message of Mon, 11 Nov 2002 18:17:48 -0500. Message-ID: <200211112322.KAA21798@lightning.itga.com.au> > Instead of doing this, try using > Ripper. Thanks! This albatross thing is sooooo cool. Pity about the seabird bloody flavour tho. From gnb at itga.com.au Tue Nov 12 15:17:52 2002 From: gnb at itga.com.au (Gregory Bond) Date: Tue, 12 Nov 2002 15:17:52 +1100 Subject: [albatross-users] A minor nit on redirects... Message-ID: <200211120417.PAA24489@lightning.itga.com.au> We have a "start over" link on the bottom of each page, which is supposed to drop the whole session and start again. I implemented this as a link with href="prog.py?top=1", but selecting this left the "?top=1" in the address bar of the browser, even after moving several pages past the top. So I thought, "Aha! Use redirects!" class Top: name = 'top' def page_enter(self, ctx): if ctx.req_equals('top'): ctx.remove_session() ctx.redirect('') # Start from the bare base URL This _almost_ works. It now leaves the url reading "/prog.py/" (i.e. with a bogus trailing slash). Various other things I tried left stuff like "/prog.py/prog.py/prog.py/"! I know it's minor, but.... BTW: A hint - decide before you start coding whether you are going to use server sessions or client sessions - the nav logic changes substantially between the two! Server sessions are much more flexible (e.g. you can also navigate with HREFs, not just FORMs) but you need to be much more picky about refresh/reload, and users abandoning sessions half way through and going back to the top url, and such like. Is there some way of saying "if there is no form data or URL args, then just ditch the session and start over"? I've had to do something like this: def page_process(self, ctx): if ctx.req_equals('top') or len(ctx.request.field_names()) == 0: ctx.set_page('top') in the page_process of every page class. The first clause is for the "start again" link, the second is for the case where the user abandons a session and navigates (or bookmarks) back to the top. Greg. From gnb at itga.com.au Thu Nov 14 17:16:27 2002 From: gnb at itga.com.au (Gregory Bond) Date: Thu, 14 Nov 2002 17:16:27 +1100 Subject: [albatross-users] A problem with cookies and multiple apps in the same directory Message-ID: <200211140616.RAA08948@lightning.itga.com.au> We have 2 .py files in the same (subdir of the) cgi-bin directory, implementing 2 apps using SessionFile mixins. They have separate secrets and appid's in the Application objects. But we can't use both apps. If we go to one, then it sets a cookie with the name of that appid, and a path of "/cgi-bin/dir". When we then navigate to the second app, it doesn't attempt to set a new cookie, but tries to use the cookie set by the previous app, and dies with an exception: Template traceback (most recent call last): Traceback (most recent call last): File "/usr/local/lib/python2.1/site-packages/albatross/app.py", line 142, in run self.load_session(ctx) File "/usr/local/lib/python2.1/site-packages/albatross/app.py", line 204, in load_session ctx.load_session() File "/usr/local/lib/python2.1/site-packages/albatross/sessionfile.py", line 46, in load_session sesid = self._get_sesid_from_cookie() File "/usr/local/lib/python2.1/site-packages/albatross/sessionfile.py", line 37, in _get_sesid_from_cookie return os.path.basename(c[self.app.ses_appid()].value) File "/usr/local/lib/python2.1/UserDict.py", line 14, in __getitem__ def __getitem__(self, key): return self.data[key] KeyError: unusualwto (unusualwto is the appid of the second app in this case). This doesn't seem to matter which app we chose first, the first one works, the second one dies. Are we doing something wierd here? From dkuhlman at cutter.rexx.com Fri Nov 15 05:05:36 2002 From: dkuhlman at cutter.rexx.com (Dave Kuhlman) Date: Thu, 14 Nov 2002 10:05:36 -0800 Subject: Albatross the name Was: [albatross-users] Accessing the list of names in the context? In-Reply-To: <200211112322.KAA21798@lightning.itga.com.au>; from gnb@itga.com.au on Tue, Nov 12, 2002 at 10:22:58AM +1100 References: <200211112322.KAA21798@lightning.itga.com.au> Message-ID: <20021114100535.A24749@cutter.rexx.com> On Tue, Nov 12, 2002 at 10:22:58AM +1100, Gregory Bond wrote: > > Instead of doing this, try using > > > > Ripper. Thanks! > > This albatross thing is sooooo cool. Pity about the seabird bloody flavour > tho. I agree about the software but disagree about the bird. The albatross is a magnificent creature. Nothing flies farther and stays up longer than an Albatross. It's a very appropriate name. Also, an albatross stays aloft with very little effort and almost no wing flapping. Efficiency and effortlessness are also apt connotations for Albatross the Web app server. Also, some species, at least, mate for life or long periods. Stick with Albatross. It won't let you down. By the way, in case you are worrying about the "albatross around the neck" thing, I looked up the "The Rime of the Ancient Mariner". (http://etext.lib.virginia.edu/stc/Coleridge/poems/Rime_Ancient_Mariner.html) The reason that the albatross was chosen as a symbol in that poem is because, for a sailor, sighting an albatross was/is a *good* omen. Needless to say, there are (some of us) bird watchers who would be thrilled at the sight of an albatross. - Dave -- Dave Kuhlman dkuhlman at rexx.com http://www.rexx.com/~dkuhlman From neel at mediapulse.com Fri Nov 15 05:33:30 2002 From: neel at mediapulse.com (Michael C. Neel) Date: Thu, 14 Nov 2002 13:33:30 -0500 Subject: Albatross the name Was: [albatross-users] Accessing the list of names in the context? Message-ID: I think he was refering to the Monty Python skit, you know Albatross being a Monty Python skit and written in python and all that... http://www.graphicszone.net/monty_python/scripts/Series_1/88.htm Mike > -----Original Message----- > From: Dave Kuhlman [mailto:dkuhlman at cutter.rexx.com] > Sent: Thursday, November 14, 2002 1:06 PM > To: albatross-users at object-craft.com.au > Subject: Albatross the name Was: [albatross-users] Accessing > the list of names in the context? > > > On Tue, Nov 12, 2002 at 10:22:58AM +1100, Gregory Bond wrote: > > > Instead of doing this, try using > > > > > > > Ripper. Thanks! > > > > This albatross thing is sooooo cool. Pity about the > seabird bloody flavour > > tho. > > I agree about the software but disagree about the bird. > > The albatross is a magnificent creature. Nothing flies farther and > stays up longer than an Albatross. It's a very appropriate name. > > Also, an albatross stays aloft with very little effort and almost > no wing flapping. Efficiency and effortlessness are also apt > connotations for Albatross the Web app server. > > Also, some species, at least, mate for life or long periods. Stick > with Albatross. It won't let you down. > > By the way, in case you are worrying about the "albatross around > the neck" thing, I looked up the "The Rime of the Ancient Mariner". > (http://etext.lib.virginia.edu/stc/Coleridge/poems/Rime_Ancien t_Mariner.html) The reason that the albatross was chosen as a symbol in that poem is because, for a sailor, sighting an albatross was/is a *good* omen. Needless to say, there are (some of us) bird watchers who would be thrilled at the sight of an albatross. - Dave -- Dave Kuhlman dkuhlman at rexx.com http://www.rexx.com/~dkuhlman _______________________________________________ Albatross-users mailing list Albatross-users at object-craft.com.au https://www.object-craft.com.au/cgi-bin/mailman/listinfo/albatross-users From tree at basistech.com Fri Nov 15 06:18:09 2002 From: tree at basistech.com (Tom Emerson) Date: Thu, 14 Nov 2002 14:18:09 -0500 Subject: Albatross the name Was: [albatross-users] Accessing the list of names in the context? In-Reply-To: <20021114100535.A24749@cutter.rexx.com> References: <200211112322.KAA21798@lightning.itga.com.au> <20021114100535.A24749@cutter.rexx.com> Message-ID: <15827.63217.453559.938278@magrathea.basistech.com> Dave Kuhlman writes: [...] > The reason that the albatross was chosen as a symbol in that poem > is because, for a sailor, sighting an albatross was/is a *good* > omen. Yes, and the Ancient Mariner killed the Albatross, which was considered to be very *bad* luck, which is why his colleagues hung the dead bird around his neck: I expect that gets rather unpleasant in a day or two. And I believe the original post referred to the Monty Python sketch with John Cleese in drag at the cinema trying to sell people an Albatross for a snack. -tree -- Tom Emerson Basis Technology Corp. Software Architect http://www.basistech.com "Beware the lollipop of mediocrity: lick it once and you suck forever" From tchur at optushome.com.au Fri Nov 15 05:05:11 2002 From: tchur at optushome.com.au (Tim Churches) Date: Fri, 15 Nov 2002 05:05:11 +1100 Subject: Albatross the name Was: [albatross-users] Accessing the list of names in the context? References: <200211112322.KAA21798@lightning.itga.com.au> <20021114100535.A24749@cutter.rexx.com> Message-ID: <3DD3E5D7.AE3DBDB4@optushome.com.au> Dave Kuhlman wrote: > > On Tue, Nov 12, 2002 at 10:22:58AM +1100, Gregory Bond wrote: > > > Instead of doing this, try using > > > > > > > Ripper. Thanks! > > > > This albatross thing is sooooo cool. Pity about the seabird bloody flavour > > tho. > > I agree about the software but disagree about the bird. > > The albatross is a magnificent creature. Nothing flies farther and > stays up longer than an Albatross. It's a very appropriate name. > > Also, an albatross stays aloft with very little effort and almost > no wing flapping. Efficiency and effortlessness are also apt > connotations for Albatross the Web app server. > > Also, some species, at least, mate for life or long periods. Stick > with Albatross. It won't let you down. > > By the way, in case you are worrying about the "albatross around > the neck" thing, I looked up the "The Rime of the Ancient Mariner". > (http://etext.lib.virginia.edu/stc/Coleridge/poems/Rime_Ancient_Mariner.html) > The reason that the albatross was chosen as a symbol in that poem > is because, for a sailor, sighting an albatross was/is a *good* > omen. Needless to say, there are (some of us) bird watchers who > would be thrilled at the sight of an albatross. Um, didn't the Ancient Mariner then proceed to inhospitably shoot the Albatross with his Crossbow... and that's when his troubles really started... there's a moral there. However, having met Dave (Cole), Ben (Golding) and Andrew (McNamara), I suspect that Michael Neel is correct in his surmise that the allusion is to Monty Python, not Coleridge. That's not to say the Object Craft guys aren't well-read men of letters - they do quote Chaucer on their home page, after all. Tim C From gnb at itga.com.au Fri Nov 15 09:31:08 2002 From: gnb at itga.com.au (Gregory Bond) Date: Fri, 15 Nov 2002 09:31:08 +1100 Subject: Albatross the name Was: [albatross-users] Accessing the list of names in the context? In-Reply-To: Your message of Thu, 14 Nov 2002 14:18:09 -0500. Message-ID: <200211142231.JAA06089@lightning.itga.com.au> > And I believe the original post referred to the Monty Python sketch > with John Cleese in drag at the cinema trying to sell people an > Albatross for a snack. That was the reference, although to the longer audio version (um, "Contractual Obligations" album I think) rather than the TV version of the skit. According to my dim-but-usually-reliable-for-this-sort-or-rubbish memory, the LP verision had the "seabird bloody flavour" line which wasn't in the TV version. From neel at mediapulse.com Tue Nov 19 03:05:33 2002 From: neel at mediapulse.com (Michael C. Neel) Date: Mon, 18 Nov 2002 11:05:33 -0500 Subject: [albatross-users] ctx.req_equals() question. Message-ID: >From the docs, req_equals() returns whether or not the browser request contains a non-empty field with a name which matches the name argument. But I've noticed that if you leave a field blank on a form, submit it, have it return to the same form and submit it again, req_equals will be true for the empty field. In my case I have and edit account page to update your account. On the page is a change password / confirm password set of inputs. If they are empty I don't want to wipe out the users password, just up date the contact info. The second submission will however wipe out the password. To prevent this, my code looks like this: if ctx.req_equals("password") and ctx.req_equals("confirm"): if ctx.locals.password == ctx.locals.confirm and len(ctx.locals.password) != 0: # change password It would seem to me that the "and len(ctx.locals.password) != 0" should not be needed. I don't know if this is intended or not, I could be missing something about the intended use of req_equals(). Mike From neel at mediapulse.com Tue Nov 19 07:09:37 2002 From: neel at mediapulse.com (Michael C. Neel) Date: Mon, 18 Nov 2002 15:09:37 -0500 Subject: [albatross-users] and zero's Message-ID: It doesn't look like albatross handle ints with a value of zero. The following shows the problem... >>> import albatross >>> ctx = albatross.SimpleContext('.') >>> ctx.locals.zero = 0 >>> ctx.locals.one = 1 >>> albatross.Template(ctx, '', ''' ... ... ... ''').to_html(ctx) >>> ctx.flush_content() One would expect that zero would be . I've been trying different things, but cannot seem to find a way for albatross to set a value to zero. Mike From andrewm at object-craft.com.au Tue Nov 19 10:10:52 2002 From: andrewm at object-craft.com.au (Andrew McNamara) Date: Tue, 19 Nov 2002 10:10:52 +1100 Subject: [albatross-users] and zero's In-Reply-To: Message from "Michael C. Neel" of "Mon, 18 Nov 2002 15:09:37 CDT." References: Message-ID: <20021118231052.361FA3C4BD@coffee.object-craft.com.au> >It doesn't look like albatross handle ints with a value of zero. The >following shows the problem... [...] >One would expect that zero would be . >I've been trying different things, but cannot seem to find a way for >albatross to set a value to zero. Oops. That's a bug - here's a one line fix: diff -u -r1.99 tags.py --- tags.py 4 Sep 2002 14:07:10 -0000 1.99 +++ tags.py 18 Nov 2002 23:08:55 -0000 @@ -122,7 +122,7 @@ name, value = self.get_name_and_value(ctx) if name: ctx.write_content(' name="%s"' % name) - if value: + if value is not None: ctx.write_content(' value="%s"' % escape(value)) ctx.input_add(self.__itype, name, value, self.has_attrib('list')) -- Andrew McNamara, Senior Developer, Object Craft http://www.object-craft.com.au/ From mxr at itga.com.au Wed Nov 20 12:52:12 2002 From: mxr at itga.com.au (Michael Rembach) Date: Wed, 20 Nov 2002 12:52:12 +1100 Subject: [albatross-users] Query regarding frames Message-ID: <3DDAEACC.55D476C9@itga.com.au> Hi Guys, I have a question. If i have a mainpage that has frames, how can I get the templates within the frame to be interpolated ? EG MAIN FRAME Application Main Page Now, the template client_top.html has Albatross tags in it and I need the main.py to interpolate tags. Surely I don't have to write a .py for each frame on the page ? CLIENT_TOP client top
    Click here for Home
    Any suggestions would be most welcome. -- Michael Rembach From neel at mediapulse.com Thu Nov 21 02:17:10 2002 From: neel at mediapulse.com (Michael C. Neel) Date: Wed, 20 Nov 2002 10:17:10 -0500 Subject: [albatross-users] Query regarding frames Message-ID: Frames are really just separate calls to the webserver, so they really wouldn't cause the problem. Most likely apache (or whatever server you are using) is not handing off the frame URL's to your app. Try going to /templates/client_top.html directly and see if the tags are parsed. If not, check your setup to make sure things in the templates dir is set to your app. Sorry if that's vauge, but there are several ways you can setup albatross and apache to work together, so I'd need more info to see the exact problem. Mike > -----Original Message----- > From: Michael Rembach [mailto:mxr at itga.com.au] > Sent: Tuesday, November 19, 2002 8:52 PM > To: albatross > Subject: [albatross-users] Query regarding frames > > > Hi Guys, > > I have a question. If i have a mainpage that has frames, how > can I get > the templates within the frame to be interpolated ? > > EG > > MAIN FRAME > > > > Application Main Page > > > src="/templates/client_top.html"> > scrolling="auto" > src="/templates/client_detail.html"> > > > > Now, the template client_top.html has Albatross tags in it and I need > the main.py to interpolate tags. Surely I don't have to write a .py > for each frame on the page ? > > CLIENT_TOP > > > > > > client top > > > width="100%" bgcolor="black"> > > > > > > > >
    > TARGET="_top"> height="73" width="117" alt="Click here for Home" border="0" > align="center"> > > size="5"> expr="clientName"> >
    > size="5"> expr="companyName"> >
    > > > Any suggestions would be most welcome. > > -- > Michael Rembach > _______________________________________________ > Albatross-users mailing list > Albatross-users at object-craft.com.au > https://www.object-craft.com.au/cgi-bin/mailman/listinfo/albat ross-users From mxr at itga.com.au Thu Nov 21 10:54:09 2002 From: mxr at itga.com.au (Michael Rembach) Date: Thu, 21 Nov 2002 10:54:09 +1100 Subject: [albatross-users] Query regarding frames References: Message-ID: <3DDC20A1.A9EBC7A1@itga.com.au> Michael, I loaded client_top.html directly, instead of through the frame def page_display(self, ctx): #ctx.run_template('client_frontpage.html') ctx.run_template('client_top.html') and this worked, which means that the template directory is fine and the tags are being parsed directly. I am sure the problem lies in the frame HTML tag where the src bit isn't interpolated. Any ideas ? "Michael C. Neel" wrote: > > Frames are really just separate calls to the webserver, so they really > wouldn't cause the problem. Most likely apache (or whatever server you > are using) is not handing off the frame URL's to your app. Try going to > /templates/client_top.html directly and see if the tags are parsed. If > not, check your setup to make sure things in the templates dir is set to > your app. > > Sorry if that's vauge, but there are several ways you can setup > albatross and apache to work together, so I'd need more info to see the > exact problem. > > Mike > > > -----Original Message----- > > From: Michael Rembach [mailto:mxr at itga.com.au] > > Sent: Tuesday, November 19, 2002 8:52 PM > > To: albatross > > Subject: [albatross-users] Query regarding frames > > > > > > Hi Guys, > > > > I have a question. If i have a mainpage that has frames, how > > can I get > > the templates within the frame to be interpolated ? > > > > EG > > > > MAIN FRAME > > > > > > > > Application Main Page > > > > > > > src="/templates/client_top.html"> > > > scrolling="auto" > > src="/templates/client_detail.html"> > > > > > > > > Now, the template client_top.html has Albatross tags in it and I need > > the main.py to interpolate tags. Surely I don't have to write a .py > > for each frame on the page ? > > > > CLIENT_TOP > > > > > > > > > > > > client top > > > > > > > width="100%" bgcolor="black"> > > > > > > > > > > > > > > > >
    > > > TARGET="_top"> > height="73" width="117" alt="Click here for Home" border="0" > > align="center"> > > > > > size="5"> > expr="clientName"> > >
    > > > size="5"> > expr="companyName"> > >
    > > > > > > Any suggestions would be most welcome. > > > > -- > > Michael Rembach > > _______________________________________________ > > Albatross-users mailing list > > Albatross-users at object-craft.com.au > > https://www.object-craft.com.au/cgi-bin/mailman/listinfo/albat > ross-users -- Michael Rembach From andrewm at object-craft.com.au Thu Nov 21 11:08:48 2002 From: andrewm at object-craft.com.au (Andrew McNamara) Date: Thu, 21 Nov 2002 11:08:48 +1100 Subject: [albatross-users] Query regarding frames In-Reply-To: Message from Michael Rembach of "Wed, 20 Nov 2002 12:52:12 +1100." <3DDAEACC.55D476C9@itga.com.au> References: <3DDAEACC.55D476C9@itga.com.au> Message-ID: <20021121000848.3F1943C4BD@coffee.object-craft.com.au> >I have a question. If i have a mainpage that has frames, how can I get >the templates within the frame to be interpolated ? There are a couple of ways this can be done - Dave initially suggested using the RandomPage mixin, and including some tag in the URL to tell the application which frame was being rendered. I ran into problems with this because RandomPage issues redirects from time to time, and my paranoid browser through someone was trying to trick it. Instead, I include arguments in the URLS like this: Sorry, this document can be viewed only with a frames-capable browser. Then, in the page class's display_page() method, I call a different ctx.run_template(...) depending on what's in the request. Hope this helps (and makes sense). 8-) -- Andrew McNamara, Senior Developer, Object Craft http://www.object-craft.com.au/ From andrewm at object-craft.com.au Thu Nov 21 13:25:14 2002 From: andrewm at object-craft.com.au (Andrew McNamara) Date: Thu, 21 Nov 2002 13:25:14 +1100 Subject: [albatross-users] A problem with cookies and multiple apps in the same directory In-Reply-To: Message from Gregory Bond of "Thu, 14 Nov 2002 17:16:27 +1100." <200211140616.RAA08948@lightning.itga.com.au> References: <200211140616.RAA08948@lightning.itga.com.au> Message-ID: <20021121022514.B6CFE3C4BD@coffee.object-craft.com.au> >But we can't use both apps. If we go to one, then it sets a cookie with the >name of that appid, and a path of "/cgi-bin/dir". When we then navigate to >the second app, it doesn't attempt to set a new cookie, but tries to use the >cookie set by the previous app, and dies with an exception: Sorry about the delay replying to this - I think this is a typo in Albatross's sesionfile.py. Can you change the "except OSError:" on line 209 to "except KeyError:" and let me know how that goes (I don't think os.path.basename can raise OSError)? --- sessionfile.py 8 Aug 2002 09:53:38 -0000 1.20 +++ sessionfile.py 21 Nov 2002 02:23:53 -0000 @@ -35,7 +35,7 @@ c = Cookie.SimpleCookie(hdr) try: return os.path.basename(c[self.app.ses_appid()].value) - except OSError: + except KeyError: pass return None -- Andrew McNamara, Senior Developer, Object Craft http://www.object-craft.com.au/ From gnb at itga.com.au Thu Nov 21 14:03:10 2002 From: gnb at itga.com.au (Gregory Bond) Date: Thu, 21 Nov 2002 14:03:10 +1100 Subject: [albatross-users] A problem with cookies and multiple apps in the same directory In-Reply-To: Your message of Thu, 21 Nov 2002 13:25:14 +1100. Message-ID: <200211210303.OAA02020@lightning.itga.com.au> >I think this is a typo in Albatross's sesionfile.py. Can you change the "except >OSError:" on line 209 to "except KeyError:" and let me know how that goes That fixes it fine. Thanks! (It/'s line 38, btw) From andrewm at object-craft.com.au Thu Nov 21 14:18:29 2002 From: andrewm at object-craft.com.au (Andrew McNamara) Date: Thu, 21 Nov 2002 14:18:29 +1100 Subject: [albatross-users] A problem with cookies and multiple apps in the same directory In-Reply-To: Message from Gregory Bond of "Thu, 21 Nov 2002 14:03:10 +1100." <200211210303.OAA02020@lightning.itga.com.au> References: <200211210303.OAA02020@lightning.itga.com.au> Message-ID: <20021121031829.3604A3C4BD@coffee.object-craft.com.au> >>I think this is a typo in Albatross's sesionfile.py. Can you change the >>"except OSError:" on line 209 to "except KeyError:" and let me know how >>that goes > >That fixes it fine. Thanks! Ta. I've commited the change (I'm also catching OSError, just in case one of the other implementations of os.path choses to raise it). >(It/'s line 38, btw) I keep getting caught by that - version 6 VIM moved the current line number to the bottom row of the screen, and removed it from the ^G output. -- Andrew McNamara, Senior Developer, Object Craft http://www.object-craft.com.au/ From rbb at techgame.net Thu Nov 21 16:59:35 2002 From: rbb at techgame.net (Brian Brown) Date: Wed, 20 Nov 2002 22:59:35 -0700 Subject: [albatross-users] A problem with cookies and multiple apps in the same directory In-Reply-To: <20021121031829.3604A3C4BD@coffee.object-craft.com.au> Message-ID: <69C3C832-FD16-11D6-90ED-003065F89450@techgame.net> On Wednesday, November 20, 2002, at 08:18 PM, Andrew McNamara wrote: > > I keep getting caught by that - version 6 VIM moved the current line > number to the bottom row of the screen, and removed it from the ^G > output. > At least you are using the One True Editor ;-) > -- > Andrew McNamara, Senior Developer, Object Craft > http://www.object-craft.com.au/ > _______________________________________________ > 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 Fri Nov 22 03:30:52 2002 From: neel at mediapulse.com (Michael C. Neel) Date: Thu, 21 Nov 2002 11:30:52 -0500 Subject: [albatross-users] A problem with cookies and multiple apps in the same directory Message-ID: > On Wednesday, November 20, 2002, at 08:18 PM, Andrew McNamara wrote: > > > > I keep getting caught by that - version 6 VIM moved the current line > > number to the bottom row of the screen, and removed it from the ^G > > output. > > > > At least you are using the One True Editor ;-) > Here, Here! Let all drink a round to VI, or better yet VIM! Did you know that if you vim a directory, and dir list comes up in the editor and you can place you cursor over the dir, hit enter and navigate to a file to edit? I also love :!killall -HUP httpd in vi. Great for those mod_python albatross apps. Vi even tells you when you forgot to save before restarting apache. And how about that windows vesrion? If you don't have it, it's at www.vim.org - even MS has givin over 2K to the projects charity fund. Mike From mxr at itga.com.au Wed Nov 27 11:31:42 2002 From: mxr at itga.com.au (Michael Rembach) Date: Wed, 27 Nov 2002 11:31:42 +1100 Subject: [albatross-users] Question using page modules Message-ID: <3DE4126E.D061F883@itga.com.au> Hi guys, I have a small problem with page modules (or at least my understanding of them). app = ModularSessionFileApp context = SessionFileAppContext the program is called itgaweb.py I set the initial page module, which processes the requests and uses a set_page depending on what choice is made. I was under the impression that once you changed the page, you would invoke the pageModule you have chosen. ie, I have a choice called gicslookup, which is a page module called gicslookup.py. When I select it from the mainpage, the gicslookup form appears just fine (as you'd expect). At this point I have invoked the set_page('gicslookup'). But when I hit the submit button, it re-calls itgaweb.py instead of gicslookup.py (which I thought it would do) The form tag has
    but I thought it should have action="/cgi-bin/protected/itgaweb.py" Am I using the wrong app-type ? Does this email make any sense at all ? Please help -- Michael Rembach ITG Australia From neel at mediapulse.com Wed Nov 27 12:32:37 2002 From: neel at mediapulse.com (Michael C. Neel) Date: Tue, 26 Nov 2002 20:32:37 -0500 Subject: [albatross-users] ctx.req_equals() question. In-Reply-To: Message-ID: <000901c295b4$de6ccf40$af00a8c0@CLAPTON> Replying to this because I haven't heard anything about the below, and also I've noticed another req_equals issue. It seems if you use an input of type="image" the name will not be set in req_equals, i.e. ctx.req_equals("mybutton") will return false while dir(ctx.locals).has_key("mybutton") will return true Mike > -----Original Message----- > From: albatross-users-admin at object-craft.com.au [mailto:albatross-users- > admin at object-craft.com.au] On Behalf Of Michael C. Neel > Sent: Monday, November 18, 2002 11:06 AM > To: albatross-users at object-craft.com.au > Subject: [albatross-users] ctx.req_equals() question. > > From the docs, req_equals() returns whether or not the browser request > contains a non-empty field with a name which matches the name argument. > But I've noticed that if you leave a field blank on a form, submit it, > have it return to the same form and submit it again, req_equals will be > true for the empty field. > > In my case I have and edit account page to update your account. On the > page is a change password / confirm password set of inputs. If they are > empty I don't want to wipe out the users password, just up date the > contact info. The second submission will however wipe out the password. > To prevent this, my code looks like this: > > if ctx.req_equals("password") and ctx.req_equals("confirm"): > if ctx.locals.password == ctx.locals.confirm and > len(ctx.locals.password) != 0: > # change password > > It would seem to me that the "and len(ctx.locals.password) != 0" should > not be needed. I don't know if this is intended or not, I could be > missing something about the intended use of req_equals(). > > Mike > > > _______________________________________________ > Albatross-users mailing list > Albatross-users at object-craft.com.au > https://www.object-craft.com.au/cgi-bin/mailman/listinfo/albatross-users From gnb at itga.com.au Wed Nov 27 13:16:48 2002 From: gnb at itga.com.au (Gregory Bond) Date: Wed, 27 Nov 2002 13:16:48 +1100 Subject: [albatross-users] ctx.req_equals() question. In-Reply-To: Your message of Tue, 26 Nov 2002 20:32:37 -0500. Message-ID: <200211270216.NAA11594@lightning.itga.com.au> > ctx.req_equals("mybutton") >will return false while > dir(ctx.locals).has_key("mybutton") >will return true You probably need to use ctx.req_equals("mybutton.x") as is mentioned in passing about half way through Sec 4.3 in the manual. From mxr at itga.com.au Wed Nov 27 16:15:24 2002 From: mxr at itga.com.au (Michael Rembach) Date: Wed, 27 Nov 2002 16:15:24 +1100 Subject: [albatross-users] Last query Message-ID: <3DE454EC.E9D7C1BE@itga.com.au> Hi Guys, The query I had in the last email can be ignored, I had an error in the code that deleted the Session and as a result confused the whole operation. Sorted now, onwards and upwards. -- Michael Rembach From andrewm at object-craft.com.au Wed Nov 27 16:20:59 2002 From: andrewm at object-craft.com.au (Andrew McNamara) Date: Wed, 27 Nov 2002 16:20:59 +1100 Subject: [albatross-users] Question using page modules In-Reply-To: Message from Michael Rembach of "Wed, 27 Nov 2002 11:31:42 +1100." <3DE4126E.D061F883@itga.com.au> References: <3DE4126E.D061F883@itga.com.au> Message-ID: <20021127052059.04C5A3C510@coffee.object-craft.com.au> >I was under the impression that once you changed the page, you would >invoke the pageModule you have chosen. ie, I have a choice called >gicslookup, which is a page module called gicslookup.py. When I select >it from the mainpage, the gicslookup form appears just fine (as you'd >expect). At this point I have invoked the set_page('gicslookup'). > >But when I hit the submit button, it re-calls itgaweb.py instead of >gicslookup.py (which I thought it would do) > >The form tag has action="/cgi-bin/protected/itgaweb.py"> >but I thought it should have action="/cgi-bin/protected/itgaweb.py" The URL will always correspond to the base_url - so you might have a base_url of 'app.py', and your browser will always be running /cgi-bin/app.py (unless you are using a RandomPage mixin). In app.py, you create the App, Request and Context objects, and not much else (when you call App mixin's __init__ method, you tell it what page is to be the initial page with the start_page argument). I suspect you are doing the equivilent of setting the start_page to app.py - make your initial page module something like "login", and it will load and run login.py instead (but the URL will still be app.py). Clear as mud? -- Andrew McNamara, Senior Developer, Object Craft http://www.object-craft.com.au/ From andrewm at object-craft.com.au Wed Nov 27 16:24:09 2002 From: andrewm at object-craft.com.au (Andrew McNamara) Date: Wed, 27 Nov 2002 16:24:09 +1100 Subject: [albatross-users] ctx.req_equals() question. In-Reply-To: Message from Gregory Bond of "Wed, 27 Nov 2002 13:16:48 +1100." <200211270216.NAA11594@lightning.itga.com.au> References: <200211270216.NAA11594@lightning.itga.com.au> Message-ID: <20021127052409.B1B1C3C510@coffee.object-craft.com.au> >> ctx.req_equals("mybutton") >>will return false while >> dir(ctx.locals).has_key("mybutton") >>will return true > >You probably need to use > ctx.req_equals("mybutton.x") >as is mentioned in passing about half way through Sec 4.3 in the manual. Yep - the "image" inputs return the co-ordinates of where, within the image, the user clicked. So you get mybutton.x and mybutton.y in the Request class. A pain in the bottom, generally, but that's what you get for abusing HTML... 8-) -- Andrew McNamara, Senior Developer, Object Craft http://www.object-craft.com.au/ From neel at mediapulse.com Thu Nov 28 01:48:55 2002 From: neel at mediapulse.com (Michael C. Neel) Date: Wed, 27 Nov 2002 09:48:55 -0500 Subject: [albatross-users] ctx.req_equals() question. Message-ID: Okay, I'll try the ".x" part. Hopefully that will work and not run into the other req_equals issue I'm having. I do think it's a bit counter intuitive, to work this way. I had assumed that mybutton was a 2 arg tuple od (x,y) since that's what it returns as ctx.locals.mybutton. It's great that there is a lot of documentation, but the layout is very hard to use for reference. I would expect this under 5.1.2.7 rather than 4.3 The Popview App. Input file was the same way, I had to play around with it to figure out how to access the data sent. BTW, how is this abusing html? This is how you would implement server-side image maps, and is nothing new. It's also the basis of how prev and next buttons. Mike > -----Original Message----- > From: Andrew McNamara [mailto:andrewm at object-craft.com.au] > Sent: Wednesday, November 27, 2002 12:24 AM > To: albatross-users at object-craft.com.au > Subject: Re: [albatross-users] ctx.req_equals() question. > > > >> ctx.req_equals("mybutton") > >>will return false while > >> dir(ctx.locals).has_key("mybutton") > >>will return true > > > >You probably need to use > > ctx.req_equals("mybutton.x") > >as is mentioned in passing about half way through Sec 4.3 in > the manual. > > Yep - the "image" inputs return the co-ordinates of where, within the > image, the user clicked. So you get mybutton.x and mybutton.y in the > Request class. A pain in the bottom, generally, but that's > what you get > for abusing HTML... 8-) > > -- > Andrew McNamara, Senior Developer, Object Craft > http://www.object-craft.com.au/ > _______________________________________________ > Albatross-users mailing list > Albatross-users at object-craft.com.au > https://www.object-craft.com.au/cgi-bin/mailman/listinfo/albat ross-users From neel at mediapulse.com Thu Nov 28 06:10:26 2002 From: neel at mediapulse.com (Michael C. Neel) Date: Wed, 27 Nov 2002 14:10:26 -0500 Subject: [albatross-users] Changing the status code Message-ID: I'm having trouble setting the status of a page though albatross using mod_python. I've snipped out extra lines here, but the idea is to set a cookie with the redirect. The ctx.request.redirect function ignores any custom headers, so I had to roll my own here. in mod_python's handler(): app = SimpleApp(base_url = '/', template_path = '/home/sites/templates', start_page = page, secret = '-=secret=-') app.register_page(page,StdForm(page)) return app.run(Request(req)) and then in the StdForm class: def page_process(self, ctx): ctx.request.status(apache.HTTP_MOVED_PERMANENTLY) ctx.request.write_header('Set-Cookie',cookies['beenhere'].OutputString() ) ctx.request.write_header('Location','https://gohere.com/') self.page = "store_redirect.html" def page_display(self, ctx): ctx.run_template(self.page) (again I snipped out a lot of other code). I've looked though anything in the docs I can find on status(), but there is no mention of any special requirments that I'm not doing already. Thanks, Mike From djc at object-craft.com.au Thu Nov 28 10:09:43 2002 From: djc at object-craft.com.au (Dave Cole) Date: 28 Nov 2002 10:09:43 +1100 Subject: [albatross-users] Changing the status code In-Reply-To: References: Message-ID: > I'm having trouble setting the status of a page though albatross > using mod_python. Albatross does not really help you here. At the moment all non-exception processing returns status 200. The culprit is the run() method in the Application class. The status() method on the Request class translates an HTTP status code to something that can be returned as a status code to the execution framework. That seems a little obscure... Consider the way that a mod_python application works: from albatross.apacheapp import Request : : app = App() def handler(req): return app.run(Request(req)) mod_python expects the return value for the handler() function to be zero if everything is OK. The status() method in apacheapp.Request simply translates the 200 from the Application.run() method to zero. > I've snipped out extra lines here, but the idea is to set a cookie > with the redirect. The ctx.request.redirect function ignores any > custom headers, so I had to roll my own here. Something which we could certainly improve is the interface for manipulating headers. > and then in the StdForm class: > > def page_process(self, ctx): > > ctx.request.status(apache.HTTP_MOVED_PERMANENTLY) The status() method does not change the status which is returned by the handler function. Currently we do not have a way to do this. If we do not get any objections, I suggest that we make the following changes: In all Request classes: def Request: def __init__(self, req): self.__status = 200 def set_status(self, status): self.__status = status def status(self): # For mod_python... if self.__status == 200: return 0 return self.__status Then in the Application.run() method: def run(self, req): : : return req.status() This would allow you to simply change the returned status by doing a small variation of your code above: def page_process(self, ctx): ctx.request.set_status(apache.HTTP_MOVED_PERMANENTLY) - Dave -- http://www.object-craft.com.au From andrewm at object-craft.com.au Thu Nov 28 10:20:39 2002 From: andrewm at object-craft.com.au (Andrew McNamara) Date: Thu, 28 Nov 2002 10:20:39 +1100 Subject: [albatross-users] ctx.req_equals() question. In-Reply-To: Message from "Michael C. Neel" of "Wed, 27 Nov 2002 09:48:55 CDT." References: Message-ID: <20021127232039.424EB3C510@coffee.object-craft.com.au> >Okay, I'll try the ".x" part. Hopefully that will work and not run into >the other req_equals issue I'm having. I do think it's a bit counter >intuitive, to work this way. I had assumed that mybutton was a 2 arg >tuple od (x,y) since that's what it returns as ctx.locals.mybutton. Yep - I'll agree it's a wart. It's this way because ctx.req_equals is a thin veneer over the Request class, which, in turn, is a thin veneer over the standard library cgi.FieldStorage class. I'm forever coming up with schemes to hide this behaviour in my apps. Albatross should help - maybe ctx.req_equals should check for the .x form? This would be a compatibility problem, however. Any preferences? >It's great that there is a lot of documentation, but the layout is very >hard to use for reference. I would expect this under 5.1.2.7 type="image"> rather than 4.3 The Popview App. Input file was the same >way, I had to play around with it to figure out how to access the data >sent. Good point - we'll try to address this in the next release. All suggestions for improving Albatross are gratefully received... 8-) >BTW, how is this abusing html? This is how you would implement >server-side image maps, and is nothing new. It's also the basis of how >prev and next buttons. I guess it's abusing the spirit of HTML, rather than any technical problem. HTML 4 (I think) added explicit button inputs, but they require javascript to be enabled to work, which sort of defeats the purpose. -- Andrew McNamara, Senior Developer, Object Craft http://www.object-craft.com.au/ From neel at mediapulse.com Thu Nov 28 10:35:37 2002 From: neel at mediapulse.com (Michael C. Neel) Date: Wed, 27 Nov 2002 18:35:37 -0500 Subject: [albatross-users] Changing the status code In-Reply-To: Message-ID: <000001c2966d$b09a0240$af00a8c0@CLAPTON> Thanks for the answer. I should be able to write a small class to wrap the current mod_python version of Request to do this. In the meantime I worked arounf it using a meta tag, but this open up other options (us as setting a cookie in an access denied page - why, not sure why you would want to, but it's always good to know you can!). Do you do anything for US thanksgiving (wouldn't make much since, lol)? Ah well, either way, have a happy thanksgiving! Mike > -----Original Message----- > From: djc at ferret.object-craft.com.au [mailto:djc at ferret.object- > craft.com.au] On Behalf Of Dave Cole > Sent: Wednesday, November 27, 2002 6:10 PM > To: Michael C. Neel > Cc: albatross-users at object-craft.com.au > Subject: Re: [albatross-users] Changing the status code > > > > I'm having trouble setting the status of a page though albatross > > using mod_python. > > Albatross does not really help you here. At the moment all > non-exception processing returns status 200. The culprit is the run() > method in the Application class. > > The status() method on the Request class translates an HTTP status > code to something that can be returned as a status code to the > execution framework. That seems a little obscure... Consider the way > that a mod_python application works: > > from albatross.apacheapp import Request > : > : > app = App() > > def handler(req): > return app.run(Request(req)) > > mod_python expects the return value for the handler() function to be > zero if everything is OK. The status() method in apacheapp.Request > simply translates the 200 from the Application.run() method to zero. > > > I've snipped out extra lines here, but the idea is to set a cookie > > with the redirect. The ctx.request.redirect function ignores any > > custom headers, so I had to roll my own here. > > Something which we could certainly improve is the interface for > manipulating headers. > > > and then in the StdForm class: > > > > def page_process(self, ctx): > > > > ctx.request.status(apache.HTTP_MOVED_PERMANENTLY) > > The status() method does not change the status which is returned by > the handler function. Currently we do not have a way to do this. > > If we do not get any objections, I suggest that we make the following > changes: > > In all Request classes: > > def Request: > def __init__(self, req): > self.__status = 200 > > def set_status(self, status): > self.__status = status > > def status(self): > # For mod_python... > if self.__status == 200: > return 0 > return self.__status > > Then in the Application.run() method: > > def run(self, req): > : > : > return req.status() > > This would allow you to simply change the returned status by doing a > small variation of your code above: > > def page_process(self, ctx): > ctx.request.set_status(apache.HTTP_MOVED_PERMANENTLY) > > - Dave > > -- > http://www.object-craft.com.au From neel at mediapulse.com Thu Nov 28 10:56:41 2002 From: neel at mediapulse.com (Michael C. Neel) Date: Wed, 27 Nov 2002 18:56:41 -0500 Subject: [albatross-users] ctx.req_equals() question. In-Reply-To: <20021127232039.424EB3C510@coffee.object-craft.com.au> Message-ID: <000101c29670$a1cf0dc0$af00a8c0@CLAPTON> > I'm forever coming up with schemes to hide this behaviour in my > apps. Albatross should help - maybe ctx.req_equals should check for the > .x form? This would be a compatibility problem, however. Any preferences? Well, since ctx.locals.mybutton and ctx.locals.mybutton.x both do exist, I wouldn't see a problem with both. For the documentation, I'd love to see the tag pages show both the using and the parsing. I've read the doc completely once, so now I just use it as reference. The two things I look up most is how do I access data when submitted and what member functions/variables does object x have. The first sometimes takes some searching; the latter usually takes some digging though base classes - a link to the base class on those pages would help a lot. > I guess it's abusing the spirit of HTML, rather than any technical > problem. HTML 4 (I think) added explicit button inputs, but they require > javascript to be enabled to work, which sort of defeats the purpose. I hate having to resort to client side scripting for application stuff. Field validation is nice, but switching between deleting a record or updating should be done server side, imho. My normal method would be PATH_INFO, but I tried giving custom action tags, and let's just say I don't try that any more ;) (Albatross in the voice of Bart Simpson - Ow, quit it. Ow, quit it.). It would be nice if image submits took a value argument like the text counter part, but then the last place I go for HTML syntax is W3C. If it works in IE, NS and lynx it's good enough for me! Mike From andrewm at object-craft.com.au Thu Nov 28 13:38:56 2002 From: andrewm at object-craft.com.au (Andrew McNamara) Date: Thu, 28 Nov 2002 13:38:56 +1100 Subject: [albatross-users] ctx.req_equals() question. In-Reply-To: Message from "Michael C. Neel" of "Wed, 27 Nov 2002 18:56:41 CDT." <000101c29670$a1cf0dc0$af00a8c0@CLAPTON> References: <000101c29670$a1cf0dc0$af00a8c0@CLAPTON> Message-ID: <20021128023856.0BB123C510@coffee.object-craft.com.au> >Well, since ctx.locals.mybutton and ctx.locals.mybutton.x both do exist, >I wouldn't see a problem with both. True. I guess the only time it would really be a problem is if some misguided developer had an "image" field and some other field, both with the same name. In which case, they get what they deserve... 8-) >For the documentation, I'd love to see the tag pages show both the using >and the parsing. I've read the doc completely once, so now I just use >it as reference. The two things I look up most is how do I access data >when submitted and what member functions/variables does object x have. >The first sometimes takes some searching; the latter usually takes some >digging though base classes - a link to the base class on those pages >would help a lot. Noted. >> I guess it's abusing the spirit of HTML, rather than any technical >> problem. HTML 4 (I think) added explicit button inputs, but they >require >> javascript to be enabled to work, which sort of defeats the purpose. > >I hate having to resort to client side scripting for application stuff. >Field validation is nice, but switching between deleting a record or >updating should be done server side, imho. Yep. I typically have Javascript turned off in my browsers, since there are too many ways to abuse it. This is a shame, because it fills a real need. >My normal method would be PATH_INFO, but I tried giving custom >action tags, and let's just say I don't try that any more ;) (Albatross >in the voice of Bart Simpson - Ow, quit it. Ow, quit it.). This is something I'm not familiar with (or maybe I've just forgotten) - PATH_INFO? >It would be nice if image submits took a value argument like the text >counter part, but then the last place I go for HTML syntax is W3C. If it >works in IE, NS and lynx it's good enough for me! Yes. The HTML spec is silent on what happens if you supply a value= attribute to an image input - it's something I've often wished for. Instead, I play games with nameexpr, and then have to extract the value in my page_process method. -- Andrew McNamara, Senior Developer, Object Craft http://www.object-craft.com.au/ From andrewm at object-craft.com.au Thu Nov 28 17:03:18 2002 From: andrewm at object-craft.com.au (Andrew McNamara) Date: Thu, 28 Nov 2002 17:03:18 +1100 Subject: [albatross-users] A problem with cookies and multiple apps in the same directory In-Reply-To: Message from "Michael C. Neel" of "Thu, 21 Nov 2002 11:30:52 CDT." References: Message-ID: <20021128060318.C8FE83C510@coffee.object-craft.com.au> >Here, Here! Let all drink a round to VI, or better yet VIM! As a co-worker of old used to regularly say "you can't spell vile without vi"... 8-) In the spirit of Python (Monty, that is)... In my day, we used "ex" at 300 baud half duplex on a teletype, and we were thankful, because it wasn't "ed"... >Did you know that if you vim a directory, and dir list comes up in the >editor and you can place you cursor over the dir, hit enter and navigate >to a file to edit? I actually used that the other day. Hmm. Can you hear that noise? It's all the emacs users laughing at us - it's always done stuff like this. >I also love :!killall -HUP httpd in vi. Great for those mod_python >albatross apps. Vi even tells you when you forgot to save before >restarting apache. Uh - vi's been able to do this for a while... >And how about that windows vesrion? If you don't have it, it's at >www.vim.org - even MS has givin over 2K to the projects charity fund. Yep, any time I have spend some time using Wintendo, I find a vi clone and install it. Broken we are. We want to be careful, 'cause Dave is an Emacs man. He'll start posting Albatross "major modes" to the list if we get him worked up... 8-) -- Andrew McNamara, Senior Developer, Object Craft http://www.object-craft.com.au/ From neel at mediapulse.com Fri Nov 29 15:41:33 2002 From: neel at mediapulse.com (Michael Neel) Date: Thu, 28 Nov 2002 23:41:33 -0500 Subject: [albatross-users] ctx.req_equals() question. In-Reply-To: <20021128023856.0BB123C510@coffee.object-craft.com.au> Message-ID: <000501c29761$97d0ca60$0600a8c0@santana> >This is something I'm not familiar with (or maybe I've just forgotten) - >PATH_INFO? If you had the /add would be in the env var PATH_INFO. This might be an apache only thing, not sure. Mike From djc at object-craft.com.au Fri Nov 29 20:51:17 2002 From: djc at object-craft.com.au (Dave Cole) Date: 29 Nov 2002 20:51:17 +1100 Subject: [albatross-users] Changing the status code In-Reply-To: <000001c2966d$b09a0240$af00a8c0@CLAPTON> References: <000001c2966d$b09a0240$af00a8c0@CLAPTON> Message-ID: >>>>> "Michael" == Michael C Neel writes: Michael> Thanks for the answer. I suppose we should make the proposed changes for the next release then. Michael> I should be able to write a small class to wrap the current Michael> mod_python version of Request to do this. In the meantime I Michael> worked arounf it using a meta tag, but this open up other Michael> options (us as setting a cookie in an access denied page - Michael> why, not sure why you would want to, but it's always good to Michael> know you can!). Michael> Do you do anything for US thanksgiving (wouldn't make much Michael> since, lol)? Not yet. It wouldn't surprise me if we started to do something within the next decade though. We have kids occasionally walking around on Halloween trying to sting us for lollies. They tend not to be very successful :-) Michael> Ah well, either way, have a happy thanksgiving! Thanks. Make sure you eat yourself into unconsciousness! - Dave >> -----Original Message----- From: djc at ferret.object-craft.com.au >> [mailto:djc at ferret.object- craft.com.au] On Behalf Of Dave Cole >> Sent: Wednesday, November 27, 2002 6:10 PM To: Michael C. Neel Cc: >> albatross-users at object-craft.com.au Subject: Re: [albatross-users] >> Changing the status code >> >> >> > I'm having trouble setting the status of a page though albatross >> > using mod_python. >> >> Albatross does not really help you here. At the moment all >> non-exception processing returns status 200. The culprit is the >> run() method in the Application class. >> >> The status() method on the Request class translates an HTTP status >> code to something that can be returned as a status code to the >> execution framework. That seems a little obscure... Consider the >> way that a mod_python application works: >> >> from albatross.apacheapp import Request >> : >> : >> app = App() >> >> def handler(req): return app.run(Request(req)) >> >> mod_python expects the return value for the handler() function to >> be zero if everything is OK. The status() method in >> apacheapp.Request simply translates the 200 from the >> Application.run() method to zero. >> >> > I've snipped out extra lines here, but the idea is to set a >> cookie > with the redirect. The ctx.request.redirect function >> ignores any > custom headers, so I had to roll my own here. >> >> Something which we could certainly improve is the interface for >> manipulating headers. >> >> > and then in the StdForm class: >> > >> > def page_process(self, ctx): >> > >> > ctx.request.status(apache.HTTP_MOVED_PERMANENTLY) >> >> The status() method does not change the status which is returned by >> the handler function. Currently we do not have a way to do this. >> >> If we do not get any objections, I suggest that we make the >> following changes: >> >> In all Request classes: >> >> def Request: def __init__(self, req): self.__status = 200 >> >> def set_status(self, status): self.__status = status >> >> def status(self): # For mod_python... if self.__status == 200: >> return 0 return self.__status >> >> Then in the Application.run() method: >> >> def run(self, req): >> : >> : >> return req.status() >> >> This would allow you to simply change the returned status by doing >> a small variation of your code above: >> >> def page_process(self, ctx): >> ctx.request.set_status(apache.HTTP_MOVED_PERMANENTLY) >> >> - Dave >> >> -- http://www.object-craft.com.au Michael> _______________________________________________ Michael> Albatross-users mailing list Michael> Albatross-users at object-craft.com.au Michael> https://www.object-craft.com.au/cgi-bin/mailman/listinfo/albatross-users -- http://www.object-craft.com.au