From sigzero at gmail.com Tue Jan 1 15:38:23 2008 From: sigzero at gmail.com (Robert Hicks) Date: Tue Jan 1 15:39:18 2008 Subject: [cgiapp] Nothing fancy but IE chokes? Message-ID: I have a simple site: www.skylinebaptist.us IE for some reason cannot navigate to: http://www.skylinebaptist.us/index.cgi?rm=ministries Firefox has no problem at all. Any idea why IE barfs (besides IE is crap)? Robert From Kezmega at sbcglobal.net Tue Jan 1 16:02:57 2008 From: Kezmega at sbcglobal.net (Kevin) Date: Tue Jan 1 16:01:37 2008 Subject: [cgiapp] Nothing fancy but IE chokes? References: Message-ID: <000b01c84cb9$afc3bac0$6401a8c0@kezmegahome> Robert, I believe the page is not being rendered because of a missing bracket on the opening tag for the title. Kevin ----- Original Message ----- From: "Robert Hicks" To: Sent: Tuesday, January 01, 2008 2:38 PM Subject: [cgiapp] Nothing fancy but IE chokes? >I have a simple site: > > www.skylinebaptist.us > > IE for some reason cannot navigate to: > > http://www.skylinebaptist.us/index.cgi?rm=ministries > > Firefox has no problem at all. Any idea why IE barfs (besides IE is crap)? > > Robert > > > ##### CGI::Application community mailing list ################ > ## ## > ## To unsubscribe, or change your message delivery options, ## > ## visit: http://www.erlbaum.net/mailman/listinfo/cgiapp ## > ## ## > ## Web archive: http://www.erlbaum.net/pipermail/cgiapp/ ## > ## Wiki: http://cgiapp.erlbaum.net/ ## > ## ## > ################################################################ > From karen.cravens at gmail.com Tue Jan 1 16:06:05 2008 From: karen.cravens at gmail.com (Karen) Date: Tue Jan 1 16:06:08 2008 Subject: [cgiapp] Nothing fancy but IE chokes? In-Reply-To: <000b01c84cb9$afc3bac0$6401a8c0@kezmegahome> References: <000b01c84cb9$afc3bac0$6401a8c0@kezmegahome> Message-ID: <7cc7c1ce0801011306k6dc75a3brd51b1d79c1fdc6c7@mail.gmail.com> On 1/1/08, Kevin wrote: > Robert, > > I believe the page is not being rendered because of a missing bracket on the > opening tag for the title. Good catch. Robert, you might want to try validating pages, like so: http://validator.w3.org/check?verbose=1&uri=http%3A%2F%2Fwww.skylinebaptist.us%2Findex.cgi%3Frm%3Dministries That often catches things that don't show up otherwise. From sigzero at gmail.com Tue Jan 1 16:09:38 2008 From: sigzero at gmail.com (Robert Hicks) Date: Tue Jan 1 16:10:50 2008 Subject: [cgiapp] Re: Nothing fancy but IE chokes? In-Reply-To: <000b01c84cb9$afc3bac0$6401a8c0@kezmegahome> References: <000b01c84cb9$afc3bac0$6401a8c0@kezmegahome> Message-ID: You are right *but* the code for that comes from: [% webpage_title %] That was wierd...I simple re-wrote it character for character and it now prints out the right HTML. Hmmm Kevin wrote: > Robert, > > I believe the page is not being rendered because of a missing bracket on > the opening tag for the title. > > Kevin > > ----- Original Message ----- From: "Robert Hicks" From sigzero at gmail.com Tue Jan 1 16:59:45 2008 From: sigzero at gmail.com (Robert Hicks) Date: Tue Jan 1 17:00:15 2008 Subject: [cgiapp] Re: Nothing fancy but IE chokes? In-Reply-To: <7cc7c1ce0801011306k6dc75a3brd51b1d79c1fdc6c7@mail.gmail.com> References: <000b01c84cb9$afc3bac0$6401a8c0@kezmegahome> <7cc7c1ce0801011306k6dc75a3brd51b1d79c1fdc6c7@mail.gmail.com> Message-ID: Karen wrote: > On 1/1/08, Kevin wrote: >> Robert, >> >> I believe the page is not being rendered because of a missing bracket on the >> opening tag for the title. > > Good catch. Robert, you might want to try validating pages, like so: > > http://validator.w3.org/check?verbose=1&uri=http%3A%2F%2Fwww.skylinebaptist.us%2Findex.cgi%3Frm%3Dministries > > That often catches things that don't show up otherwise. > Thanks! Yes I should be using that. : ) Robert From mpeters at plusthree.com Tue Jan 1 17:49:18 2008 From: mpeters at plusthree.com (Michael Peters) Date: Tue Jan 1 17:50:45 2008 Subject: [cgiapp] Re: Nothing fancy but IE chokes? In-Reply-To: References: <000b01c84cb9$afc3bac0$6401a8c0@kezmegahome> Message-ID: <477AC36E.9090806@plusthree.com> Robert Hicks wrote: > You are right *but* the code for that comes from: > > [% webpage_title %] This probably isn't your problem, but all input that goes in your templates should be HTML escaped unless you know it has been earlier. TT makes this very easy: [% wepage_title | html %] Not only will this allow your variables to contain things like "&" and "<" without problems, but it will also protect you against XSS attacks. -- Michael Peters Developer Plus Three, LP From sigzero at gmail.com Tue Jan 1 21:11:20 2008 From: sigzero at gmail.com (Robert Hicks) Date: Tue Jan 1 21:11:42 2008 Subject: [cgiapp] Re: Nothing fancy but IE chokes? In-Reply-To: <477AC36E.9090806@plusthree.com> References: <000b01c84cb9$afc3bac0$6401a8c0@kezmegahome> <477AC36E.9090806@plusthree.com> Message-ID: Michael Peters wrote: > Robert Hicks wrote: >> You are right *but* the code for that comes from: >> >> [% webpage_title %] > > This probably isn't your problem, but all input that goes in your templates > should be HTML escaped unless you know it has been earlier. TT makes this very easy: > > [% wepage_title | html %] > > Not only will this allow your variables to contain things like "&" and "<" > without problems, but it will also protect you against XSS attacks. > Thanks for the tip! Robert From adam at spatialsystems.org Tue Jan 1 21:59:58 2008 From: adam at spatialsystems.org (adam@spatialsystems.org) Date: Tue Jan 1 22:00:00 2008 Subject: [cgiapp] Adding Footer to Output Message-ID: <20080101195958.292eb6c930850de810cf35869bff7bc4.bab4342a59.wbe@email.secureserver.net> I'm adding a footer and I'm using HTML::Template. I'll be including a generic footer using TMPL_INCLUDE and pass the current year to the included footer for the copyright date. What's the best way to send this info without having to explicitly sending a TMPL_VAR for the year each time? I'd like this to be automatic. Thanks, Adam From mpeters at plusthree.com Wed Jan 2 09:22:31 2008 From: mpeters at plusthree.com (Michael Peters) Date: Wed Jan 2 09:23:46 2008 Subject: [cgiapp] Adding Footer to Output In-Reply-To: <20080101195958.292eb6c930850de810cf35869bff7bc4.bab4342a59.wbe@email.secureserver.net> References: <20080101195958.292eb6c930850de810cf35869bff7bc4.bab4342a59.wbe@email.secureserver.net> Message-ID: <477B9E27.8020404@plusthree.com> adam@spatialsystems.org wrote: > I'm adding a footer and I'm using HTML::Template. I'll be including a generic > footer using TMPL_INCLUDE and pass the current year to the included footer for the > copyright date. Just saying something is copyrighted doesn't make it so :) > What's the best way to send this info without having to explicitly sending a > TMPL_VAR for the year each time? I'd like this to be automatic. There's no way to do this "automatically" using H::T. You can't run code in H::T templates, just put markup around variables that you explicitly pass in. -- Michael Peters Developer Plus Three, LP From perl at rhesa.com Wed Jan 2 09:52:14 2008 From: perl at rhesa.com (Rhesa Rozendaal) Date: Wed Jan 2 09:52:22 2008 Subject: [cgiapp] Adding Footer to Output In-Reply-To: <20080101195958.292eb6c930850de810cf35869bff7bc4.bab4342a59.wbe@email.secureserver.net> References: <20080101195958.292eb6c930850de810cf35869bff7bc4.bab4342a59.wbe@email.secureserver.net> Message-ID: <477BA51E.3080505@rhesa.com> adam@spatialsystems.org wrote: > I'm adding a footer and I'm using HTML::Template. I'll be including a generic footer using TMPL_INCLUDE and pass the current year to the included footer for the copyright date. > > What's the best way to send this info without having to explicitly sending a TMPL_VAR for the year each time? I'd like this to be automatic. You can do this with a callback to 'load_tmpl': sub my_load_tmpl_callback { my ($self, $ht_params, $tmpl_params, $tmpl_file) = @_; $tmpl_params->{YEAR} ||= current_year(); } Setting up the callback can be done at several points, but I'd suggest doing it inside setup() for simplicity: sub setup { my $self = shift; # other setup stuff # ... # set default params $self->add_callback('load_tmpl',\&my_load_tmpl_callback); } Refer to the CGI::Application docs for more information on callbacks. HTH, Rhesa From karen.cravens at gmail.com Wed Jan 2 10:27:38 2008 From: karen.cravens at gmail.com (Karen) Date: Wed Jan 2 10:27:41 2008 Subject: [cgiapp] Adding Footer to Output In-Reply-To: <477B9E27.8020404@plusthree.com> References: <20080101195958.292eb6c930850de810cf35869bff7bc4.bab4342a59.wbe@email.secureserver.net> <477B9E27.8020404@plusthree.com> Message-ID: <7cc7c1ce0801020727t68e94072wc65f0d0ae66ce9c9@mail.gmail.com> On 1/2/08, Michael Peters wrote: > Just saying something is copyrighted doesn't make it so :) Continuously moving the copyright date is a pet peeve of mine, too. Things are copyrighted when they're first committed to fixed form. You don't get to keep moving the copyright date unless you make substantial changes, and even then the original version still keeps the older copyright date. If you want permanent copyright, you have to do it the honest way, like Disney, and get Congress to keep extending the term indefinitely. From mpeters at plusthree.com Wed Jan 2 10:29:07 2008 From: mpeters at plusthree.com (Michael Peters) Date: Wed Jan 2 10:30:21 2008 Subject: [cgiapp] Adding Footer to Output In-Reply-To: <7cc7c1ce0801020727t68e94072wc65f0d0ae66ce9c9@mail.gmail.com> References: <20080101195958.292eb6c930850de810cf35869bff7bc4.bab4342a59.wbe@email.secureserver.net> <477B9E27.8020404@plusthree.com> <7cc7c1ce0801020727t68e94072wc65f0d0ae66ce9c9@mail.gmail.com> Message-ID: <477BADC3.60305@plusthree.com> Karen wrote: > If you want permanent copyright, you have to do it the honest way, > like Disney, and get Congress to keep extending the term indefinitely. I have to say that this made my day :) Although I'd probably =~ s/get/bribe/ -- Michael Peters Developer Plus Three, LP From karen.cravens at gmail.com Wed Jan 2 10:51:52 2008 From: karen.cravens at gmail.com (Karen) Date: Wed Jan 2 10:51:55 2008 Subject: [cgiapp] Adding Footer to Output In-Reply-To: <477BADC3.60305@plusthree.com> References: <20080101195958.292eb6c930850de810cf35869bff7bc4.bab4342a59.wbe@email.secureserver.net> <477B9E27.8020404@plusthree.com> <7cc7c1ce0801020727t68e94072wc65f0d0ae66ce9c9@mail.gmail.com> <477BADC3.60305@plusthree.com> Message-ID: <7cc7c1ce0801020751t2d9b9ec3k292876e958cb0345@mail.gmail.com> On 1/2/08, Michael Peters wrote: > I have to say that this made my day :) Although I'd probably =~ s/get/bribe/ Heh. I opted to keep the level at "snark" and not "actionable." Soapboxing aside, I suspect that the usual reason for updates is either a simple misunderstanding of the notice's meaning (just because something was copyrighted last year doesn't mean it's expired this year) or technical issues (we don't know exactly when the particular bit of content was created, so we give the whole site the date of the newest content). I don't like the latter, as it dilutes the notices to where I would expect a judge to deny you statutory damages, i.e. same as when you don't have a properly-formatted notice at all. I'd rather be up-front about it and put a generic notice without a year. It doesn't qualify for statutory damages either, but they seem unlikely anyway. Were it a site statutory damages were a realistic possibility, I'd care enough to track the correct date for every bit of content, and then I'd be explicitly setting a TMPL_VAR. From geconomou at gmail.com Wed Jan 2 11:06:46 2008 From: geconomou at gmail.com (Giannis Economou) Date: Wed Jan 2 11:07:01 2008 Subject: [cgiapp] Bug-Problem with CGI.pm, fcgid, CGI::Application and utf-8? Message-ID: <477BB696.8060304@gmail.com> Hello, I'm writing to report a nasty situation/bug I'm facing. It is quite strange to me, I can not find out which component might be fully responsible (maybe just CGI.pm or the combination of C::A and CGI.pm) and I gave some hours to isolate the situation as much as possible and reproduce it. Maybe someone is also interest or can help. I explain and afterwards I send you some sample code you can try. I have some applications written, now in production installation, using C::A. They are different apps, using many CGI::App modules and C::A Plugins and they show output (html) in utf-8. Among other they also use TT2, but this is also irrelevant to the problem. All started when I accidentally found out that when cookies are disabled (in firefox or ie) then web pages do not display the utf-8 correctly, but when cookies are enabled, everything is displayed correctly! I've managed to isolate the problem (as you can guess I started being suspicious with many modules in the way before stripping everything in a new test case). It happens only with: - C::A applications (simple cgi script are not having the problem) - running on my server (Linux, Apache/2.0.52, Perl v5.8.5), I haven't tried other servers, but I guess it will be also have the problem - only when run under fcgid acceleration (plain cgi execution has consistent behavior), I also tried the latest fcgid module on my Apache no luck - only when using CGI.pm (with CGI::Simple this problem is not happening, utf-8 is always displayed right) - my CGI.pm is version 3.31. It is frustrating, mostly because I was really happy with fcgid as acceleration of my apps until today. Now I had to switch to plain cgi again. Here is a sample source that demonstrates and reproduce the problem, using the bare/minimal modules to reproduce it: ############### (instance.fcgi) ############### #!/usr/bin/perl use CGI::Fast; use WebApp; while (new CGI::Fast) { my $self = WebApp->new(); $self->run(); } ############### (WebApp.pm) ############### package WebApp; use base 'CGI::Application'; sub setup { my $self = shift; $self->start_mode('test'); $self->mode_param('rm'); $self->run_modes( 'test' => 'show_test', ); $self->header_add( -charset => 'utf-8' ); } sub show_test { my $self = shift; my $cookie = $self->query->cookie(-name=>'test', -value=>'foo'); $self->header_add(-cookie=>$cookie); #set the cookie return "Hello ... ????????!"; #this is 'Good morning' in Greek, file is saved as utf-8 } 1; Now: - when you run the instance.fcgi as fcgid script, cookie is set and in browser you get garbage in the Greek text (encoding is correctly set in browser). - when you run the instance.fcgi as plain cgi script, everything is fine - when you comment the cookie setting line in WebApp.pm, everything is working fine, regardless of fcgid or plain cgi. - when you use CGI::Simple instead of CGI.pm (for example use a CGI::Simple object instead of $self->query which is a CGI.pm in the example above to create the cookie), everything is working fine (fcgi / plain cgi, set cookie / do not set cookie, everything is fine). Here is the output of CGI::Application, as sent in browser, but as unicode codes: Correct: Hello ... \xce\x9a\xce\xb1\xce\xbb\xce\xb7\xce\xbc\xce\xad\xcf\x81\xce\xb1! Erroneous: Hello ... \xc3\x8e\xc2\x9a\xc3\x8e\xc2\xb1\xc3\x8e\xc2\xbb\xc3\x8e\xc2\xb7\xc3\x8e\xc2\xbc\xc3\x8e\xc2\xad\xc3\x8f\xc2\x81\xc3\x8e\xc2\xb1! Best regards, Giannis Economou From adam at spatialsystems.org Wed Jan 2 11:57:35 2008 From: adam at spatialsystems.org (adam@spatialsystems.org) Date: Wed Jan 2 11:57:37 2008 Subject: [cgiapp] Adding Footer to Output Message-ID: <20080102095735.292eb6c930850de810cf35869bff7bc4.cf570f66a7.wbe@email.secureserver.net> I know it really doesn't matter. This is more of an exercise of leaning CGI::Application, plus I know it will come in useful. Thanks for everyones help, I'll try the callback. -------------------------------------------------------------------- On 1/2/08, Karen wrote: >Soapboxing aside, I suspect that the usual reason for updates is >either a simple misunderstanding of the notice's meaning (just because >something was copyrighted last year doesn't mean it's expired this >year) or technical issues (we don't know exactly when the particular >bit of content was created, so we give the whole site the date of the >newest content). From ron at savage.net.au Wed Jan 2 17:21:18 2008 From: ron at savage.net.au (Ron Savage) Date: Wed Jan 2 17:20:50 2008 Subject: [cgiapp] Adding Footer to Output In-Reply-To: <7cc7c1ce0801020727t68e94072wc65f0d0ae66ce9c9@mail.gmail.com> References: <20080101195958.292eb6c930850de810cf35869bff7bc4.bab4342a59.wbe@email.secureserver.net> <477B9E27.8020404@plusthree.com> <7cc7c1ce0801020727t68e94072wc65f0d0ae66ce9c9@mail.gmail.com> Message-ID: <1199312478.4553.5.camel@zoe.savage.net.au> On Wed, 2008-01-02 at 09:27 -0600, Karen wrote: Hi Karen > If you want permanent copyright, you have to do it the honest way, > like Disney, and get Congress to keep extending the term indefinitely. Ah, yes. The American Way. Note also that the 3-character symbol (C) is not a copyright symbol in some countries, e.g. Australia. This raises the intriguing question of why IBM refused to put the copyright symbol in the original PC's character set... -- Ron Savage ron@savage.net.au http://savage.net.au/index.html From ron at savage.net.au Wed Jan 2 18:21:28 2008 From: ron at savage.net.au (Ron Savage) Date: Wed Jan 2 18:20:58 2008 Subject: [cgiapp] Bug-Problem with CGI.pm, fcgid, CGI::Application and utf-8? In-Reply-To: <477BB696.8060304@gmail.com> References: <477BB696.8060304@gmail.com> Message-ID: <1199316088.4553.15.camel@zoe.savage.net.au> On Wed, 2008-01-02 at 18:06 +0200, Giannis Economou wrote: Hi Giannis Debian and Apache/2.2.6 (Unix) mod_fastcgi/2.4.6 mod_perl/2.0.3 Perl/v5.8.8 here. > Now: > - when you run the instance.fcgi as fcgid script, cookie is set and in > browser you get garbage in the Greek text (encoding is correctly set in > browser). Same here. > - when you run the instance.fcgi as plain cgi script, everything is fine Same here. > - when you comment the cookie setting line in WebApp.pm, everything is > working fine, regardless of fcgid or plain cgi. Same here. > - when you use CGI::Simple instead of CGI.pm (for example use a > CGI::Simple object instead of $self->query which is a CGI.pm in the > example above to create the cookie), everything is working fine (fcgi / > plain cgi, set cookie / do not set cookie, everything is fine). Same here. > Here is the output of CGI::Application, as sent in browser, but as > unicode codes: > Correct: > Hello ... \xce\x9a\xce\xb1\xce\xbb\xce\xb7\xce\xbc\xce\xad\xcf\x81\xce\xb1! > > Erroneous: > Hello ... > \xc3\x8e\xc2\x9a\xc3\x8e\xc2\xb1\xc3\x8e\xc2\xbb\xc3\x8e\xc2\xb7\xc3\x8e\xc2\xbc\xc3\x8e\xc2\xad\xc3\x8f\xc2\x81\xc3\x8e\xc2\xb1! I'd try double-encoding the correct text and/or double-decoding the incorrect text. Perhaps that will tell you something. -- Ron Savage ron@savage.net.au http://savage.net.au/index.html From karen.cravens at gmail.com Thu Jan 3 00:18:38 2008 From: karen.cravens at gmail.com (Karen) Date: Thu Jan 3 00:18:43 2008 Subject: [cgiapp] Adding Footer to Output In-Reply-To: <1199312478.4553.5.camel@zoe.savage.net.au> References: <20080101195958.292eb6c930850de810cf35869bff7bc4.bab4342a59.wbe@email.secureserver.net> <477B9E27.8020404@plusthree.com> <7cc7c1ce0801020727t68e94072wc65f0d0ae66ce9c9@mail.gmail.com> <1199312478.4553.5.camel@zoe.savage.net.au> Message-ID: <7cc7c1ce0801022118x2a289ef8jd1c83204d19ebd30@mail.gmail.com> On 1/2/08, Ron Savage wrote: > Note also that the 3-character symbol (C) is not a copyright symbol in > some countries, e.g. Australia. The US, as well. "Copr." is the shortest legal way to represent it here if you can't do a proper circled-C. From dan.horne at redbone.co.nz Thu Jan 3 04:44:17 2008 From: dan.horne at redbone.co.nz (Dan Horne) Date: Thu Jan 3 04:43:04 2008 Subject: [cgiapp] Adding Footer to Output In-Reply-To: <477B9E27.8020404@plusthree.com> References: <20080101195958.292eb6c930850de810cf35869bff7bc4.bab4342a59.wbe@email.secureserver.net> <477B9E27.8020404@plusthree.com> Message-ID: <477CAE71.7070303@redbone.co.nz> Michael Peters wrote: > Just saying something is copyrighted doesn't make it so :) > Er, assuming you're that actual author, why not? From mpeters at plusthree.com Thu Jan 3 08:10:01 2008 From: mpeters at plusthree.com (Michael Peters) Date: Thu Jan 3 09:49:59 2008 Subject: [cgiapp] Adding Footer to Output In-Reply-To: <477CAE71.7070303@redbone.co.nz> References: <20080101195958.292eb6c930850de810cf35869bff7bc4.bab4342a59.wbe@email.secureserver.net> <477B9E27.8020404@plusthree.com> <477CAE71.7070303@redbone.co.nz> Message-ID: <477CDEA9.7050904@plusthree.com> Dan Horne wrote: > Michael Peters wrote: >> Just saying something is copyrighted doesn't make it so :) >> > Er, assuming you're that actual author, why not? I'm not a lawyer (would I be hanging out here if I was :) and it has been some years since my last copyright law class at the university (so please correct me if I'm wrong) but here goes... Actual copyright registration means something different then the automatic copyright rights provided by the Berne Convention (which basically took effect in 1989 in the US). Putting a "(C) 2008" on something is supposed to mean that you've officially registered the copyright with the appropriate government office. And then the year is the year the work was completed. If it's something that you wrote in 2007 it's misleading (and probably "wrong" in some way) to say "(C) 2008". In fact, lying about the copyright date on something you wrote could probably lose you some points with a judge if you actually have to go to court. Since some copyright protections are automatic the reason you register is to make it easier to enforce monetary damages. Putting "(C) 2008" one something does not give you any extra legal protection or enforcement possibilities, so why do it? -- Michael Peters Developer Plus Three, LP From karen.cravens at gmail.com Thu Jan 3 19:17:51 2008 From: karen.cravens at gmail.com (Karen) Date: Thu Jan 3 19:17:53 2008 Subject: [cgiapp] Adding Footer to Output In-Reply-To: <477CAE71.7070303@redbone.co.nz> References: <20080101195958.292eb6c930850de810cf35869bff7bc4.bab4342a59.wbe@email.secureserver.net> <477B9E27.8020404@plusthree.com> <477CAE71.7070303@redbone.co.nz> Message-ID: <7cc7c1ce0801031617w50038c6bg41114751db09dbeb@mail.gmail.com> On 1/3/08, Dan Horne wrote: > Michael Peters wrote: > > Just saying something is copyrighted doesn't make it so :) > > > Er, assuming you're that actual author, why not? (Under US law, and I think all the Berne signatories, as I understand them. YMMV.) Something is copyrighted the moment it's put into fixed form. The copyright notice only entitles you to seek statutory (I think) damages, presumeably on the principle that the infringer *really* should have known better. But the notice has to be in a specific format: "Copyright YYYY Copyright Holder's Name," where you can abbreviate it to "Copr." or use the (fully) circled-C symbol. In 2008, you don't update all your 2007 copyright notices... the 2007 ones are good indefinitely. (Technically, there's a limit. The US Constitution mandates one. But Congress keeps bumping the limit further out, which somehow doesn't count as being unlimited. But in Internet time, it's forever for all practical purposes.) If you keep updating your copyright notices, I imagine there are judges who would throw them out for purposes of damages. If you don't intend to seek damages, of course, you don't have to worry about getting the exact legality right - you're just trying to remind people that the copyright is there, since there are a lot of people who still assume that if it doesn't say otherwise, it's public domain. For that, you'd probably be better served with an undated copyright notice, and then a "last updated" with that year in it, though. (I am not a lawyer, I just have worked in several fields that involve copyright and accordingly have read a lot of lawyers' interpretations for laymen.) From stefan.petrea at gmail.com Sat Jan 5 14:19:36 2008 From: stefan.petrea at gmail.com (Stefan Petrea) Date: Sun Jan 6 00:18:51 2008 Subject: [cgiapp] headers problem Message-ID: <200801052119.36944.stefan.petrea@gmail.com> Hi, I'm very new to CGI::Application I'm using this example here http://www.redantigua.com/cgi-application1.html for learning how to use CGI::Application. I get 500 every time I run helloworld.cgi-app.pl What can I do about this ? It just seems that the pl is not sending any headers. How can I solve this problem ? thank you From adam at spatialsystems.org Sun Jan 6 01:24:19 2008 From: adam at spatialsystems.org (adam@spatialsystems.org) Date: Sun Jan 6 01:24:22 2008 Subject: [cgiapp] headers problem Message-ID: <20080105232419.292eb6c930850de810cf35869bff7bc4.f2423a4d45.wbe@email.secureserver.net> I'm very new at CGI::Application too, but I'd say make sure you have CGI::Application and HTML::Template installed. Try using "CGI::Carp qw( fatalsToBrowser )" and try invoking the application from your shell and see what happens. Maybe you're getting some kind of error. -------- Original Message -------- Subject: [cgiapp] headers problem From: Stefan Petrea Date: Sat, January 05, 2008 1:19 pm To: cgiapp@lists.erlbaum.net Hi, I'm very new to CGI::Application I'm using this example here http://www.redantigua.com/cgi-application1.html for learning how to use CGI::Application. I get 500 every time I run helloworld.cgi-app.pl What can I do about this ? It just seems that the pl is not sending any headers. How can I solve this problem ? thank you ##### CGI::Application community mailing list ################ ## ## ## To unsubscribe, or change your message delivery options, ## ## visit: http://www.erlbaum.net/mailman/listinfo/cgiapp ## ## ## ## Web archive: http://www.erlbaum.net/pipermail/cgiapp/ ## ## Wiki: http://cgiapp.erlbaum.net/ ## ## ## ################################################################ From ron at savage.net.au Sun Jan 6 01:26:48 2008 From: ron at savage.net.au (Ron Savage) Date: Sun Jan 6 01:26:16 2008 Subject: *****SPAM***** [cgiapp] headers problem In-Reply-To: <200801052119.36944.stefan.petrea@gmail.com> References: <200801052119.36944.stefan.petrea@gmail.com> Message-ID: <1199600808.4517.9.camel@zoe.savage.net.au> On Sat, 2008-01-05 at 21:19 +0200, Stefan Petrea wrote: Hi Stefan > I'm very new to CGI::Application Welcome to the club! > I'm using this example here http://www.redantigua.com/cgi-application1.html for > learning how to use CGI::Application. > I get 500 every time I run helloworld.cgi-app.pl > What can I do about this ? > It just seems that the pl is not sending any headers. > How can I solve this problem ? Things to check: 1) Is the template in the same directory as the CGI script? It should be, because of this line (IMHO): $self->tmpl_path('./'); in the *.pm file 2) Are the permissions correct on /all/ 3 files? - CGI script - Template - *.pm -- Ron Savage ron@savage.net.au http://savage.net.au/index.html From stefan.petrea at gmail.com Sat Jan 5 15:30:59 2008 From: stefan.petrea at gmail.com (Stefan Petrea) Date: Sun Jan 6 01:30:14 2008 Subject: [cgiapp] headers problem In-Reply-To: <20080105232419.292eb6c930850de810cf35869bff7bc4.f2423a4d45.wbe@email.secureserver.net> References: <20080105232419.292eb6c930850de810cf35869bff7bc4.f2423a4d45.wbe@email.secureserver.net> Message-ID: <200801052230.59584.stefan.petrea@gmail.com> On Sunday 06 January 2008 08:24, adam@spatialsystems.org wrote: Hi, I've just tried "use CGI::Carp qw( fatalsToBrowser )" and nothing changed in the sense that from console it still works OK but from the browser I still get 500 > I'm very new at CGI::Application too, but I'd say make sure you have CGI::Application and HTML::Template installed. Try using "CGI::Carp qw( fatalsToBrowser )" and try invoking the application from your shell and see what happens. Maybe you're getting some kind of error. > > > > -------- Original Message -------- > Subject: [cgiapp] headers problem > From: Stefan Petrea > Date: Sat, January 05, 2008 1:19 pm > To: cgiapp@lists.erlbaum.net > > Hi, > > I'm very new to CGI::Application > I'm using this example here http://www.redantigua.com/cgi-application1.html for > learning how to use CGI::Application. > I get 500 every time I run helloworld.cgi-app.pl > What can I do about this ? > It just seems that the pl is not sending any headers. > How can I solve this problem ? > thank you > > ##### CGI::Application community mailing list ################ > ## ## > ## To unsubscribe, or change your message delivery options, ## > ## visit: http://www.erlbaum.net/mailman/listinfo/cgiapp ## > ## ## > ## Web archive: http://www.erlbaum.net/pipermail/cgiapp/ ## > ## Wiki: http://cgiapp.erlbaum.net/ ## > ## ## > ################################################################ > > > > > ##### CGI::Application community mailing list ################ > ## ## > ## To unsubscribe, or change your message delivery options, ## > ## visit: http://www.erlbaum.net/mailman/listinfo/cgiapp ## > ## ## > ## Web archive: http://www.erlbaum.net/pipermail/cgiapp/ ## > ## Wiki: http://cgiapp.erlbaum.net/ ## > ## ## > ################################################################ > > From stefan.petrea at gmail.com Sat Jan 5 16:11:21 2008 From: stefan.petrea at gmail.com (Stefan Petrea) Date: Sun Jan 6 02:10:33 2008 Subject: *****SPAM***** [cgiapp] headers problem In-Reply-To: <1199600808.4517.9.camel@zoe.savage.net.au> References: <200801052119.36944.stefan.petrea@gmail.com> <1199600808.4517.9.camel@zoe.savage.net.au> Message-ID: <200801052311.21135.stefan.petrea@gmail.com> On Sunday 06 January 2008 08:26, Ron Savage wrote: ok I just checked 1 and 2 you wrote and they are ok. I've modified httpd.conf so that it has Option +ExecCGI on the directory where the code is located. Now I get a long wait after wich I still get 500. > On Sat, 2008-01-05 at 21:19 +0200, Stefan Petrea wrote: > > Hi Stefan > > > I'm very new to CGI::Application > > Welcome to the club! > > > I'm using this example here http://www.redantigua.com/cgi-application1.html for > > learning how to use CGI::Application. > > I get 500 every time I run helloworld.cgi-app.pl > > What can I do about this ? > > It just seems that the pl is not sending any headers. > > How can I solve this problem ? > > Things to check: > > 1) Is the template in the same directory as the CGI script? It should > be, because of this line (IMHO): > $self->tmpl_path('./'); > in the *.pm file > > 2) Are the permissions correct on /all/ 3 files? > - CGI script > - Template > - *.pm From mpeters at plusthree.com Sun Jan 6 19:04:22 2008 From: mpeters at plusthree.com (Michael Peters) Date: Sun Jan 6 19:05:41 2008 Subject: *****SPAM***** [cgiapp] headers problem In-Reply-To: <200801052311.21135.stefan.petrea@gmail.com> References: <200801052119.36944.stefan.petrea@gmail.com> <1199600808.4517.9.camel@zoe.savage.net.au> <200801052311.21135.stefan.petrea@gmail.com> Message-ID: <47816C86.8050101@plusthree.com> Stefan Petrea wrote: > Now I get a long wait after wich I still get 500. Look at your server's error logs. Until you do nothing we tell you will be more than just a guess. The server's error log is one of your best friends for web development. -- Michael Peters Developer Plus Three, LP From adam at spatialsystems.org Mon Jan 7 17:39:01 2008 From: adam at spatialsystems.org (adam@spatialsystems.org) Date: Mon Jan 7 17:39:03 2008 Subject: [cgiapp] Saving Data From Authentication Phase Message-ID: <20080107153901.292eb6c930850de810cf35869bff7bc4.5e55c1a315.wbe@email.secureserver.net> I'm using CGI::Application::Plugin::Session and CGI::Application::Plugin::Authentication. With CGI::Application::Plugin::Authentication I'm using the Generic driver. I have an authentication object in my anonymous subroutine ref that I use for authentication with the Generic driver. The authentication object returns 0 or 1 if the username/password is valid or not. And I can also ask for the users info after the user is logged in and it returns a hashref. How can I save this hashref of user info and keep it in my Session for all requests where the user is logged in? Here is some of my code: sub setup { # setup authentication $self->authen->config( DRIVER => [ 'Generic', \&my_login ], STORE => 'Session', LOGIN_RUNMODE => 'login', POST_LOGIN_RUNMODE => 'main', LOGOUT_RUNMODE => 'login', ); } sub my_login { my ($username, $password) = @_; # connect to auth network my $ad_auth = MyCompany::ActiveDirectory->new('WINDOWS'); return 0 if not $ad_auth->login( $username, $password ); # how do I store this info in the hash ref so I always have it??? $users_hash_ref = $ad_auth->getUserInfo; retrun 1; } Thanks, Adam From adam at spatialsystems.org Mon Jan 7 21:47:28 2008 From: adam at spatialsystems.org (adam@spatialsystems.org) Date: Mon Jan 7 21:47:30 2008 Subject: [cgiapp] Saving Data From Authentication Phase Message-ID: <20080107194727.292eb6c930850de810cf35869bff7bc4.0969b57ff0.wbe@email.secureserver.net> I sent this 4 hours ago but didn't see it come back to me. Did this not get sent out by the mail server? I'm using CGI::Application::Plugin::Session and CGI::Application::Plugin::Authentication. With CGI::Application::Plugin::Authentication I'm using the Generic driver. I have an authentication object in my anonymous subroutine ref that I use for authentication with the Generic driver. The authentication object returns 0 or 1 if the username/password is valid or not. And I can also ask for the users info after the user is logged in and it returns a hashref. How can I save this hashref ( $users_hash_ref = $ad_auth->getUserInfo ) of user info and keep it in my Session for all requests where the user is logged in? Here is some of my code: sub setup { # setup authentication $self->authen->config( DRIVER => [ 'Generic', \&my_login ], STORE => 'Session', LOGIN_RUNMODE => 'login', POST_LOGIN_RUNMODE => 'main', LOGOUT_RUNMODE => 'login', ); } sub my_login { my ($username, $password) = @_; # connect to auth network my $ad_auth = MyCompany::ActiveDirectory->new('WINDOWS'); return 0 if not $ad_auth->login( $username, $password ); # how do I store this info in the hash ref so I always have it??? $users_hash_ref = $ad_auth->getUserInfo; retrun 1; } Thanks, Adam From adam at spatialsystems.org Mon Jan 7 22:39:59 2008 From: adam at spatialsystems.org (adam@spatialsystems.org) Date: Mon Jan 7 22:40:01 2008 Subject: [cgiapp] Saving Data From Authentication Phase Message-ID: <20080107203959.292eb6c930850de810cf35869bff7bc4.af2ca51e4f.wbe@email.secureserver.net> Messages don't seem to be getting through the mail list so I'm trying again. I'm using CGI::Application::Plugin::Session and CGI::Application::Plugin::Authentication. With CGI::Application::Plugin::Authentication I'm using the Generic driver. I have an authentication object in my anonymous subroutine ref that I use for authentication with the Generic driver. The authentication object returns 0 or 1 if the username/password is valid or not. And I can also ask for the users info after the user is logged in and it returns a hashref. How can I save this hashref of user info and keep it in my Session for all requests where the user is logged in? Here is some of my code: sub setup { # setup authentication $self->authen->config( DRIVER => [ 'Generic', \&my_login ], STORE => 'Session', LOGIN_RUNMODE => 'login', POST_LOGIN_RUNMODE => 'main', LOGOUT_RUNMODE => 'login', ); } sub my_login { my ($username, $password) = @_; # connect to auth network my $ad_auth = MyCompany::ActiveDirectory->new('WINDOWS'); return 0 if not $ad_auth->login( $username, $password ); # how do I store this info in the hash ref so I always have it??? $users_hash_ref = $ad_auth->getUserInfo; retrun 1; } Thanks, Adam From adam at spatialsystems.org Tue Jan 8 13:12:31 2008 From: adam at spatialsystems.org (adam@spatialsystems.org) Date: Tue Jan 8 13:12:36 2008 Subject: [cgiapp] Saving Data From Authentication Phase Message-ID: <20080108111231.292eb6c930850de810cf35869bff7bc4.5f249c9b2f.wbe@email.secureserver.net> I'm using CGI::Application::Plugin::Session and CGI::Application::Plugin::Authentication. With CGI::Application::Plugin::Authentication I'm using the Generic driver. I have an authentication object in my anonymous subroutine ref that I use for authentication with the Generic driver. The authentication object returns 0 or 1 if the username/password is valid or not. And I can also ask for the users info after the user is logged in and it returns a hashref. How can I save this hashref ( $users_hash_ref = $ad_auth->getUserInfo ) of user info and keep it in my Session for all requests where the user is logged in? Here is some of my code: sub setup { # setup authentication $self->authen->config( DRIVER => [ 'Generic', \&my_login ], STORE => 'Session', LOGIN_RUNMODE => 'login', POST_LOGIN_RUNMODE => 'main', LOGOUT_RUNMODE => 'login', ); } sub my_login { my ($username, $password) = @_; # connect to auth network my $ad_auth = MyCompany::ActiveDirectory->new('WINDOWS'); return 0 if not $ad_auth->login( $username, $password ); # how do I store this info in the hash ref so I always have it??? $users_hash_ref = $ad_auth->getUserInfo; retrun 1; } Thanks, Adam From perl at rhesa.com Tue Jan 8 13:42:59 2008 From: perl at rhesa.com (Rhesa Rozendaal) Date: Tue Jan 8 14:13:15 2008 Subject: [cgiapp] Saving Data From Authentication Phase In-Reply-To: <20080108111231.292eb6c930850de810cf35869bff7bc4.5f249c9b2f.wbe@email.secureserver.net> References: <20080108111231.292eb6c930850de810cf35869bff7bc4.5f249c9b2f.wbe@email.secureserver.net> Message-ID: <4783C433.6020608@rhesa.com> adam@spatialsystems.org wrote: > How can I save this hashref ( $users_hash_ref = $ad_auth->getUserInfo ) of user info and keep it in my Session for all requests where the user is logged in? Isn't that the usual: # store it inside &my_login $self->session->param( ad_auth_userinfo => $ad_auth->getUserInfo ); # use it elsewhere my $userinfo = $self->session->param( 'ad_auth_userinfo' ); > Here is some of my code: > > sub setup { > > # setup authentication > $self->authen->config( > DRIVER => [ 'Generic', \&my_login ], > STORE => 'Session', > LOGIN_RUNMODE => 'login', > POST_LOGIN_RUNMODE => 'main', > LOGOUT_RUNMODE => 'login', > ); > > } CAP::Authentication also has a authen->username method that you might be able to use. It won't have all your AD info, of course, but it might be enough for your application. HTH, Rhesa From cub.uanic at gmail.com Tue Jan 8 14:16:16 2008 From: cub.uanic at gmail.com (Oleg Kostyuk) Date: Tue Jan 8 14:16:19 2008 Subject: [cgiapp] Saving Data From Authentication Phase In-Reply-To: <20080107203959.292eb6c930850de810cf35869bff7bc4.af2ca51e4f.wbe@email.secureserver.net> References: <20080107203959.292eb6c930850de810cf35869bff7bc4.af2ca51e4f.wbe@email.secureserver.net> Message-ID: <60ef632f0801081116k237bb732n138a8c828c209440@mail.gmail.com> Hello > Messages don't seem to be getting through the mail list so I'm trying again. I can read your messages, so mail list seems to working fine. > I'm using CGI::Application::Plugin::Session and CGI::Application::Plugin::Authentication. With CGI::Application::Plugin::Authentication I'm using the Generic driver. [skipped] > How can I save this hashref of user info and keep it in my Session for all requests where the user is logged in? CGI::Application::Plugin::Session uses CGI::Session, so you should take look to it's documentation (http://search.cpan.org/perldoc?CGI::Session) - try to search "storing data in the session" and "retrieving data" in it. HTH -- Sincerely yours, Oleg Kostyuk (CUB-UANIC) From adam at spatialsystems.org Tue Jan 8 14:32:50 2008 From: adam at spatialsystems.org (adam@spatialsystems.org) Date: Tue Jan 8 14:32:52 2008 Subject: [cgiapp] Saving Data From Authentication Phase Message-ID: <20080108123250.292eb6c930850de810cf35869bff7bc4.15206429b9.wbe@email.secureserver.net> When I try that in the login coderef passed to the CGI::Application::Plugin::Authentication, I get an error about $self not being an explicit package name. They only thing that gets passed to the coderef is the username and password, not $self. I don't see a way to save the AD data to the session from within the \&my_login coderef. Is there a way to store this into the session without modifying CGI::Application::Plugin::Authorization::Driver::Generic to get $self into the auth coderef? sub setup { # setup authentication $self->authen->config( # here we send coderef \&my_login for login DRIVER => [ 'Generic', \&my_login ], STORE => 'Session', LOGIN_RUNMODE => 'login', POST_LOGIN_RUNMODE => 'main', LOGOUT_RUNMODE => 'login', ); } sub my_login { my ($username, $password) = @_; my $ad_auth = MyCompany::ActiveDirectory->new('WINDOWS'); return 0 if not $ad_auth->login( $username, $password ); # how do I store this info in the hash ref so I always have it??? $users_hash_ref = $ad_auth->getUserInfo; # if I try to store it here using the session, $self doesn't exist # and I don' see a way to get it to exist unless I modify # CGI::Application::Plugin::Authorization::Driver::Generic. # I'm wondering if there's a differnt way to do this without # modifying the driver # doesn't work, $self not here. #$self->session->param( ad_auth_userinfo => $ad_auth->getUserInfo ); return 1; } >-------- Original Message -------- >Subject: Re: [cgiapp] Saving Data From Authentication Phase >From: Rhesa Rozendaal >Date: Tue, January 08, 2008 12:42 pm >To: CGI Application > >adam@spatialsystems.org wrote: >> How can I save this hashref ( $users_hash_ref = $ad_auth->getUserInfo ) of user info and keep it in my Session for all requests where the user is logged in? > >Isn't that the usual: > ># store it inside &my_login >$self->session->param( ad_auth_userinfo => $ad_auth->getUserInfo ); > ># use it elsewhere >my $userinfo = $self->session->param( 'ad_auth_userinfo' ); > > >> Here is some of my code: >> >> sub setup { >> >> # setup authentication >> $self->authen->config( >> DRIVER => [ 'Generic', \&my_login ], >> STORE => 'Session', >> LOGIN_RUNMODE => 'login', >> POST_LOGIN_RUNMODE => 'main', >> LOGOUT_RUNMODE => 'login', >> ); >> >> } > >CAP::Authentication also has a authen->username method that you might be able >to use. It won't have all your AD info, of course, but it might be enough for >your application. > >HTH, >Rhesa > From adam at spatialsystems.org Tue Jan 8 14:45:35 2008 From: adam at spatialsystems.org (adam@spatialsystems.org) Date: Tue Jan 8 14:46:01 2008 Subject: [cgiapp] Saving Data From Authentication Phase Message-ID: <20080108124535.292eb6c930850de810cf35869bff7bc4.7a931d742d.wbe@email.secureserver.net> I figured it out. My subroutine needed to be declared in my setup. It was being declared in the Webapp namespace and not the Webapp::setup namespace. That's why $self wasn't available for storing it into the session. Thanks, Adam >-------- Original Message -------- >Subject: Re: [cgiapp] Saving Data From Authentication Phase >From: Rhesa Rozendaal >Date: Tue, January 08, 2008 12:42 pm >To: CGI Application > >adam@spatialsystems.org wrote: >> How can I save this hashref ( $users_hash_ref = $ad_auth->getUserInfo ) of user info and keep it in my Session for all requests where the user is logged in? > >Isn't that the usual: > ># store it inside &my_login >$self->session->param( ad_auth_userinfo => $ad_auth->getUserInfo ); > ># use it elsewhere >my $userinfo = $self->session->param( 'ad_auth_userinfo' ); > > >> Here is some of my code: >> >> sub setup { >> >> # setup authentication >> $self->authen->config( >> DRIVER => [ 'Generic', \&my_login ], >> STORE => 'Session', >> LOGIN_RUNMODE => 'login', >> POST_LOGIN_RUNMODE => 'main', >> LOGOUT_RUNMODE => 'login', >> ); >> >> } > >CAP::Authentication also has a authen->username method that you might be able >to use. It won't have all your AD info, of course, but it might be enough for >your application. > >HTH, >Rhesa > ##### CGI::Application community mailing list ################ ## ## ## To unsubscribe, or change your message delivery options, ## ## visit: http://www.erlbaum.net/mailman/listinfo/cgiapp ## ## ## ## Web archive: http://www.erlbaum.net/pipermail/cgiapp/ ## ## Wiki: http://cgiapp.erlbaum.net/ ## ## ## ################################################################ From perl at rhesa.com Tue Jan 8 14:49:19 2008 From: perl at rhesa.com (Rhesa Rozendaal) Date: Tue Jan 8 15:36:33 2008 Subject: [cgiapp] Saving Data From Authentication Phase In-Reply-To: <20080108123250.292eb6c930850de810cf35869bff7bc4.15206429b9.wbe@email.secureserver.net> References: <20080108123250.292eb6c930850de810cf35869bff7bc4.15206429b9.wbe@email.secureserver.net> Message-ID: <4783D3BF.10802@rhesa.com> adam@spatialsystems.org wrote: > When I try that in the login coderef passed to the CGI::Application::Plugin::Authentication, I get an error about $self not being an explicit package name. They only thing that gets passed to the coderef is the username and password, not $self. I don't see a way to save the AD data to the session from within the \&my_login coderef. D'oh! I completely missed that, you're right. > Is there a way to store this into the session without modifying CGI::Application::Plugin::Authorization::Driver::Generic to get $self into the auth coderef? You could wrap &mylogin in a closure: > sub setup { > > # setup authentication > $self->authen->config( > > # here we send coderef \&my_login for login > DRIVER => [ 'Generic', \&my_login ], DRIVER => [ 'Generic', sub { return $self->my_login( @_ ) } ], > STORE => 'Session', > LOGIN_RUNMODE => 'login', > POST_LOGIN_RUNMODE => 'main', > LOGOUT_RUNMODE => 'login', > ); > > } > > sub my_login { my $self = shift; > my ($username, $password) = @_; > > my $ad_auth = MyCompany::ActiveDirectory->new('WINDOWS'); > > return 0 if not $ad_auth->login( $username, $password ); > > # how do I store this info in the hash ref so I always have it??? > $users_hash_ref = $ad_auth->getUserInfo; > $self->session->param( ad_auth_userinfo => $users_hash_ref ); > > return 1; > > } > From ron at savage.net.au Tue Jan 8 20:40:30 2008 From: ron at savage.net.au (Ron Savage) Date: Tue Jan 8 20:39:57 2008 Subject: [cgiapp] [OT] Seeking software Message-ID: <1199842830.4545.14.camel@zoe.savage.net.au> Hi Folks I'm doing some voluntary work for a community group who have 2 requirements: o A contacts (e.g. suppliers) manager. Simple, really o A clients manager. This is complex, with clients getting govt benefits, housing, etc. So the software has to manage case notes, family relationships, etc. Any suggestions welcome. -- Ron Savage ron@savage.net.au http://savage.net.au/index.html From dan.horne at redbone.co.nz Tue Jan 8 21:08:52 2008 From: dan.horne at redbone.co.nz (Dan Horne) Date: Tue Jan 8 21:08:56 2008 Subject: [cgiapp] [OT] Seeking software In-Reply-To: <1199842830.4545.14.camel@zoe.savage.net.au> References: <1199842830.4545.14.camel@zoe.savage.net.au> Message-ID: <17932.210.54.245.44.1199844532.squirrel@mail.redbone.co.nz> I'd look at SugarCRM. It works pretty well out of the box, but is also very customisable Ron Savage said: > Hi Folks > > I'm doing some voluntary work for a community group who have 2 > requirements: > > o A contacts (e.g. suppliers) manager. Simple, really > > o A clients manager. This is complex, with clients getting govt > benefits, housing, etc. So the software has to manage case notes, family > relationships, etc. > > Any suggestions welcome. > -- > Ron Savage > ron@savage.net.au > http://savage.net.au/index.html > > > > ##### CGI::Application community mailing list ################ > ## ## > ## To unsubscribe, or change your message delivery options, ## > ## visit: http://www.erlbaum.net/mailman/listinfo/cgiapp ## > ## ## > ## Web archive: http://www.erlbaum.net/pipermail/cgiapp/ ## > ## Wiki: http://cgiapp.erlbaum.net/ ## > ## ## > ################################################################ > > From adam at spatialsystems.org Fri Jan 11 02:22:15 2008 From: adam at spatialsystems.org (adam@spatialsystems.org) Date: Fri Jan 11 02:22:16 2008 Subject: [cgiapp] How to integrate a module ? Message-ID: <20080111002215.292eb6c930850de810cf35869bff7bc4.5fc70de8f9.wbe@email.secureserver.net> SUMMARY: How should I integrate my OO module with CGI::Application? Need advice and direction. Details: Here is my first OO module ( Tools::User ) that administers users on my system. Creates a user object populated with user info from DB: my $user = Tools::User->new( $user_id ); Get info for user stored in db: my $name = $user->name; Store info into object and save to db: $user->name( $new_name ); Check if a user exists: Tools::User->exists( $user_id ) or die "User $user_id doesn't exist"; Create new user and return object for user: my $user = Tools::User->insert({ id => 007, name => Bond }); QUESTION: How should I integrate this with CGI::Application and CGI::Application::Plugin::Authentication? IMPLEMENTATION: When a user logs in, Plugin::Authentication stores the User_Id in the session. I'd like to take that User_Id and run it in Tools::User->exists( $user_id ) and if it comes back false, then redirect to a registration page where the user will get created on my system. If the user already exists in my DB, then I want to load the info for them from my database and have my user object avail from $self->user in my CGI::Application. I'd like functionality similar to: package Tools::Avail::WebApp; use strict; use base qw( CGI::Application); use CGI::Application::Plugin::Session; use CGI::Application::Plugin::Forward; use CGI::Application::Plugin::Authentication; use My::ActiveDirectory; sub setup { my $self = shift; $self->start_mode('login'); $self->mode_param('rm'); $self->run_modes( 'login' => 'show_login', 'main' => 'show_main', 'register' => 'show_register', ); # setup authentication $self->authen->config( DRIVER => [ 'Generic', \&login ], STORE => 'Session', LOGIN_RUNMODE => 'login', POST_LOGIN_RUNMODE => 'main', LOGOUT_RUNMODE => 'login', ); $self->authen->protected_runmodes( 'main' ); sub login { my ( $username, $password ) = @_; my $ad_auth = My::ActiveDirectory->new('WIN'); return 0 if not $ad_auth->login( $username, $password ); $self->session->param( ad_auth_userinfo => $ad_auth->getUserInfo ); ######################################################################### # # # if we've never seen the user before, redirect them to register # # # # if they are already in the DB, then load their data with # # Tools::User object that will be accessable everywhere via # # $self->user # # # ######################################################################### Tools::User->exists( %{ $self->session->param('ad_auth_userinfo') }->{user_id} } ) or $self->forward('register'); return $username; } } sub show_main { my $self = shift; ######################################################################### # # # retrieve user info, update user info, add user via class method # # from Tools::Users, how do I implement this functionality? # # # ######################################################################### # retrieve user info my $name = $self->users->name # update user info $self->user->name('New_Name'); # class method to see if user exists $self->user->exists( $user_id ) or die "user doesn't exist"; # create new user and get it's object, don't know if this is necessary for me to do. my $new_user_object = $self->user->insert({ id => 007, name => Bond }); } From adam at spatialsystems.org Fri Jan 11 12:46:09 2008 From: adam at spatialsystems.org (adam@spatialsystems.org) Date: Fri Jan 11 12:46:53 2008 Subject: [cgiapp] How to integrate a module? Message-ID: <20080111104609.292eb6c930850de810cf35869bff7bc4.9b68764a01.wbe@email.secureserver.net> SUMMARY: How should I integrate my OO module with CGI::Applcaiton? Details: Here is my first OO module ( Tools::User ) that administers users on my system. Create a user object populated with user info from DB: my $user = Tools::User->new( $user_id ); Get info for user stored in db: my $name = $user->name; Store info into object and save to db: $user->name( $new_name ); Check if a user exists: Tools::User->exists( $user_id ) or die "User $user_id doesn't exist"; Create new user and return object for user: my $user = Tools::User->insert({ id => 007, name => Bond }); QUESION: How should I integrate this with CGI::Application and CGI::Application::Plugin::Authentication? IMPLEMENTATION: When a user logs in, Plugin::Authentication stores the User_Id in the session. I'd like to take that User_Id and run it in Tools::User->exists( $user_id ) and if it comes back false, then redirect to a registration page where the user will get created on my system. If the user already exists in my DB, then I want to load the info for them from my database and have my user object avail from $self->user in my CGI::Application. I'd like functionality similar to: package VzTools::CellAvail::WebApp; use strict; use base qw( CGI::Application); use CGI::Application::Plugin::Session; use CGI::Application::Plugin::Forward; use CGI::Application::Plugin::Authentication; use My::ActiveDirectory; sub setup { my $self = shift; $self->start_mode('login'); $self->mode_param('rm'); $self->run_modes( 'login' => 'show_login', 'main' => 'show_main', 'register' => 'show_register', ); # setup authentication $self->authen->config( DRIVER => [ 'Generic', \&login ], STORE => 'Session', LOGIN_RUNMODE => 'login', POST_LOGIN_RUNMODE => 'main', LOGOUT_RUNMODE => 'login', ); $self->authen->protected_runmodes( 'main' ); $self->tmpl_path('templates'); $self->add_callback( 'load_tmpl', \&load_template_callback ); sub login { my ( $username, $password ) = @_; my $ad_auth = My::ActiveDirectory->new('WIN'); return 0 if not $ad_auth->login( $username, $password ); $self->session->param( ad_auth_userinfo => $ad_auth->getUserInfo ); ######################################################################### # # # if we've never seen the user before, redirect them to register # # # # if they are already in the DB, then load their data with # # Tools::User object that will be accessable everywhere via # # $self->user # # # ######################################################################### Tools::User->exists( %{ $self->session->param('ad_auth_userinfo') }->{user_id} } ) or $self->forward('register'); return $username; } } sub show_main { my $self = shift; ######################################################################### # # # retrieve user info, update user info, add user via class method # # from Tools::Users # # # ######################################################################### # retrieve user info my $name = $self->users->name # update user info $self->user->name('New_Name'); # class method to see if user exists $self->user->exists( $user_id ) or die "user doesn't exist"; # create new user and get it's object, dont't know if this is necessary for me to do. my $new_user_object = $self->user->insert({ id => 007, name => Bond }); } From adam at spatialsystems.org Fri Jan 11 12:27:01 2008 From: adam at spatialsystems.org (adam@spatialsystems.org) Date: Fri Jan 11 12:53:44 2008 Subject: [cgiapp] How to integrate a module? Message-ID: <20080111102701.292eb6c930850de810cf35869bff7bc4.0b7270a5b4.wbe@email.secureserver.net> SUMMARY: How should I integrate my OO module with CGI::Applcaiton? Details: Here is my first OO module ( Tools::Users ) that administers users on my system. Create a user object populated with user info from DB: my $user = Tools::User->new( $user_id ); Get info for user stored in db: my $name = $user->name; Store info into object and save to db: $user->name( $new_name ); Check if a user exists: Tools::User->exists( $user_id ) or die "User $user_id doesn't exist"; Create new user and return object for user: my $user = Tools::User->insert({ id => 007, name => Bond }); QUESION: How should I integrate this with CGI::Application and CGI::Application::Plugin::Authentication? IMPLEMENTATION: When a user logs in, Plugin::Authentication stores the User_Id in the session. I'd like to take that User_Id and run it in Tools::User->exists( $user_id ) and if it comes back false, then redirect to a registration page where the user will get created on my system. If the user already exists in my DB, then I want to load the info for them from my database and have my user object avail from $self->user in my CGI::Application. I'd like functionality similar to: package VzTools::CellAvail::WebApp; use strict; use base qw( CGI::Application); use CGI::Application::Plugin::Session; use CGI::Application::Plugin::Forward; use CGI::Application::Plugin::Authentication; use My::ActiveDirectory; sub setup { my $self = shift; $self->start_mode('login'); $self->mode_param('rm'); $self->run_modes( 'login' => 'show_login', 'main' => 'show_main', 'register' => 'show_register', ); # setup authentication $self->authen->config( DRIVER => [ 'Generic', \&login ], STORE => 'Session', LOGIN_RUNMODE => 'login', POST_LOGIN_RUNMODE => 'main', LOGOUT_RUNMODE => 'login', ); $self->authen->protected_runmodes( 'main' ); $self->tmpl_path('templates'); $self->add_callback( 'load_tmpl', \&load_template_callback ); sub login { my ( $username, $password ) = @_; my $ad_auth = My::ActiveDirectory->new('WIN'); return 0 if not $ad_auth->login( $username, $password ); $self->session->param( ad_auth_userinfo => $ad_auth->getUserInfo ); ######################################################################### # # # if we've never seen the user before, redirect them to register # # # # if they are already in the DB, then load their data with # # Tools::User object that will be accessable everywhere via # # $self->user # # # ######################################################################### Tools::User->exists( %{ $self->session->param('ad_auth_userinfo') }->{user_id} } ) or $self->forward('register'); return $username; } } sub show_main { my $self = shift; ######################################################################### # # # retrieve user info, update user info, add user via class method # # from Tools::Users # # # ######################################################################### # retrieve user info my $name = $self->users->name # update user info $self->user->name('New_Name'); # class method to see if user exists $self->user->exists( $user_id ) or die "user doesn't exist"; # create new user and get it's object, dont't know if this is necessary for me to do. my $new_user_object = $self->user->insert({ id => 007, name => Bond }); } From shijialeee at yahoo.com Fri Jan 11 19:39:48 2008 From: shijialeee at yahoo.com (James.Q.L) Date: Fri Jan 11 19:39:50 2008 Subject: [cgiapp] How to integrate a module? In-Reply-To: <20080111104609.292eb6c930850de810cf35869bff7bc4.9b68764a01.wbe@email.secureserver.net> Message-ID: <491368.75624.qm@web50112.mail.re2.yahoo.com> sorry, didn't have time to read through your email. you should check out the wiki, this page maybe help http://www.cgi-app.org/index.cgi?OrganizeApp also search the list archive as this is a question asked few times before. James. --- adam@spatialsystems.org wrote: > SUMMARY: > How should I integrate my OO module with CGI::Applcaiton? > > > > Details: > Here is my first OO module ( Tools::User ) that administers users on my system. > > Create a user object populated with user info from DB: > my $user = Tools::User->new( $user_id ); > > Get info for user stored in db: > my $name = $user->name; > > Store info into object and save to db: > $user->name( $new_name ); > > Check if a user exists: > Tools::User->exists( $user_id ) or die "User $user_id doesn't exist"; > > Create new user and return object for user: > my $user = Tools::User->insert({ id => 007, name => Bond }); > > > > QUESION: > How should I integrate this with CGI::Application and CGI::Application::Plugin::Authentication? > > > > IMPLEMENTATION: > When a user logs in, Plugin::Authentication stores the User_Id in the session. I'd like to take > > that User_Id and run it in Tools::User->exists( $user_id ) and if it comes back false, then > redirect to a registration page where the user will get created on my system. > > If the user already exists in my DB, then I want to load the info for them from my database and > have my user object avail from $self->user in my CGI::Application. > > > > I'd like functionality similar to: > > > package VzTools::CellAvail::WebApp; > use strict; > > use base qw( CGI::Application); > > use CGI::Application::Plugin::Session; > use CGI::Application::Plugin::Forward; > use CGI::Application::Plugin::Authentication; > use My::ActiveDirectory; > > sub setup { > my $self = shift; > > $self->start_mode('login'); > $self->mode_param('rm'); > $self->run_modes( > 'login' => 'show_login', > 'main' => 'show_main', > 'register' => 'show_register', > ); > > # setup authentication > $self->authen->config( > DRIVER => [ 'Generic', \&login ], > STORE => 'Session', > LOGIN_RUNMODE => 'login', > POST_LOGIN_RUNMODE => 'main', > LOGOUT_RUNMODE => 'login', > ); > > $self->authen->protected_runmodes( 'main' ); > > $self->tmpl_path('templates'); > > $self->add_callback( 'load_tmpl', \&load_template_callback ); > > sub login { > > my ( $username, $password ) = @_; > my $ad_auth = My::ActiveDirectory->new('WIN'); > > return 0 if not $ad_auth->login( $username, $password ); > > $self->session->param( ad_auth_userinfo => $ad_auth->getUserInfo ); > > > ######################################################################### > # # > # if we've never seen the user before, redirect them to register # > # # > # if they are already in the DB, then load their data with # > # Tools::User object that will be accessable everywhere via # > # $self->user # > # # > ######################################################################### > > Tools::User->exists( %{ $self->session->param('ad_auth_userinfo') }->{user_id} } ) > or $self->forward('register'); > > return $username; > > } > > > } > > > sub show_main { > > my $self = shift; > > ######################################################################### > # # > # retrieve user info, update user info, add user via class method # > # from Tools::Users # > # # > ######################################################################### > > > # retrieve user info > my $name = $self->users->name > > > # update user info > $self->user->name('New_Name'); > > # class method to see if user exists > $self->user->exists( $user_id ) or die "user doesn't exist"; > > > # create new user and get it's object, dont't know if this is necessary for me to do. > my $new_user_object = $self->user->insert({ id => 007, name => Bond }); > > } > > ##### CGI::Application community mailing list ################ > ## ## > ## To unsubscribe, or change your message delivery options, ## > ## visit: http://www.erlbaum.net/mailman/listinfo/cgiapp ## > ## ## > ## Web archive: http://www.erlbaum.net/pipermail/cgiapp/ ## > ## Wiki: http://cgiapp.erlbaum.net/ ## > ## ## > ################################################################ > > ____________________________________________________________________________________ Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ From trwww at sbcglobal.net Sat Jan 12 13:26:45 2008 From: trwww at sbcglobal.net (Todd W) Date: Sat Jan 12 13:26:50 2008 Subject: [cgiapp] How to integrate a module ? References: <20080111002215.292eb6c930850de810cf35869bff7bc4.5fc70de8f9.wbe@email.secureserver.net> Message-ID: <002401c85548$b1809760$5402a8c0@trwlapgateway> From: > QUESTION: > How should I integrate this with CGI::Application and > CGI::Application::Plugin::Authentication? You could check out my slides from yapc 07. Half of them are Catalyst, but the half that are CGI::App cover this exact thing: http://www.waveright.com/yapc07/ http://www.waveright.com/svn/yapc/yapc07/trunk/cgiapp/MyStore Also, I found the ::Plugin::Authentication documentation very helpful. trwww From trwww at sbcglobal.net Sun Jan 13 01:55:09 2008 From: trwww at sbcglobal.net (Todd W) Date: Sun Jan 13 01:55:14 2008 Subject: [Bulk] [cgiapp] How to integrate a module ? References: <20080111002215.292eb6c930850de810cf35869bff7bc4.5fc70de8f9.wbe@email.secureserver.net> Message-ID: <00e701c855b1$3df8b160$5402a8c0@trwlapgateway> From: > QUESTION: > How should I integrate this with CGI::Application and > CGI::Application::Plugin::Authentication? You could check out my slides from yapc 07. Half of them are Catalyst, but the half that are CGI::App cover this exact thing: http://www.waveright.com/yapc07/ http://www.waveright.com/svn/yapc/yapc07/trunk/cgiapp/MyStore Also, I found the ::Plugin::Authentication documentation very helpful. trwww From adam at spatialsystems.org Sun Jan 13 23:22:33 2008 From: adam at spatialsystems.org (adam@spatialsystems.org) Date: Sun Jan 13 23:22:36 2008 Subject: [cgiapp] Displaying LoggedIn or Login Message-ID: <20080113212233.292eb6c930850de810cf35869bff7bc4.561fb30921.wbe@email.secureserver.net> I'm using HTML::Template and I have a block of HTML that will either display "Logged In" or "Not Logged In" based on if I'm logged in or not.
Logged In
OR
Not Logged In
How should I implement showing one of either block depending if I'm logged in? My thought is to register a template callback to figure out if I'm logged in and pass HTML::Template a boolean for Something like this:
Logged In
Not Logged In
Does this sound right or is there a better way? Thanks, Adam From ron at savage.net.au Mon Jan 14 00:22:59 2008 From: ron at savage.net.au (Ron Savage) Date: Mon Jan 14 00:23:55 2008 Subject: [cgiapp] Displaying LoggedIn or Login In-Reply-To: <20080113212233.292eb6c930850de810cf35869bff7bc4.561fb30921.wbe@email.secureserver.net> References: <20080113212233.292eb6c930850de810cf35869bff7bc4.561fb30921.wbe@email.secureserver.net> Message-ID: <1200288179.868.1.camel@zoe.savage.net.au> On Sun, 2008-01-13 at 21:22 -0700, adam@spatialsystems.org wrote: Hi Adam Something like this:
Logged InNot Logged In
looks simpler. -- Ron Savage ron@savage.net.au http://savage.net.au/index.html From adrianh at quietstars.com Tue Jan 15 06:42:13 2008 From: adrianh at quietstars.com (Adrian Howard) Date: Tue Jan 15 06:42:25 2008 Subject: [cgiapp] [request] Hardware for Smolder In-Reply-To: <476B453C.50906@plusthree.com> References: <476B453C.50906@plusthree.com> Message-ID: <29A3EDDA-1554-4CFC-8E14-5E4B50DEE989@quietstars.com> Got anything for this yet? (not nagging - just seeing if it's still appropriate for me to do some begging :-) Cheers, Adrian On 21 Dec 2007, at 04:46, Michael Peters wrote: > As part of a TPF Grant that I'm working on, the last thing I need > to do is setup > a Smolder (http://sourceforge.net/projects/smolder) server for > receiving test > reports for CGI::App CPAN modules. There's also talk about trying > to hook into > CPAN's smoke testing service so that you can receive more detailed > reports > instead of the particularly vague emails that come from CPANTS > boxes... > > Smolder doesn't take a lot of resources (it can use MySQL if it's > installed or > just use SQLite locally. If this becomes popular for other CPAN > authors then > disk space might be an issue eventually, but not anytime soon... > > Any donors? > > -- > Michael Peters > Developer > Plus Three, LP > > > ##### CGI::Application community mailing list ################ > ## ## > ## To unsubscribe, or change your message delivery options, ## > ## visit: http://www.erlbaum.net/mailman/listinfo/cgiapp ## > ## ## > ## Web archive: http://www.erlbaum.net/pipermail/cgiapp/ ## > ## Wiki: http://cgiapp.erlbaum.net/ ## > ## ## > ################################################################ > > > > > > > > > > > > > > > > > > > > > From stephen.carville at gmail.com Wed Jan 16 14:06:05 2008 From: stephen.carville at gmail.com (Stephen Carville) Date: Wed Jan 16 14:07:29 2008 Subject: [cgiapp] Settng Template path Message-ID: <2428c0380801161106q28343dddi975a9704f08aeb96@mail.gmail.com> I'm trying out CGI++Application plus HTML::Template as a replacement/upgrade for a current report generation system but I'm havinmg a problem with settng the template path: I create a module called DailyFloodSummary.pm: #!/usr/bin/perl package DailyFloodSummary; use base 'CGI::Application'; use strict; use warnings; use HTML::Template; # Constants my $TMPL_DIR = "/var/www/perl/html_templates"; ####################################### # Setup # sub setup { my $self = shift; $self->tmpl_path($TMPL_DIR); $self->run_modes( '0' => 'show_search_form', '1' => 'show_results_list' ); $self->start_mode('0'); $self->mode_param('level'); } ####################################### # show the search form # sub show_search_form { my $self = shift; my ($cgi,$date,$time); my ($header,$body,$trailer,$output); # open the header template $header = $self->load_tmpl("header.tmpl"); # current date and time from library routines ($date,$time) = web_get_today(); $header->param(todaysdate => "$date $time"); $output = $header->output; return $output; } I call it from dfs.cgi #!/usr/bin/perl use strict; use warnings; use lib "."; use DailyFloodSummary; my $app = DailyFloodSummary->new(); $app->run(); I get the following error list: Error executing run mode '0': HTML::Template->new() : Cannot open included file header.tmpl : file not found. at /usr/lib/perl5/site_perl/5.8.8/HTML/Template.pm line 1658 HTML::Template::_init_template('HTML::Template=HASH(0x1f738f80)') called at /usr/lib/perl5/site_perl/5.8.8/HTML/Template.pm line 1238 HTML::Template::_init('HTML::Template=HASH(0x1f738f80)') called at /usr/lib/perl5/site_perl/5.8.8/HTML/Template.pm line 1124 HTML::Template::new('HTML::Template', 'filename', 'header.tmpl', 'path', 'ARRAY(0x1f83f1a0)') called at /usr/lib/perl5/site_perl/5.8.8/HTML/Template.pm line 1182 HTML::Template::new_file('HTML::Template', 'header.tmpl', 'path', 'ARRAY(0x1f83f1a0)') called at /usr/lib/perl5/site_perl/5.8.8/CGI/Application.pm line 1464 CGI::Application::load_tmpl('DailyFloodSummary=HASH(0x1f5e12e0)', 'header.tmpl') called at DailyFloodSummary.pm line 40 DailyFloodSummary::show_search_form('DailyFloodSummary=HASH(0x1f5e12e0)') called at /usr/lib/perl5/site_perl/5.8.8/CGI/Application.pm line 152 eval {...} called at /usr/lib/perl5/site_perl/5.8.8/CGI/Application.pm line 151 CGI::Application::run('DailyFloodSummary=HASH(0x1f5e12e0)') called at ./dfs.cgi line 11 at ./dfs.cgi line 11 Any idea what I am doing wrong? -- Stephen Carville From stephen.carville at gmail.com Wed Jan 16 14:43:48 2008 From: stephen.carville at gmail.com (Stephen Carville) Date: Wed Jan 16 14:43:51 2008 Subject: [cgiapp] Re: Settng Template path In-Reply-To: <2428c0380801161106q28343dddi975a9704f08aeb96@mail.gmail.com> References: <2428c0380801161106q28343dddi975a9704f08aeb96@mail.gmail.com> Message-ID: <2428c0380801161143u4e89eaap6a9d23fd06f03178@mail.gmail.com> Forget it! False alarm! "html_templates" should be "html-templates". On Jan 16, 2008 11:06 AM, Stephen Carville wrote: > I'm trying out CGI++Application plus HTML::Template as a > replacement/upgrade for a current report generation system but I'm > havinmg a problem with settng the template path: > > I create a module called DailyFloodSummary.pm: > > #!/usr/bin/perl > package DailyFloodSummary; > use base 'CGI::Application'; > use strict; > use warnings; > use HTML::Template; > > # Constants > my $TMPL_DIR = "/var/www/perl/html_templates"; > > ####################################### > # Setup > # > sub setup { > my $self = shift; > > $self->tmpl_path($TMPL_DIR); > $self->run_modes( > '0' => 'show_search_form', > '1' => 'show_results_list' > ); > > $self->start_mode('0'); > > $self->mode_param('level'); > } > > ####################################### > # show the search form > # > sub show_search_form { > my $self = shift; > my ($cgi,$date,$time); > my ($header,$body,$trailer,$output); > > # open the header template > $header = $self->load_tmpl("header.tmpl"); > > # current date and time from library routines > ($date,$time) = web_get_today(); > > $header->param(todaysdate => "$date $time"); > > $output = $header->output; > > return $output; > } > > I call it from dfs.cgi > > #!/usr/bin/perl > > use strict; > use warnings; > > use lib "."; > use DailyFloodSummary; > > my $app = DailyFloodSummary->new(); > > $app->run(); > > I get the following error list: > > Error executing run mode '0': HTML::Template->new() : Cannot open > included file header.tmpl : file not found. at > /usr/lib/perl5/site_perl/5.8.8/HTML/Template.pm line 1658 > HTML::Template::_init_template('HTML::Template=HASH(0x1f738f80)') > called at /usr/lib/perl5/site_perl/5.8.8/HTML/Template.pm line 1238 > HTML::Template::_init('HTML::Template=HASH(0x1f738f80)') > called at /usr/lib/perl5/site_perl/5.8.8/HTML/Template.pm line 1124 > HTML::Template::new('HTML::Template', 'filename', > 'header.tmpl', 'path', 'ARRAY(0x1f83f1a0)') called at > /usr/lib/perl5/site_perl/5.8.8/HTML/Template.pm line 1182 > HTML::Template::new_file('HTML::Template', 'header.tmpl', > 'path', 'ARRAY(0x1f83f1a0)') called at > /usr/lib/perl5/site_perl/5.8.8/CGI/Application.pm line 1464 > CGI::Application::load_tmpl('DailyFloodSummary=HASH(0x1f5e12e0)', > 'header.tmpl') called at DailyFloodSummary.pm line 40 > DailyFloodSummary::show_search_form('DailyFloodSummary=HASH(0x1f5e12e0)') > called at /usr/lib/perl5/site_perl/5.8.8/CGI/Application.pm line 152 > eval {...} called at > /usr/lib/perl5/site_perl/5.8.8/CGI/Application.pm line 151 > CGI::Application::run('DailyFloodSummary=HASH(0x1f5e12e0)') > called at ./dfs.cgi line 11 > at ./dfs.cgi line 11 > > Any idea what I am doing wrong? > > -- > Stephen Carville > -- Stephen Carville From sigzero at gmail.com Wed Jan 16 21:10:49 2008 From: sigzero at gmail.com (Robert Hicks) Date: Wed Jan 16 21:11:01 2008 Subject: [cgiapp] Task::CGIApp Message-ID: I was reading the CA website and saw the post that it would be nice to have a Task::CGIApp. What would be the list of recommended plugins that you would like to see loaded from Task::CGIApp? Robert From ron at savage.net.au Sat Jan 19 23:33:52 2008 From: ron at savage.net.au (Ron Savage) Date: Sat Jan 19 23:33:12 2008 Subject: [cgiapp] Combining CGI::App::Plugin::Apache and CGI::App::Dispatch Message-ID: <1200803632.868.64.camel@zoe.savage.net.au> Hi Folks Is is possible to combine the 2 modules named in the Subject? Context is: o Debian etch o Apache/2.2.6 (Unix) mod_fastcgi/2.4.6 mod_apreq2-20051231/2.6.0 mod_perl/2.0.3 Perl/v5.8.8 configured What I'm finding is: o I can use CGI::App::Dispatch by itself o When I add CGI::App::Plugin::Apache, CGI::App::Dispatch is disabled, so CGI::App calls its default sub setup(), and the default run mode 'start' triggers a call to CGI::App's sub dump_html(), but since the query object is now an Apache::Request object, which has no sub Dump(), CGI::App is dying at line 297: $output .= $query->Dump; The full error msg is: [Sun Jan 20 15:26:56 2008] [error] [client 127.0.0.1] Error executing run mode 'start': Can't locate auto/Apache2/Request/Dump.al in @INC (@INC contains: /etc/perl /usr/local/lib/perl/5.8.8 /usr/local/share/perl/5.8.8 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.8 /usr/share/perl/5.8 /usr/local/lib/site_perl . /home/ron/httpd/prefork) at /usr/local/share/perl/5.8.8/CGI/Application.pm line 297\n at /usr/local/share/perl/5.8.8/CGI/Application/Plugin/Apache.pm line 36\n -- Ron Savage ron@savage.net.au http://savage.net.au/index.html From trwww at sbcglobal.net Sun Jan 20 09:26:54 2008 From: trwww at sbcglobal.net (Todd W) Date: Sun Jan 20 09:26:57 2008 Subject: [cgiapp] Task::CGIApp References: Message-ID: <006c01c85b70$82e35360$5402a8c0@trwlapgateway> From: "Robert Hicks" >I was reading the CA website and saw the post that it would be nice to > have a Task::CGIApp. What would be the list of recommended plugins that > you would like to see loaded from Task::CGIApp? Just a few of my faves: ::Plugin::Session ::Plugin::Stash ::Plugin::TT ::Plugin::Authorization ::Plugin::Authenticication ::Plugin::ValidateRM ::Plugin::DBH ::Plugin::AutoRunmode ::Dispatch ::Plugin::RateLimit ::Plugin::RequireSSL :-) trwww From adrianh at quietstars.com Sun Jan 20 14:21:49 2008 From: adrianh at quietstars.com (Adrian Howard) Date: Sun Jan 20 14:21:57 2008 Subject: [cgiapp] [request] Hardware for Smolder In-Reply-To: <29A3EDDA-1554-4CFC-8E14-5E4B50DEE989@quietstars.com> References: <476B453C.50906@plusthree.com> <29A3EDDA-1554-4CFC-8E14-5E4B50DEE989@quietstars.com> Message-ID: On 15 Jan 2008, at 11:42, Adrian Howard wrote: > Got anything for this yet? > > (not nagging - just seeing if it's still appropriate for me to do > some begging :-) Guess who didn't mean that to go to the whole list :-/ Adrian From karen.cravens at gmail.com Sun Jan 20 14:24:54 2008 From: karen.cravens at gmail.com (Karen) Date: Sun Jan 20 14:24:58 2008 Subject: [cgiapp] [request] Hardware for Smolder In-Reply-To: References: <476B453C.50906@plusthree.com> <29A3EDDA-1554-4CFC-8E14-5E4B50DEE989@quietstars.com> Message-ID: <7cc7c1ce0801201124u59de97f6occ1d7f9c6af7183d@mail.gmail.com> On 1/20/08, Adrian Howard wrote: > Guess who didn't mean that to go to the whole list :-/ That's okay, I'm curious too. We're relocating to a new hosting service on a faster box, and might could find some room if nobody else has. From mpeters at plusthree.com Sun Jan 20 17:13:35 2008 From: mpeters at plusthree.com (Michael Peters) Date: Sun Jan 20 17:15:21 2008 Subject: [cgiapp] Combining CGI::App::Plugin::Apache and CGI::App::Dispatch In-Reply-To: <1200803632.868.64.camel@zoe.savage.net.au> References: <1200803632.868.64.camel@zoe.savage.net.au> Message-ID: <4793C78F.6040401@plusthree.com> Ron Savage wrote: > Is is possible to combine the 2 modules named in the Subject? Yes, but it depends on how you use them. Are you trying to use both of them as base classes? Dispatch is not intended to be used as a base class. Dispatch sits outside of your application modules and *dispatches* to them. -- Michael Peters Developer Plus Three, LP From mpeters at plusthree.com Sun Jan 20 17:20:44 2008 From: mpeters at plusthree.com (Michael Peters) Date: Sun Jan 20 17:22:29 2008 Subject: [cgiapp] Re: cgiapp plug JSON. In-Reply-To: <901549.93348.qm@web32405.mail.mud.yahoo.com> References: <901549.93348.qm@web32405.mail.mud.yahoo.com> Message-ID: <4793C93C.7020500@plusthree.com> Neil Mansilla wrote: > Hi there, CC'ing the cgi-app list: > Can you give me a little tip on how to get the plugin to properly work > with CGIapp in terms of changing the content-type and sending the data > out to the application properly? It should be pretty straight forward. > I'm using prototype.js to observe one > of my form fields and onchange it runs my CGIapp runmode "foo_ajax". > I'd like to instruct my CGIapp to use the JSON plugin so that the data > is properly sent back in as compact way as possible. Are you trying to send JSON data in the HTTP X-JSON header or as the contents of the response? If the header, just do: $self->json_header(foo => 'bar'); Somewhere in your run mode. If your sending the JSON as the contents of the response then it's just: return $self->json_body({ foo => 'bar' }); at the end of your run mode. > I'm trying to set the header_type to none, etc.. but I'm just getting a > lot of Error 500s and other errors from CGIapp. A 500 error means *look in your server log* :) -- Michael Peters Developer Plus Three, LP From mpeters at plusthree.com Sun Jan 20 17:43:35 2008 From: mpeters at plusthree.com (Michael Peters) Date: Sun Jan 20 17:45:19 2008 Subject: [cgiapp] [request] Hardware for Smolder In-Reply-To: <29A3EDDA-1554-4CFC-8E14-5E4B50DEE989@quietstars.com> References: <476B453C.50906@plusthree.com> <29A3EDDA-1554-4CFC-8E14-5E4B50DEE989@quietstars.com> Message-ID: <4793CE97.5080900@plusthree.com> Adrian Howard wrote: > Got anything for this yet? > > (not nagging - just seeing if it's still appropriate for me to do some > begging :-) I've got a lead I'm waiting on. He needed to move some stuff around but was going to let me know when he was ready. Thanks for the prodding! -- Michael Peters Developer Plus Three, LP From ron at savage.net.au Sun Jan 20 18:12:22 2008 From: ron at savage.net.au (Ron Savage) Date: Sun Jan 20 18:13:12 2008 Subject: [cgiapp] Combining CGI::App::Plugin::Apache and CGI::App::Dispatch In-Reply-To: <4793C78F.6040401@plusthree.com> References: <1200803632.868.64.camel@zoe.savage.net.au> <4793C78F.6040401@plusthree.com> Message-ID: <1200870742.868.72.camel@zoe.savage.net.au> On Sun, 2008-01-20 at 17:13 -0500, Michael Peters wrote: Hi Michael Thanx for the response. > > Is is possible to combine the 2 modules named in the Subject? > > Yes, but it depends on how you use them. Are you trying to use both of them as > base classes? Dispatch is not intended to be used as a base class. Dispatch sits > outside of your application modules and *dispatches* to them. Yes, I'm trying to use them both as base classes, as in: use base qw(CGI::Application CGI::Application::Dispatch); '... not intended to be used as a base class'?????? Let me quote your Synopsis: With a dispatch table package MyApp::Dispatch; use base 'CGI::Application::Dispatch'; No $customized_profanity wonder I'm confused :=). The Synopsis goes on: sub dispatch_args { return { prefix => 'MyApp', table => [ '' => { app => 'Welcome', rm => 'start' }, ':app/:rm' => { }, 'admin/:app/:rm' => { prefix => 'MyApp::Admin' }, ], }; } So, how will CGI::Application::Dispatch have access to dispatch_args() if that sub is inside my module? Anyway, thanx for the pointers. I'll battle on while I breathlessly await your reply... -- Ron Savage ron@savage.net.au http://savage.net.au/index.html From ron at savage.net.au Sun Jan 20 18:16:01 2008 From: ron at savage.net.au (Ron Savage) Date: Sun Jan 20 18:15:20 2008 Subject: [cgiapp] Combining CGI::App::Plugin::Apache and CGI::App::Dispatch In-Reply-To: <4793C78F.6040401@plusthree.com> References: <1200803632.868.64.camel@zoe.savage.net.au> <4793C78F.6040401@plusthree.com> Message-ID: <1200870961.868.76.camel@zoe.savage.net.au> On Sun, 2008-01-20 at 17:13 -0500, Michael Peters wrote: Hi Michael Ha. More reading of the docs suggests I was labouring under even more of a mis-understanding than even I'd assumed. I was putting sub dispatch_args() in my CGI::App-based base class :-(. Sigh. -- Ron (Perhaps I should just retire now) Savage ron@savage.net.au http://savage.net.au/index.html From mpeters at plusthree.com Mon Jan 21 09:33:20 2008 From: mpeters at plusthree.com (Michael Peters) Date: Mon Jan 21 09:35:06 2008 Subject: [cgiapp] Combining CGI::App::Plugin::Apache and CGI::App::Dispatch In-Reply-To: <1200870742.868.72.camel@zoe.savage.net.au> References: <1200803632.868.64.camel@zoe.savage.net.au> <4793C78F.6040401@plusthree.com> <1200870742.868.72.camel@zoe.savage.net.au> Message-ID: <4794AD30.9040607@plusthree.com> Ron Savage wrote: > Yes, I'm trying to use them both as base classes, as in: > use base qw(CGI::Application CGI::Application::Dispatch); > > '... not intended to be used as a base class'?????? > Let me quote your Synopsis: > With a dispatch table > package MyApp::Dispatch; > use base 'CGI::Application::Dispatch'; > > No $customized_profanity wonder I'm confused :=). You can subclass Dispatch. That's not a problem. I do it all the time. But you subclass it to create a custom dispatch module, not an application module. For that you subclass C::A itself. Remember, Dispatch sits outside of your application modules and dispatches to them. The prime use case is when you have lots of application modules. For instance, Smolder has 11 application modules (which inherit from C::A) and 1 dispatch module (which inherits from Dispatch). -- Michael Peters Developer Plus Three, LP From szabgab at gmail.com Mon Jan 21 21:09:52 2008 From: szabgab at gmail.com (Gabor Szabo) Date: Mon Jan 21 21:09:54 2008 Subject: [cgiapp] Best practice for dealing with errors during the cgiapp_init method Message-ID: As I understand the error_mode should be defined in the setup() phase. What is the standard way to handle errors during the previous phases, e.g. during cgiapp_init()? What if the configuration file read during cgiapp_init is missing or if the database connection could not be established? Right now I have this in my script: eval { $dn = WebApp->new; $dn->run; }; if ($@) { warn "Major crisis: $@"; print "Content-type: text/html\n\n"; print "Major crisis. Please ask the site administrator to look at the log files.\n"; } Any better way to handle this? Gabor From szabgab at gmail.com Mon Jan 21 21:16:55 2008 From: szabgab at gmail.com (Gabor Szabo) Date: Mon Jan 21 21:17:07 2008 Subject: [cgiapp] slight documentation change Message-ID: Would it be possible to change the the documentation so the order of the methods one can implement in the subclass is the same in the documentation as in the order of calling? Would it be possible to add the hierarchy to the documentation something like this: =over 4 =item new =over 4 =item cgiapp_init() =item setup() =back =item run =over 4 =item cgiapp_prerun() =item User implemented run mode =item cgiapp_postrun() =item teardown() =back =back Gabor From ron at savage.net.au Sun Jan 27 17:57:08 2008 From: ron at savage.net.au (Ron Savage) Date: Sun Jan 27 17:56:23 2008 Subject: [cgiapp] Combining CGI::App::Plugin::Apache and CGI::App::Dispatch In-Reply-To: <4794AD30.9040607@plusthree.com> References: <1200803632.868.64.camel@zoe.savage.net.au> <4793C78F.6040401@plusthree.com> <1200870742.868.72.camel@zoe.savage.net.au> <4794AD30.9040607@plusthree.com> Message-ID: <1201474628.5082.61.camel@zoe.savage.net.au> On Mon, 2008-01-21 at 09:33 -0500, Michael Peters wrote: Hi Michael > You can subclass Dispatch. That's not a problem. I do it all the time. But you Yes, thanx. I eventually understood what to do... <===><8===> package CGI::Application::Test::ModperlDispatcher; use base 'CGI::Application::Dispatch'; use strict; use warnings; our $VERSION = '1.00'; # ----------------------------------------------- sub dispatch_args { return { prefix => 'CGI::Application::Test::Modperl', table => [ '' => {app => 'main-menu', rm => 'menu'}, ':app/:rm' => {}, ], }; } # End of dispatch_args. # ----------------------------------------------- 1; <===><8===> I.e. Exactly as recommended. The problem was in the understanding, not in your code. And in httpd.conf: <===><8===> SetHandler perl-script PerlResponseHandler CGI::Application::Test::ModperlDispatcher <===><8===> Again, exactly as recommended... -- Ron Savage ron@savage.net.au http://savage.net.au/index.html From sigzero at gmail.com Mon Jan 28 21:36:34 2008 From: sigzero at gmail.com (Robert Hicks) Date: Mon Jan 28 21:36:49 2008 Subject: [cgiapp] CA and AJAX Message-ID: I am looking at the Ext Js 2.0 AJAX framework and it looks really good (I also like jQuery). Is anybody working on an easy way to call Ext stuff from Perl through CA? Robert From mpeters at plusthree.com Tue Jan 29 09:29:25 2008 From: mpeters at plusthree.com (Michael Peters) Date: Tue Jan 29 09:31:23 2008 Subject: [cgiapp] CA and AJAX In-Reply-To: References: Message-ID: <479F3845.9040101@plusthree.com> Robert Hicks wrote: > I am looking at the Ext Js 2.0 AJAX framework and it looks really good > (I also like jQuery). Is anybody working on an easy way to call Ext > stuff from Perl through CA? Ajax stuff is fun to do, but it's really no different from normal web work, at least from a C::A perspective. You call run modes just the same. It doesn't matter how the request makes it to the backend. The only real differences are the following: + you almost never return full pages (header, nav, footer, etc). This is pretty easy to do with templating. I just set a no_wrapper param that goes to my templates on Ajax requests to turn off the extra stuff I don't need. + JSON - If I have any advice about Ajax programming is don't use XML if you can avoid it. It's nice to be able to read RSS feeds from some other source, but if you can control the data source use JSON. It's faster, smaller, easier to read and more "natural" to Perl. Check out C::A::Plugin::JSON for some easy ways to use it -- Michael Peters Developer Plus Three, LP From hitz at genome.stanford.edu Tue Jan 29 11:27:45 2008 From: hitz at genome.stanford.edu (Ben Hitz) Date: Tue Jan 29 12:06:40 2008 Subject: [cgiapp] CA and AJAX In-Reply-To: <479F3845.9040101@plusthree.com> References: <479F3845.9040101@plusthree.com> Message-ID: <6311C6CB-0244-47B8-B663-DD7ABB7E52F4@genome.stanford.edu> I have been starting to interface my CA with both DBIx::Class and the Rico js library (www.openrico.org), which is derived from prototype.js. Generally, I haven't found much use to actually write javascript from perl; I prefer to use Templates for the javascript and XML and use the perl to define variables and configure. There is an HTML::Prototype library and associated CGI:App plugin. At one point I was looking at jQuery and had to write a 6 line Cgi::App::Plugin::jQuery module (but I never used it). One thing that tripped me up for a day or two was forgetting to escape $ in TT2 so that it appears as $(variable) in javascript. Ben On Jan 29, 2008, at 6:29 AM, Michael Peters wrote: > Robert Hicks wrote: >> I am looking at the Ext Js 2.0 AJAX framework and it looks really >> good >> (I also like jQuery). Is anybody working on an easy way to call Ext >> stuff from Perl through CA? > > Ajax stuff is fun to do, but it's really no different from normal > web work, at > least from a C::A perspective. You call run modes just the same. It > doesn't > matter how the request makes it to the backend. The only real > differences are > the following: > > + you almost never return full pages (header, nav, footer, etc). > This is pretty > easy to do with templating. I just set a no_wrapper param that goes > to my > templates on Ajax requests to turn off the extra stuff I don't need. > > + JSON - If I have any advice about Ajax programming is don't use > XML if you can > avoid it. It's nice to be able to read RSS feeds from some other > source, but if > you can control the data source use JSON. It's faster, smaller, > easier to read > and more "natural" to Perl. Check out C::A::Plugin::JSON for some > easy ways to > use it > > -- > Michael Peters > Developer > Plus Three, LP > > > ##### CGI::Application community mailing list ################ > ## ## > ## To unsubscribe, or change your message delivery options, ## > ## visit: http://www.erlbaum.net/mailman/listinfo/cgiapp ## > ## ## > ## Web archive: http://www.erlbaum.net/pipermail/cgiapp/ ## > ## Wiki: http://cgiapp.erlbaum.net/ ## > ## ## > ################################################################ -- Ben Hitz Senior Scientific Programmer ** Saccharomyces Genome Database ** GO Consortium Stanford University ** hitz@genome.stanford.edu From sigzero at gmail.com Wed Jan 30 17:25:31 2008 From: sigzero at gmail.com (Robert Hicks) Date: Wed Jan 30 18:11:24 2008 Subject: [cgiapp] Template::TAL Message-ID: Has anyone tried integrating: http://search.cpan.org/~fotango/Template-TAL-0.91/lib/Template/TAL.pm into CA? Looks like a nice fit. Robert From mpeters at plusthree.com Wed Jan 30 18:18:09 2008 From: mpeters at plusthree.com (Michael Peters) Date: Wed Jan 30 18:21:57 2008 Subject: [cgiapp] Template::TAL In-Reply-To: References: Message-ID: <47A105B1.5000408@plusthree.com> Robert Hicks wrote: > Has anyone tried integrating: > > http://search.cpan.org/~fotango/Template-TAL-0.91/lib/Template/TAL.pm > > into CA? Looks like a nice fit. It's just another templating system. The only real reason to use TAL is because it's language agnostic. It's got implementations in Python, Java and PHP. So if you're working on a multi language project then it's a good fit. Otherwise it's slow (slower than both TT and H::T) and I find it incredibly verbose and clumsy. I converted a few TAL templates into TT equivalents once and the reduction in size was almost 50%. -- Michael Peters Developer Plus Three, LP From sigzero at gmail.com Wed Jan 30 21:46:12 2008 From: sigzero at gmail.com (Robert Hicks) Date: Wed Jan 30 21:46:34 2008 Subject: [cgiapp] Re: Template::TAL In-Reply-To: <47A105B1.5000408@plusthree.com> References: <47A105B1.5000408@plusthree.com> Message-ID: Michael Peters wrote: > Robert Hicks wrote: >> Has anyone tried integrating: >> >> http://search.cpan.org/~fotango/Template-TAL-0.91/lib/Template/TAL.pm >> >> into CA? Looks like a nice fit. > > It's just another templating system. The only real reason to use TAL is because > it's language agnostic. It's got implementations in Python, Java and PHP. So if > you're working on a multi language project then it's a good fit. Otherwise it's > slow (slower than both TT and H::T) and I find it incredibly verbose and clumsy. > I converted a few TAL templates into TT equivalents once and the reduction in > size was almost 50%. > Good enough for me *not* to use it. Thanks for the input. Robert From mpeters at plusthree.com Thu Jan 31 14:46:43 2008 From: mpeters at plusthree.com (Michael Peters) Date: Thu Jan 31 14:48:43 2008 Subject: [cgiapp] Re: Dispatcher In-Reply-To: References: Message-ID: <47A225A3.8040202@plusthree.com> Karunakar Komirishetty wrote: > Hello Michael CC'ing the C::A list > My name is Karun. I am trying to implement the CGI-Application-Dispatch-2.12 module which you developed. I downloaded and installed the module. In my application I am subclassing the dispatch_args subroutine. When I run the URL I get a page not found error (404). I am using Apache server and mod_perl 2.0. My URL looks something like the following: > > http://example.net:4042/WebApp/WebService/mode_get_page > > For some reason it's failing in the table code. The following is the table code: > > sub dispatch_args { > my $self = shift; > my $DEBUG = true; > my ( $self1, $new_args ) = @_; > > return { > prefix => 'WebApp', > table => [ > '/WebService' => { app => 'WebService', rm => 'mode_get_page' }, > ], > #error_document => '"Oops..."', > #default => 'Test.html', > $DEBUG => 'true', > }; > > } I'll need a little more info than that. Are you using Apache? mod_perl? mod_rewrite? If so, how are they configured for this location. Also, what C::A module are you trying to dispatch to? Also, I think you might be confused about what some of those values should be. The 'prefix' isn't the URL prefix, it's the module name prefix. C::A::Dispatch dispatches to C::A based modules. Also the url's are assumed to be all lowercase. Look at the translate_module_name() name if you want to change this. Looking at the URL you have and the, the prefix and the table your url will map to a class named WebApp::Webservice. Does that module exist? Also you seem to be a little confused about that $DEBUG there. For one, "true" is can't exist without quotes (like you have in "my $DEBUG = true;" Perl doesn't have true/false literals like that. Use 1 or 0. And then in your hash that you return you have "$DEBUG => 'true'", that will not do what you think it will. Try 'debug => 1'. -- Michael Peters Developer Plus Three, LP From petr.vojkovsky at centrum.cz Fri Feb 1 10:41:25 2008 From: petr.vojkovsky at centrum.cz (petr.vojkovsky@centrum.cz) Date: Fri Feb 1 11:43:27 2008 Subject: [cgiapp] How to send pdf file? Message-ID: <200802011641.28104@centrum.cz> Hi, I want send to browser pdf file (it exist): I try do it in this rm: use MIME::Base64; ... -------------------------------- my $self = shift; my $q = $self->query(); my $session = undef(); my $message = ''; my $output = ''; my $buf; my $files_location = 'PATH TO DIR'; my $filename = 'exam1.pdf'; open(FILE, "<$files_location/exam1.pdf") or die "$!"; #binmode FILE; my @fs = stat(FILE); #my $file_size = $theFileStat->size; #my $file_size = $fs[7]; while (read(FILE, $buf, 60*57)) { $output = $output . encode_base64($buf); } close (FILE); $self->header_props( -type => "application/pdf", -attachment => $filename, -Content_Length => length($output), -Content_Transfer_Encoding => "base64", ); $self->header_type('header'); return $output; --------------------------- Browser shows "Save as" window, but xpdf can't dislpay it. Why the browser automatically decode_base64 this file? How to send binary file (*.pdf, *.jpg, ...) without Base64 encoding? Thank you for advice. Best regards, Petr From mpeters at plusthree.com Fri Feb 1 11:50:14 2008 From: mpeters at plusthree.com (Michael Peters) Date: Fri Feb 1 11:52:13 2008 Subject: [cgiapp] How to send pdf file? In-Reply-To: <200802011641.28104@centrum.cz> References: <200802011641.28104@centrum.cz> Message-ID: <47A34DC6.2010309@plusthree.com> petr.vojkovsky@centrum.cz wrote: > Hi, > I want send to browser pdf file (it exist): If it already exists, it's much easier than that. Basically you just tell the browser where to find the file and what type it is: sub send_pdf { my $self = shift; $self->header_type('none'); # let's you set your own headers $self->header_props( -content-type => 'application/pdf', -content-disposition' => 'inline; filename=myfile.pdf' ); return 'Download myfile.pdf'; } Or something like that. It's kind of tricky when you need to deal with caching, SSL and IE - http://support.microsoft.com/kb/316431, but if you don't then it's pretty easy. -- Michael Peters Developer Plus Three, LP From petr.vojkovsky at centrum.cz Sun Feb 3 05:14:18 2008 From: petr.vojkovsky at centrum.cz (petr.vojkovsky@centrum.cz) Date: Sun Feb 3 05:53:18 2008 Subject: [cgiapp] How to send pdf file? Message-ID: <200802031114.29209@centrum.cz> Hi Michael, thank you for your answer. MIME headers are correct, but I still don't know how to send binary output through CGI::Application. On "classic" way it is easy: open(FILE, "; close (FILE); print "Content-Type: application/pdf\n"; print "Content-Disposition: attachment;filename=test.pdf\n\n"; print @fileholder; How to do it through CGI::Application? Petr petr.vojkovsky@centrum.cz wrote: > Hi, > I want send to browser pdf file (it exist): mpeters@plusthree.com wrote: >If it already exists, it's much easier than that. Basically you just tell the >browser where to find the file and what type it is: >sub send_pdf { >my $self = shift; >$self->header_type('none'); # let's you set your own headers >$self->header_props( >-content-type => 'application/pdf', >-content-disposition' => 'inline; filename=myfile.pdf' >); > >return 'Download myfile.pdf'; >} >Or something like that. It's kind of tricky when you need to deal with caching, >SSL and IE - http://support.microsoft.com/kb/316431, but if you don't then it's >pretty easy. >-- >Michael Peters >Developer >Plus Three, LP From jesse at erlbaum.net Sun Feb 3 08:34:00 2008 From: jesse at erlbaum.net (Jesse Erlbaum) Date: Sun Feb 3 08:49:34 2008 Subject: [cgiapp] How to send pdf file? In-Reply-To: <200802031114.29209@centrum.cz> References: <200802031114.29209@centrum.cz> Message-ID: Hi Petr -- > MIME headers are correct, but I still don't know how to send binary > output through CGI::Application. > On "classic" way it is easy: > open(FILE, " @fileholder = ; > close (FILE); > > print "Content-Type: application/pdf\n"; > print "Content-Disposition: attachment;filename=test.pdf\n\n"; > print @fileholder; > > > How to do it through CGI::Application? It's basically the same w/ CGI::Application, with two exceptions: 1. You don't return the headers. You set them. 2. You don't print -- you return your data. sub send_pdf { my $self = shift; $self->header_props( -type => "application/pdf", -"Content-Disposition"=>"attachment;filename=test.pdf" ); open(FILE, "; close (FILE); return join("", @fileholder); } TTYL, -Jesse- ? Jesse Erlbaum The Erlbaum Group, LLC 817 Broadway, 10th floor New York, NY 10003 212-684-6161 (office) 917-647-3059 (mobile) 212-684-6226 (fax) jesse@erlbaum.net From hartzell at alerce.com Sun Feb 3 12:48:28 2008 From: hartzell at alerce.com (George Hartzell) Date: Sun Feb 3 12:48:32 2008 Subject: [cgiapp] How to send pdf file? In-Reply-To: <200802031114.29209@centrum.cz> References: <200802031114.29209@centrum.cz> Message-ID: <18341.65132.683395.629924@almost.alerce.com> There's also Jason Purdy's CGI::Application::Plugin::Stream, which reads and write the file in chunks to avoid slurping it all into memory at once. http://search.cpan.org/dist/CGI-Application-Plugin-Stream/lib/CGI/Application/Plugin/Stream.pm g. From pagaltzis at gmx.de Sun Feb 3 14:17:30 2008 From: pagaltzis at gmx.de (Aristotle Pagaltzis) Date: Sun Feb 3 14:17:34 2008 Subject: [cgiapp] Re: How to send pdf file? In-Reply-To: <200802031114.29209@centrum.cz> References: <200802031114.29209@centrum.cz> <47A34DC6.2010309@plusthree.com> <200802031114.29209@centrum.cz> Message-ID: <20080203191730.GG25553@klangraum> * petr.vojkovsky@centrum.cz [2008-02-03 11:55]: > @fileholder = ; > print @fileholder; * Jesse Erlbaum [2008-02-03 14:50]: > @fileholder = ; > return join("", @fileholder); Note that this is a really bad way to slurp a whole file. In the worst case (2nd example) it will consume over thrice the size of the file in memory. In general, if you do slurp an entire file, you should do it using `read`: read *FILE, $fileholder, -s *FILE; But if you do that and then `return $fileholder`, you?ll still get double the size of the file in memory consumption, because Perl makes a copy of the scalar to return it. The right approach in such cases is either passing around a file handle (so the output can be streamed directly) or a reference (but then the code which outputs it must still be written carefully to avoid making a copy). In case of a CGI::App app, the answer is to pass a file handle, which is done using CGI::Application::Plugin::Stream. That will also conveniently take care of setting all the requisite headers. -- *AUTOLOAD=*_;sub _{s/(.*)::(.*)/print$2,(",$\/"," ")[defined wantarray]/e;$1} &Just->another->Perl->hack; #Aristotle Pagaltzis // From lhernsen1015 at wowway.com Sun Feb 3 19:02:32 2008 From: lhernsen1015 at wowway.com (Lou Hernsen) Date: Sun Feb 3 19:07:01 2008 Subject: [cgiapp] How to send pdf file? References: <200802031114.29209@centrum.cz> Message-ID: <002c01c866c1$43330ec0$6401a8c0@lousmaster> I klnow how to send an email with text. How to I send an email with HTML in it? Is there a special header or command or what? Lou ----- Original Message ----- From: To: Sent: Sunday, February 03, 2008 5:14 AM Subject: Re:Re: [cgiapp] How to send pdf file? > Hi Michael, > thank you for your answer. > MIME headers are correct, but I still don't know how to send binary output through CGI::Application. > On "classic" way it is easy: > open(FILE, " @fileholder = ; > close (FILE); > > print "Content-Type: application/pdf\n"; > print "Content-Disposition: attachment;filename=test.pdf\n\n"; > print @fileholder; > > > How to do it through CGI::Application? > > Petr > > petr.vojkovsky@centrum.cz wrote: > > Hi, > > I want send to browser pdf file (it exist): > > mpeters@plusthree.com wrote: > >If it already exists, it's much easier than that. Basically you just tell the > >browser where to find the file and what type it is: > > >sub send_pdf { > >my $self = shift; > >$self->header_type('none'); # let's you set your own headers > >$self->header_props( > >-content-type => 'application/pdf', > >-content-disposition' => 'inline; filename=myfile.pdf' > >); > > > >return 'Download myfile.pdf'; > >} > > >Or something like that. It's kind of tricky when you need to deal with caching, > >SSL and IE - http://support.microsoft.com/kb/316431, but if you don't then it's > >pretty easy. > > >-- > >Michael Peters > >Developer > >Plus Three, LP > > > ##### CGI::Application community mailing list ################ > ## ## > ## To unsubscribe, or change your message delivery options, ## > ## visit: http://www.erlbaum.net/mailman/listinfo/cgiapp ## > ## ## > ## Web archive: http://www.erlbaum.net/pipermail/cgiapp/ ## > ## Wiki: http://cgiapp.erlbaum.net/ ## > ## ## > ################################################################ > > > > -- > No virus found in this incoming message. > Checked by AVG Free Edition. > Version: 7.5.516 / Virus Database: 269.19.16/1250 - Release Date: 1/29/08 10:20 PM > > From mpeters at plusthree.com Mon Feb 4 08:22:53 2008 From: mpeters at plusthree.com (Michael Peters) Date: Mon Feb 4 08:24:52 2008 Subject: [cgiapp] How to send pdf file? In-Reply-To: <002c01c866c1$43330ec0$6401a8c0@lousmaster> References: <200802031114.29209@centrum.cz> <002c01c866c1$43330ec0$6401a8c0@lousmaster> Message-ID: <47A711AD.3070106@plusthree.com> Lou Hernsen wrote: > I klnow how to send an email with text. > How to I send an email with HTML in it? > Is there a special header or command or what? Wow, can you say completely unrelated to this topic :) Next time, try starting a new thread. Not only will it not confuse people, but several people are probably already tuned out to the PDF conversation. So you're also missing out on an audience. Their called MIME emails. Do a search CPAN. I've used MIME::Lite with some success, but it's not really "lite". I think Email::MIME is one of the preferred modules now. -- Michael Peters Developer Plus Three, LP From lhernsen1015 at wowway.com Mon Feb 4 10:01:16 2008 From: lhernsen1015 at wowway.com (Lou Hernsen) Date: Mon Feb 4 10:04:35 2008 Subject: [cgiapp] NOT related to >>> How to send pdf file? References: <200802031114.29209@centrum.cz><002c01c866c1$43330ec0$6401a8c0@lousmaster> <47A711AD.3070106@plusthree.com> Message-ID: <001c01c8673e$d233c2e0$6401a8c0@lousmaster> Oh... sorrry.. I forgot to change the subject line.. by bad.... thanks for the help anyways... Lou ----- Original Message ----- From: "Michael Peters" To: "CGI Application" Sent: Monday, February 04, 2008 8:22 AM Subject: Re: [cgiapp] How to send pdf file? > Lou Hernsen wrote: > > I klnow how to send an email with text. > > How to I send an email with HTML in it? > > Is there a special header or command or what? > > Wow, can you say completely unrelated to this topic :) Next time, try starting a > new thread. Not only will it not confuse people, but several people are probably > already tuned out to the PDF conversation. So you're also missing out on an > audience. > > Their called MIME emails. Do a search CPAN. I've used MIME::Lite with some > success, but it's not really "lite". I think Email::MIME is one of the preferred > modules now. > > -- > Michael Peters > Developer > Plus Three, LP > > > ##### CGI::Application community mailing list ################ > ## ## > ## To unsubscribe, or change your message delivery options, ## > ## visit: http://www.erlbaum.net/mailman/listinfo/cgiapp ## > ## ## > ## Web archive: http://www.erlbaum.net/pipermail/cgiapp/ ## > ## Wiki: http://cgiapp.erlbaum.net/ ## > ## ## > ################################################################ > > > > -- > No virus found in this incoming message. > Checked by AVG Free Edition. > Version: 7.5.516 / Virus Database: 269.19.16/1250 - Release Date: 1/29/08 10:20 PM > > From mark at rawcane.net Tue Feb 5 05:44:19 2008 From: mark at rawcane.net (Mark Knoop) Date: Tue Feb 5 05:44:23 2008 Subject: [cgiapp] Persistence References: <200802031114.29209@centrum.cz><002c01c866c1$43330ec0$6401a8c0@lousmaster><47A711AD.3070106@plusthree.com> <001c01c8673e$d233c2e0$6401a8c0@lousmaster> Message-ID: <010701c867e4$0ff99b40$06fe000a@gboffice.gorillabox.net> Hi I'm new to CGI::Application. I like the way it makes me organize the script but I guess I could do it in this way without CGI:Application so I just want to be sure I fully understand the benefits. Given that I am not running it under mod_perl at this stage is each instance request a completely seperate event or does CGI::Application somehow keep track of something between one user's calls to the same instance? If so how? If not then does CGI::Application offer any other benefits than helping one to organize ones code better? I have read through lots of docs but I seem to be missing this key point... if there is a doc specifically related to this that would be a huge help. Cheers Mark From mark at rawcane.net Tue Feb 5 06:59:19 2008 From: mark at rawcane.net (Mark Knoop) Date: Tue Feb 5 07:00:43 2008 Subject: [cgiapp] Persistence References: <200802031114.29209@centrum.cz><002c01c866c1$43330ec0$6401a8c0@lousmaster><47A711AD.3070106@plusthree.com><001c01c8673e$d233c2e0$6401a8c0@lousmaster> <010701c867e4$0ff99b40$06fe000a@gboffice.gorillabox.net> Message-ID: <014701c867ee$8a8c0a50$06fe000a@gboffice.gorillabox.net> > Hi > > I'm new to CGI::Application. > > I like the way it makes me organize the script but I guess I could do it > in this way without CGI:Application so I just want to be sure I fully > understand the benefits. > > Given that I am not running it under mod_perl at this stage is each > instance request a completely seperate event or does CGI::Application > somehow keep track of something between one user's calls to the same > instance? > > If so how? > > If not then does CGI::Application offer any other benefits than helping > one to organize ones code better? > > I have read through lots of docs but I seem to be missing this key > point... if there is a doc specifically related to this that would be a > huge help. > > Cheers > Mark > > > Ok... have made some progress. It seems I can use the CGI::Application::Plugin::Session for the persistence side of things. But still feel like I am missing a trick.... will persevere and see if things become clearer. From ceeshek at gmail.com Tue Feb 5 08:18:39 2008 From: ceeshek at gmail.com (Cees Hek) Date: Tue Feb 5 08:18:43 2008 Subject: [cgiapp] Persistence In-Reply-To: <014701c867ee$8a8c0a50$06fe000a@gboffice.gorillabox.net> References: <200802031114.29209@centrum.cz> <002c01c866c1$43330ec0$6401a8c0@lousmaster> <47A711AD.3070106@plusthree.com> <001c01c8673e$d233c2e0$6401a8c0@lousmaster> <010701c867e4$0ff99b40$06fe000a@gboffice.gorillabox.net> <014701c867ee$8a8c0a50$06fe000a@gboffice.gorillabox.net> Message-ID: On Feb 5, 2008 10:59 PM, Mark Knoop wrote: > > Hi > > > > I'm new to CGI::Application. Welcome > > I like the way it makes me organize the script but I guess I could do it > > in this way without CGI:Application so I just want to be sure I fully > > understand the benefits. > > > > Given that I am not running it under mod_perl at this stage is each > > instance request a completely seperate event or does CGI::Application > > somehow keep track of something between one user's calls to the same > > instance? No, CGI::Application by itself does not offer any persistance. Each request will create a new CGI::Application object. You can use mod_perl or FastCGI to make the code persistent, but it will still create a new CGI::Application object on each request. > > If not then does CGI::Application offer any other benefits than helping > > one to organize ones code better? If you look at the source code for CGI::Application you will see that it is not very big and not very complex. So yes you are correct in thinking that you can probably structure your code that way without using CGI::Application itself. The benefit in using it is that you are using a module that has been tried and tested over many years by thousands of people. These people all structure their apps in a very similar way (ie the CGI::Application way), which means you can benefit from several thing: Code re-use - many people have spent time building lots of extensions to CGI::Application that make life for a web developer much easier. By using CGI::Application as your base you can benefit from all this work (search CPAN for CGI::Application::Plugin to see what is publicly available). Lower your Technical Debt - Building your own application code structure and rebuilding your own version of all the plugins that are available means you have to maintain all that extra code. And the person that takes over your project in the future has to maintain and understand what you have built. Using well supported modules and best practices lowers your technical debt for the future. It also gives future maintainers a starting place to look for help and documentation. Help from your peers - this mailing list has many people that may be able to help you if you run into problems, but only if you use CGI::Application. Building it all yourself means you are less likely to find someone that can (or is willing to) help you. > Ok... have made some progress. It seems I can use the > CGI::Application::Plugin::Session for the persistence side of things. But > still feel like I am missing a trick.... will persevere and see if things > become clearer. So it looks like you have already found some of the plugins :) The Session plugin will allow you to maintain state variables across requests. So if all you want to do is store some info for a user between requests (like an authentication token, or maybe their language preference, etc...) then the Session plugin will definately do that for you. If you still feel you are missing something, then explain to us what you are trying to do, and what you are expecting an application framework like CGI::Application to do for you. Cheers, Cees Hek From mark at rawcane.net Tue Feb 5 08:29:55 2008 From: mark at rawcane.net (Mark Knoop) Date: Tue Feb 5 08:30:01 2008 Subject: [cgiapp] Persistence References: <200802031114.29209@centrum.cz><002c01c866c1$43330ec0$6401a8c0@lousmaster><47A711AD.3070106@plusthree.com><001c01c8673e$d233c2e0$6401a8c0@lousmaster><010701c867e4$0ff99b40$06fe000a@gboffice.gorillabox.net><014701c867ee$8a8c0a50$06fe000a@gboffice.gorillabox.net> Message-ID: <01ac01c867fb$32a31560$06fe000a@gboffice.gorillabox.net> > On Feb 5, 2008 10:59 PM, Mark Knoop wrote: >> > Hi >> > >> > I'm new to CGI::Application. > > Welcome > >> > I like the way it makes me organize the script but I guess I could do >> > it >> > in this way without CGI:Application so I just want to be sure I fully >> > understand the benefits. >> > >> > Given that I am not running it under mod_perl at this stage is each >> > instance request a completely seperate event or does CGI::Application >> > somehow keep track of something between one user's calls to the same >> > instance? > > No, CGI::Application by itself does not offer any persistance. Each > request will create a new CGI::Application object. You can use > mod_perl or FastCGI to make the code persistent, but it will still > create a new CGI::Application object on each request. > >> > If not then does CGI::Application offer any other benefits than helping >> > one to organize ones code better? > > If you look at the source code for CGI::Application you will see that > it is not very big and not very complex. So yes you are correct in > thinking that you can probably structure your code that way without > using CGI::Application itself. > > The benefit in using it is that you are using a module that has been > tried and tested over many years by thousands of people. These people > all structure their apps in a very similar way (ie the > CGI::Application way), which means you can benefit from several thing: > > Code re-use > - many people have spent time building lots of extensions to > CGI::Application that make life for a web developer much easier. By > using CGI::Application as your base you can benefit from all this work > (search CPAN for CGI::Application::Plugin to see what is publicly > available). > > Lower your Technical Debt > - Building your own application code structure and rebuilding your own > version of all the plugins that are available means you have to > maintain all that extra code. And the person that takes over your > project in the future has to maintain and understand what you have > built. Using well supported modules and best practices lowers your > technical debt for the future. It also gives future maintainers a > starting place to look for help and documentation. > > Help from your peers > - this mailing list has many people that may be able to help you if > you run into problems, but only if you use CGI::Application. Building > it all yourself means you are less likely to find someone that can (or > is willing to) help you. > > >> Ok... have made some progress. It seems I can use the >> CGI::Application::Plugin::Session for the persistence side of things. >> But >> still feel like I am missing a trick.... will persevere and see if things >> become clearer. > > So it looks like you have already found some of the plugins :) The > Session plugin will allow you to maintain state variables across > requests. So if all you want to do is store some info for a user > between requests (like an authentication token, or maybe their > language preference, etc...) then the Session plugin will definately > do that for you. > > If you still feel you are missing something, then explain to us what > you are trying to do, and what you are expecting an application > framework like CGI::Application to do for you. > > Cheers, > > Cees Hek > Thanks for the very thorough and helpful response. I will probably have many questions over the coming weeks but for now I suspect I need to try some things out and see how I go. It is already improving my (very messy) code just from the way it is forcing me to think about and structure my application but I guess will take some trial and error to fully appreciate the benefits and establish best practices. Will be back with some questions regarding specifics soon! Cheers Mark From breadwild at gmail.com Tue Feb 5 08:41:58 2008 From: breadwild at gmail.com (Brad Cathey) Date: Tue Feb 5 08:42:01 2008 Subject: [cgiapp] Persistence In-Reply-To: <010701c867e4$0ff99b40$06fe000a@gboffice.gorillabox.net> References: <200802031114.29209@centrum.cz> <002c01c866c1$43330ec0$6401a8c0@lousmaster> <47A711AD.3070106@plusthree.com> <001c01c8673e$d233c2e0$6401a8c0@lousmaster> <010701c867e4$0ff99b40$06fe000a@gboffice.gorillabox.net> Message-ID: <9c83f0330802050541k21c82bfbm7e4c3fa13335218b@mail.gmail.com> Bottomline, CGI::App does lots of the work for you. Life is easier. I could not develop for the Web without it. Brad On Feb 5, 2008 4:44 AM, Mark Knoop wrote: > Hi > > I'm new to CGI::Application. > > I like the way it makes me organize the script but I guess I could do it in > this way without CGI:Application so I just want to be sure I fully > understand the benefits. > > Given that I am not running it under mod_perl at this stage is each instance > request a completely seperate event or does CGI::Application somehow keep > track of something between one user's calls to the same instance? > > If so how? > > If not then does CGI::Application offer any other benefits than helping one > to organize ones code better? > > I have read through lots of docs but I seem to be missing this key point... > if there is a doc specifically related to this that would be a huge help. > > Cheers > Mark > > > > > > ##### CGI::Application community mailing list ################ > ## ## > ## To unsubscribe, or change your message delivery options, ## > ## visit: http://www.erlbaum.net/mailman/listinfo/cgiapp ## > ## ## > ## Web archive: http://www.erlbaum.net/pipermail/cgiapp/ ## > ## Wiki: http://cgiapp.erlbaum.net/ ## > ## ## > ################################################################ > > From petr.vojkovsky at centrum.cz Tue Feb 5 14:08:12 2008 From: petr.vojkovsky at centrum.cz (petr.vojkovsky@centrum.cz) Date: Tue Feb 5 14:08:18 2008 Subject: [cgiapp] Re: How to send pdf file? In-Reply-To: <20080203191730.GG25553@klangraum> References: 200802031114.29209@centrum.cz> <20080203191730.GG25553@klangraum> Message-ID: <200802052008.13631@centrum.cz> Thank you very much, guys. It works! Best regards, Petr ______________________________________________________________ > Od: pagaltzis@gmx.de > Komu: cgiapp@lists.erlbaum.net > Datum: 03.02.2008 20:26 > P?edm?t: [cgiapp] Re: How to send pdf file? > >* petr.vojkovsky@centrum.cz [2008-02-03 11:55]: >> @fileholder = ; >> print @fileholder; > >* Jesse Erlbaum [2008-02-03 14:50]: >> @fileholder = ; >> return join("", @fileholder); > >Note that this is a really bad way to slurp a whole file. In the >worst case (2nd example) it will consume over thrice the size of >the file in memory. > >In general, if you do slurp an entire file, you should do it >using `read`: > > read *FILE, $fileholder, -s *FILE; > >But if you do that and then `return $fileholder`, you?ll still >get double the size of the file in memory consumption, because >Perl makes a copy of the scalar to return it. > >The right approach in such cases is either passing around a file >handle (so the output can be streamed directly) or a reference >(but then the code which outputs it must still be written >carefully to avoid making a copy). > >In case of a CGI::App app, the answer is to pass a file handle, >which is done using CGI::Application::Plugin::Stream. That will >also conveniently take care of setting all the requisite headers. > >-- >*AUTOLOAD=*_;sub _{s/(.*)::(.*)/print$2,(",$\/"," ")[defined wantarray]/e;$1} >&Just->another->Perl->hack; >#Aristotle Pagaltzis // > >##### CGI::Application community mailing list ################ >## ## >## To unsubscribe, or change your message delivery options, ## >## visit: http://www.erlbaum.net/mailman/listinfo/cgiapp ## >## ## >## Web archive: http://www.erlbaum.net/pipermail/cgiapp/ ## >## Wiki: http://cgiapp.erlbaum.net/ ## >## ## >################################################################ > > From ron at savage.net.au Tue Feb 5 16:18:02 2008 From: ron at savage.net.au (Ron Savage) Date: Tue Feb 5 16:17:14 2008 Subject: [cgiapp] Persistence In-Reply-To: <010701c867e4$0ff99b40$06fe000a@gboffice.gorillabox.net> References: <200802031114.29209@centrum.cz> <002c01c866c1$43330ec0$6401a8c0@lousmaster><47A711AD.3070106@plusthree.com> <001c01c8673e$d233c2e0$6401a8c0@lousmaster> <010701c867e4$0ff99b40$06fe000a@gboffice.gorillabox.net> Message-ID: <1202246282.27200.94.camel@zoe.savage.net.au> On Tue, 2008-02-05 at 10:44 +0000, Mark Knoop wrote: Hi Mark > I have read through lots of docs but I seem to be missing this key point... > if there is a doc specifically related to this that would be a huge help. On top of the other responses, I'd add: Your application must keep track of a 'session'. The main ways to do that are: o Add a hidden field to each CGI form, in which you send out to the client the id of their session, so that when the use submits the form you get back their id. This is my preferred alternative o Add the session id to a cookie sent from your code, which you get back later from the client. This is a commonly-used method o Add the session id to the URL. This method has the most problems, and is not recommended. The session id is generated by CGI::Session. -- Ron Savage ron@savage.net.au http://savage.net.au/index.html From mark at rawcane.net Wed Feb 6 03:16:33 2008 From: mark at rawcane.net (Mark Knoop) Date: Wed Feb 6 03:16:39 2008 Subject: [cgiapp] Persistence References: <200802031114.29209@centrum.cz><002c01c866c1$43330ec0$6401a8c0@lousmaster><47A711AD.3070106@plusthree.com><001c01c8673e$d233c2e0$6401a8c0@lousmaster><010701c867e4$0ff99b40$06fe000a@gboffice.gorillabox.net> <1202246282.27200.94.camel@zoe.savage.net.au> Message-ID: <039401c86898$95ec7b00$06fe000a@gboffice.gorillabox.net> > > On top of the other responses, I'd add: > Your application must keep track of a 'session'. The main ways to do > that are: > > o Add a hidden field to each CGI form, in which you send out to the > client the id of their session, so that when the use submits the form > you get back their id. This is my preferred alternative > > o Add the session id to a cookie sent from your code, which you get back > later from the client. This is a commonly-used method > > o Add the session id to the URL. This method has the most problems, and > is not recommended. > > The session id is generated by CGI::Session. Surely 1 and 3 are the same (except possibly you are talking about a post vs get)? What are the problems with the last option? This is the way I have to approach it as I can't rely on the browsers I am dealing with to allow cookies. It's worked fine up to now... From mark at rawcane.net Wed Feb 6 07:16:26 2008 From: mark at rawcane.net (Mark Knoop) Date: Wed Feb 6 07:16:44 2008 Subject: [cgiapp] Changing CGI::Session name within a CGI::Application Message-ID: <00bd01c868ba$18a26200$06fe000a@gboffice.gorillabox.net> Hi I am trying to use the CGI::Application::Plugin::Session but I am getting a bit confused with what objects are what. In my cgiapp_init method I have the following: CGI::Session->name('lsid'); $self->session_config( CGI_SESSION_OPTIONS => [ "driver:File", $self->query, { Dir=>$session_path } ], DEFAULT_EXPIRY => '+5m', SEND_COOKIE => 0, ); Then in my cgiapp_prerun I use my $session = $self->session; unless ( $self->session->param('rsid') ) { $self->session->param('rsid', 'SOME_VALUE'); # some code to change prerun mode to redirect to external site } and then use $self->session->id as the value to lsid param in a callback url which I pass to an external app that I then redirect to so that when they redirect back with the lsid param in the query string it will use that as the session id. For some reason it is not picking up the session data correctly ie it is acting as if rsid in the session data does not exist and redoing the redirect though I can't tell whether it is because it is not automatically using the lsid param (which is definitely there) or whether it is not creating the session successfully in the first place. It is going to be tricky to create a working example because of the redirects but is there anything that I am obviously approaching in the wrong way or any obvious errors? Is there a way I test to see whether $self->session is creating a new session or picking up an existing one or not working at all? Cheers Mark From mark at rawcane.net Wed Feb 6 09:19:36 2008 From: mark at rawcane.net (Mark Knoop) Date: Wed Feb 6 09:19:51 2008 Subject: [cgiapp] Changing CGI::Session name within a CGI::Application References: <00bd01c868ba$18a26200$06fe000a@gboffice.gorillabox.net> Message-ID: <014901c868cb$4dd3b8f0$06fe000a@gboffice.gorillabox.net> > Hi > > I am trying to use the CGI::Application::Plugin::Session but I am getting > a bit confused with what objects are what. > ... Ok. I have made some progress in pinnign this down and it seems I have a problem with the session object. This code recreates the scenario. package GSystem::Test; use base 'CGI::Application'; use strict; use CGI::Carp qw(fatalsToBrowser); use CGI::Application::Plugin::Session; sub cgiapp_init { my $self = shift; my $session_path; CGI::Session->name('lsid'); $self->session_config( CGI_SESSION_OPTIONS => [ "driver:File", $self->query, { Dir=>'D:\sessions\\' } ], # running on windows/IIS DEFAULT_EXPIRY => '+5m', SEND_COOKIE => 0, ); } sub setup { my $self = shift; $self->start_mode('no_lsid'); $self->run_modes( 'got_lsid' => 'got_lsid', 'no_lsid' => 'no_lsid' ); } sub cgiapp_prerun { my $self = shift; my $session = $self->session; if ($self->query->param('lsid') ) { $self->prerun_mode('got_lsid'); } else { $self->session->param('rsid', 'SOME_VALUE'); $self->prerun_mode('no_lsid'); } } sub got_lsid { my $self = shift; my $lsid = $self->session->id; my $rsid = $self->session->param('rsid'); my $output = <Got lsid $lsid - rsid is $rsid EOF return $output; } sub no_lsid { my $self = shift; my $lsid = $self->session->id; my $output = <New lsid is $lsid - Link EOF return $output; } 1; If I call this with no parameters it returns a link with the new session id as a value to lsid. If I click on this then it runs the got_lsid run mode but has not successfully retrieved the rsid value from the session data and has created a new session id. Any ideas on how to pin this down? I'm sure I am doing something dumb... Cheers Mark From mark at rawcane.net Wed Feb 6 09:56:14 2008 From: mark at rawcane.net (Mark Knoop) Date: Wed Feb 6 09:56:28 2008 Subject: [cgiapp] Changing CGI::Session name within a CGI::Application References: <00bd01c868ba$18a26200$06fe000a@gboffice.gorillabox.net> <014901c868cb$4dd3b8f0$06fe000a@gboffice.gorillabox.net> Message-ID: <017201c868d0$6beb2d00$06fe000a@gboffice.gorillabox.net> > >> Hi >> >> I am trying to use the CGI::Application::Plugin::Session but I am getting >> a bit confused with what objects are what. >> ... > > Ok. I have made some progress in pinnign this down and it seems I have a > problem with the session object. > > This code recreates the scenario. > > package GSystem::Test; > use base 'CGI::Application'; > use strict; > > use CGI::Carp qw(fatalsToBrowser); > use CGI::Application::Plugin::Session; > > sub cgiapp_init { > > my $self = shift; > my $session_path; > > CGI::Session->name('lsid'); > $self->session_config( > CGI_SESSION_OPTIONS => [ "driver:File", $self->query, { > Dir=>'D:\sessions\\' } ], # running on windows/IIS > DEFAULT_EXPIRY => '+5m', > SEND_COOKIE => 0, > ); > > } > > sub setup { > > my $self = shift; > > $self->start_mode('no_lsid'); > > $self->run_modes( > 'got_lsid' => 'got_lsid', > 'no_lsid' => 'no_lsid' > ); > > > } > > sub cgiapp_prerun { > > my $self = shift; > > my $session = $self->session; > > if ($self->query->param('lsid') ) { > $self->prerun_mode('got_lsid'); > } else { > $self->session->param('rsid', 'SOME_VALUE'); > $self->prerun_mode('no_lsid'); > } > } > > sub got_lsid { > > my $self = shift; > > my $lsid = $self->session->id; > my $rsid = $self->session->param('rsid'); > > my $output = < > Got lsid $lsid - rsid is $rsid > > EOF > > return $output; > > } > > sub no_lsid { > > my $self = shift; > > my $lsid = $self->session->id; > > my $output = < > New lsid is $lsid - "http://my.url.com/test.pl?lsid=$lsid">Link > > EOF > > return $output; > } > > 1; > > If I call this with no parameters it returns a link with the new session > id as a value to lsid. If I click on this then it runs the got_lsid run > mode but has not successfully retrieved the rsid value from the session > data and has created a new session id. > I just tried recreating this using CGI::Session directly and it worked as I had hoped, even with cookies disabled in my browser. ################################ use strict; #use warnings; use CGI qw/:standard/; use CGI::Session; my $cgi = new CGI; CGI::Session->name('lsid'); my $session = new CGI::Session("driver:File", $cgi, {Directory=>'D:\sessions\\'}); $session->expire('+5m'); my $lsid = $session->id; my $rsid; if ($cgi->param('lsid') ) { $rsid = $session->param('rsid'); print $cgi->header; print <Got lsid $lsid - rsid is $rsid EOF } else { $session->param('rsid','SOME_VALUE'); print $cgi->header; print <New lsid is $lsid - Link EOF } exit; ################## The notable difference is that I can see the session data files appearing in D:\sessions whereas they were not with my previous attempt. Any thoughts? Mark From mark at rawcane.net Wed Feb 6 11:10:34 2008 From: mark at rawcane.net (Mark Knoop) Date: Wed Feb 6 11:10:40 2008 Subject: [cgiapp] Changing CGI::Session name within a CGI::Application Message-ID: <01f901c868da$ce067cb0$06fe000a@gboffice.gorillabox.net> Aargh. Ignore all the above. For some insane reason I was using Dir instead of Directory in the session_config inside the CGI::Application version. Still... was great opportunity to really get to grips with the module :) From ron at savage.net.au Wed Feb 6 16:47:25 2008 From: ron at savage.net.au (Ron Savage) Date: Wed Feb 6 16:46:32 2008 Subject: [cgiapp] Persistence In-Reply-To: <039401c86898$95ec7b00$06fe000a@gboffice.gorillabox.net> References: <200802031114.29209@centrum.cz> <002c01c866c1$43330ec0$6401a8c0@lousmaster><47A711AD.3070106@plusthree.com> <001c01c8673e$d233c2e0$6401a8c0@lousmaster> <010701c867e4$0ff99b40$06fe000a@gboffice.gorillabox.net> <1202246282.27200.94.camel@zoe.savage.net.au> <039401c86898$95ec7b00$06fe000a@gboffice.gorillabox.net> Message-ID: <1202334445.27200.103.camel@zoe.savage.net.au> On Wed, 2008-02-06 at 08:16 +0000, Mark Knoop wrote: Hi Mark > > > > On top of the other responses, I'd add: > > Your application must keep track of a 'session'. The main ways to do > > that are: > > > > o Add a hidden field to each CGI form, in which you send out to the > > client the id of their session, so that when the use submits the form > > you get back their id. This is my preferred alternative > > > > o Add the session id to a cookie sent from your code, which you get back > > later from the client. This is a commonly-used method > > > > o Add the session id to the URL. This method has the most problems, and > > is not recommended. > > > > The session id is generated by CGI::Session. > > Surely 1 and 3 are the same (except possibly you are talking about a post vs > get)? Not really. > What are the problems with the last option? This is the way I have to > approach it as I can't rely on the browsers I am dealing with to allow > cookies. It's worked fine up to now... Google for XSS - Cross-site scripting attacks, as a starter. -- Ron Savage ron@savage.net.au http://savage.net.au/index.html From mpeters at plusthree.com Wed Feb 6 16:47:17 2008 From: mpeters at plusthree.com (Michael Peters) Date: Wed Feb 6 16:49:21 2008 Subject: [cgiapp] Persistence In-Reply-To: <1202334445.27200.103.camel@zoe.savage.net.au> References: <200802031114.29209@centrum.cz> <002c01c866c1$43330ec0$6401a8c0@lousmaster><47A711AD.3070106@plusthree.com> <001c01c8673e$d233c2e0$6401a8c0@lousmaster> <010701c867e4$0ff99b40$06fe000a@gboffice.gorillabox.net> <1202246282.27200.94.camel@zoe.savage.net.au> <039401c86898$95ec7b00$06fe000a@gboffice.gorillabox.net> <1202334445.27200.103.camel@zoe.savage.net.au> Message-ID: <47AA2AE5.4020208@plusthree.com> Ron Savage wrote: >>> o Add the session id to the URL. This method has the most problems, and >>> is not recommended. >>> >>> The session id is generated by CGI::Session. >> Surely 1 and 3 are the same (except possibly you are talking about a post vs >> get)? > > Not really. > >> What are the problems with the last option? This is the way I have to >> approach it as I can't rely on the browsers I am dealing with to allow >> cookies. It's worked fine up to now... > > Google for XSS - Cross-site scripting attacks, as a starter. Maybe I'm being dense, but XSS is about letting user's embed HTML/JS into other documents. So you need to protect against nefarious JS folks. How does putting the session id in the URL cause XSS problems? XSS is all about *escaping* user entered data when outputting it. -- Michael Peters Developer Plus Three, LP From azfuller at gmail.com Wed Feb 6 17:11:18 2008 From: azfuller at gmail.com (Mark Fuller) Date: Wed Feb 6 17:11:20 2008 Subject: [cgiapp] Persistence In-Reply-To: <1202334445.27200.103.camel@zoe.savage.net.au> References: <200802031114.29209@centrum.cz> <002c01c866c1$43330ec0$6401a8c0@lousmaster> <47A711AD.3070106@plusthree.com> <001c01c8673e$d233c2e0$6401a8c0@lousmaster> <010701c867e4$0ff99b40$06fe000a@gboffice.gorillabox.net> <1202246282.27200.94.camel@zoe.savage.net.au> <039401c86898$95ec7b00$06fe000a@gboffice.gorillabox.net> <1202334445.27200.103.camel@zoe.savage.net.au> Message-ID: > > > o Add the session id to the URL. This method has the most problems, and > > > is not recommended. > > > > What are the problems with the last option? ... > > Google for XSS - Cross-site scripting attacks, as a starter. I thought the problem with putting the session ID in the URL is that the user might copy/paste the URL to others. When they try to use it, the app would have no way to know it's not the real user? Maybe I've misunderstood the original question? Mark From mpeters at plusthree.com Wed Feb 6 17:16:47 2008 From: mpeters at plusthree.com (Michael Peters) Date: Wed Feb 6 17:18:51 2008 Subject: [cgiapp] Persistence In-Reply-To: References: <200802031114.29209@centrum.cz> <002c01c866c1$43330ec0$6401a8c0@lousmaster> <47A711AD.3070106@plusthree.com> <001c01c8673e$d233c2e0$6401a8c0@lousmaster> <010701c867e4$0ff99b40$06fe000a@gboffice.gorillabox.net> <1202246282.27200.94.camel@zoe.savage.net.au> <039401c86898$95ec7b00$06fe000a@gboffice.gorillabox.net> <1202334445.27200.103.camel@zoe.savage.net.au> Message-ID: <47AA31CF.6010608@plusthree.com> Mark Fuller wrote: >>>> o Add the session id to the URL. This method has the most problems, and >>>> is not recommended. >>> What are the problems with the last option? ... >> Google for XSS - Cross-site scripting attacks, as a starter. > > I thought the problem with putting the session ID in the URL is that > the user might copy/paste the URL to others. When they try to use it, > the app would have no way to know it's not the real user? While that is a problem (it holds true with any user identifiable information not just sessions. You need to especially watch what you put into emails since they will get forwarded) it's not XSS. XSS is Cross Site Scripting. So you need 2 domains (hence the cross-site) and it involves Javascript (can also be ActionScript/Flash, VBScript, or any other future client-side scripting language). Basically it's problem of people embedding Javascript into a page that others will see. That Javascript can steal sessions, etc from the user who sees it. It doesn't matter if the session id is in the URL or a cookie, Javascript can see both. This is why escaping any data that could potentially come from a user is so important. or [% foo | html %] -- Michael Peters Developer Plus Three, LP From fluffymike at googlemail.com Wed Feb 6 17:51:10 2008 From: fluffymike at googlemail.com (Mike Tonks) Date: Wed Feb 6 17:51:14 2008 Subject: [cgiapp] Multiple run modes Message-ID: <727692630802061451v772b03dibca485821e077e5f@mail.gmail.com> Hi, I'm looking at CGI::Application prior to use, and one thing is unclear to me. I'll outline a little senario to demonstrate the question: I have a simple app with four run modes - list, view, edit & update list does what it say on the tin - lists records in a data table view ditto, displays a single record edit displays a form to edit (or add) a record update sends the posted data to the database In my example, I would like the update run mode to then call the view run mode, rather then simply display a rather useless 'update complete' message. Is there a good way to do this with CA? I suppose a simple option is to simply have update() call view() and return the results, but I wondered if there was a preferred solution to this? Another thought that occurred from scanning the docs would be to put the update function in prerun, but this seems wrong somehow. Thanks for any assistance, mike From dan.horne at redbone.co.nz Wed Feb 6 18:39:03 2008 From: dan.horne at redbone.co.nz (Dan Horne) Date: Wed Feb 6 18:39:25 2008 Subject: [cgiapp] Persistence In-Reply-To: References: <200802031114.29209@centrum.cz> <002c01c866c1$43330ec0$6401a8c0@lousmaster> <47A711AD.3070106@plusthree.com> <001c01c8673e$d233c2e0$6401a8c0@lousmaster> <010701c867e4$0ff99b40$06fe000a@gboffice.gorillabox.net> <1202246282.27200.94.camel@zoe.savage.net.au> <039401c86898$95ec7b00$06fe000a@gboffice.gorillabox.net> <1202334445.27200.103.camel@zoe.savage.net.au> Message-ID: <45189.210.54.245.44.1202341143.squirrel@mail.redbone.co.nz> Mark Fuller said: > I thought the problem with putting the session ID in the URL is that > the user might copy/paste the URL to others. When they try to use it, > the app would have no way to know it's not the real user? > Another problem is bookmarks. A user may bookmark a page, but when they come back a couple of days later, the session has expired. They might also email a link to others, and that link may not work for the same reason. From dan.horne at redbone.co.nz Wed Feb 6 18:43:26 2008 From: dan.horne at redbone.co.nz (Dan Horne) Date: Wed Feb 6 18:43:29 2008 Subject: [cgiapp] Multiple run modes In-Reply-To: <727692630802061451v772b03dibca485821e077e5f@mail.gmail.com> References: <727692630802061451v772b03dibca485821e077e5f@mail.gmail.com> Message-ID: <46471.210.54.245.44.1202341406.squirrel@mail.redbone.co.nz> Mike Tonks said: > Hi, > > I'm looking at CGI::Application prior to use, and one thing is unclear to > me. > > I'll outline a little senario to demonstrate the question: > > I have a simple app with four run modes - list, view, edit & update > > list does what it say on the tin - lists records in a data table > > view ditto, displays a single record > > edit displays a form to edit (or add) a record > > update sends the posted data to the database > > > In my example, I would like the update run mode to then call the view > run mode, rather then simply display a rather useless 'update > complete' message. > > Is there a good way to do this with CA? I suppose a simple option is > to simply have update() call view() and return the results, but I > wondered if there was a preferred solution to this? Well you could simply call the view runmode after the update runmode has run, but there are two recommended ways - CGI::Application::Plugin::Forward and CGI::Application::Plugin::Redirect. I prefer the latter, as a refresh of the browser doesn't resubmit the data (which the first two methods would) > > Another thought that occurred from scanning the docs would be to put > the update function in prerun, but this seems wrong somehow. > You probably want to avoid this - it's just getting messy From dan.horne at redbone.co.nz Wed Feb 6 18:48:24 2008 From: dan.horne at redbone.co.nz (Dan Horne) Date: Wed Feb 6 18:49:14 2008 Subject: [cgiapp] Persistence In-Reply-To: <45189.210.54.245.44.1202341143.squirrel@mail.redbone.co.nz> References: <200802031114.29209@centrum.cz> <002c01c866c1$43330ec0$6401a8c0@lousmaster> <47A711AD.3070106@plusthree.com> <001c01c8673e$d233c2e0$6401a8c0@lousmaster> <010701c867e4$0ff99b40$06fe000a@gboffice.gorillabox.net> <1202246282.27200.94.camel@zoe.savage.net.au> <039401c86898$95ec7b00$06fe000a@gboffice.gorillabox.net> <1202334445.27200.103.camel@zoe.savage.net.au> <45189.210.54.245.44.1202341143.squirrel@mail.redbone.co.nz> Message-ID: <48019.210.54.245.44.1202341704.squirrel@mail.redbone.co.nz> Dan Horne said: > Mark Fuller said: > >> I thought the problem with putting the session ID in the URL is that >> the user might copy/paste the URL to others. When they try to use it, >> the app would have no way to know it's not the real user? >> > > Another problem is bookmarks. A user may bookmark a page, but when they > come back a couple of days later, the session has expired. They might also > email a link to others, and that link may not work for the same reason. > > Oh and having the session in the URL may affect your caching algorithms, which may or may not be a problem, depending on your app. If an e-commerce app used page-based caching (say a product page as determined by the request URL) then each session would have a unique URL, and hence would get its own cache. From barry.moore at genetics.utah.edu Wed Feb 6 19:04:56 2008 From: barry.moore at genetics.utah.edu (Barry Moore) Date: Wed Feb 6 19:09:00 2008 Subject: [cgiapp] Persistence In-Reply-To: <47AA31CF.6010608@plusthree.com> References: <200802031114.29209@centrum.cz> <002c01c866c1$43330ec0$6401a8c0@lousmaster> <47A711AD.3070106@plusthree.com> <001c01c8673e$d233c2e0$6401a8c0@lousmaster> <010701c867e4$0ff99b40$06fe000a@gboffice.gorillabox.net> <1202246282.27200.94.camel@zoe.savage.net.au> <039401c86898$95ec7b00$06fe000a@gboffice.gorillabox.net> <1202334445.27200.103.camel@zoe.savage.net.au> <47AA31CF.6010608@plusthree.com> Message-ID: <78A40BC4-66B7-4759-9C0C-F9F8BA478B88@genetics.utah.edu> This is an interesting thread, and XSS is something that I haven't really understood. Let me see if I'm understanding this correctly: Basically one version of an XSS attack would be for me to enter javascript code into a form on your web page. Then if you include my form submission in other web pages then my javascript could execute on any other users machine that subsequently loaded those tainted pages. My JS code could do anything that they could do including contact your server on behalf of them and send data back to my server. Is this correct? Then the rational for you to html escape any input that comes from me and any other user is because that escaping would render the JS code in-operable. Is that correct? So then is is safe to assume that if the data from your form never gets sent back to other users (i.e. it only gets analyzed by your server - such as a search form) or if you check for JS code in some other way, then that would also prevent this form of XSS? Barry On Feb 6, 2008, at 3:16 PM, Michael Peters wrote: > > > Mark Fuller wrote: >>>>> o Add the session id to the URL. This method has the most >>>>> problems, and >>>>> is not recommended. >>>> What are the problems with the last option? ... >>> Google for XSS - Cross-site scripting attacks, as a starter. >> >> I thought the problem with putting the session ID in the URL is that >> the user might copy/paste the URL to others. When they try to use it, >> the app would have no way to know it's not the real user? > > While that is a problem (it holds true with any user identifiable > information > not just sessions. You need to especially watch what you put into > emails since > they will get forwarded) it's not XSS. > > XSS is Cross Site Scripting. So you need 2 domains (hence the cross- > site) and it > involves Javascript (can also be ActionScript/Flash, VBScript, or > any other > future client-side scripting language). Basically it's problem of > people > embedding Javascript into a page that others will see. That > Javascript can steal > sessions, etc from the user who sees it. It doesn't matter if the > session id is > in the URL or a cookie, Javascript can see both. > > This is why escaping any data that could potentially come from a > user is so > important. > > > or > [% foo | html %] > > -- > Michael Peters > Developer > Plus Three, LP > > > ##### CGI::Application community mailing list ################ > ## ## > ## To unsubscribe, or change your message delivery options, ## > ## visit: http://www.erlbaum.net/mailman/listinfo/cgiapp ## > ## ## > ## Web archive: http://www.erlbaum.net/pipermail/cgiapp/ ## > ## Wiki: http://cgiapp.erlbaum.net/ ## > ## ## > ################################################################ > From barry.moore at genetics.utah.edu Wed Feb 6 19:06:49 2008 From: barry.moore at genetics.utah.edu (Barry Moore) Date: Wed Feb 6 19:09:00 2008 Subject: [cgiapp] XSS References: <78A40BC4-66B7-4759-9C0C-F9F8BA478B88@genetics.utah.edu> Message-ID: <06483281-05D5-4CFB-B4EF-B99B18BEF917@genetics.utah.edu> Sorry for the second post. I decided that this topic has diverged enough it should be a separate thread. Reply to this one instead if you see it in time. This is an interesting thread, and XSS is something that I haven't really understood. Let me see if I'm understanding this correctly: Basically one version of an XSS attack would be for me to enter javascript code into a form on your web page. Then if you include my form submission in other web pages then my javascript could execute on any other users machine that subsequently loaded those tainted pages. My JS code could do anything that they could do including contact your server on behalf of them and send data back to my server. Is this correct? Then the rational for you to html escape any input that comes from me and any other user is because that escaping would render the JS code in-operable. Is that correct? So then is is safe to assume that if the data from your form never gets sent back to other users (i.e. it only gets analyzed by your server - such as a search form) or if you check for JS code in some other way, then that would also prevent this form of XSS? Barry On Feb 6, 2008, at 3:16 PM, Michael Peters wrote: > > > Mark Fuller wrote: >>>>> o Add the session id to the URL. This method has the most >>>>> problems, and >>>>> is not recommended. >>>> What are the problems with the last option? ... >>> Google for XSS - Cross-site scripting attacks, as a starter. >> >> I thought the problem with putting the session ID in the URL is that >> the user might copy/paste the URL to others. When they try to use it, >> the app would have no way to know it's not the real user? > > While that is a problem (it holds true with any user identifiable > information > not just sessions. You need to especially watch what you put into > emails since > they will get forwarded) it's not XSS. > > XSS is Cross Site Scripting. So you need 2 domains (hence the cross- > site) and it > involves Javascript (can also be ActionScript/Flash, VBScript, or > any other > future client-side scripting language). Basically it's problem of > people > embedding Javascript into a page that others will see. That > Javascript can steal > sessions, etc from the user who sees it. It doesn't matter if the > session id is > in the URL or a cookie, Javascript can see both. > > This is why escaping any data that could potentially come from a > user is so > important. > > > or > [% foo | html %] > > -- > Michael Peters > Developer > Plus Three, LP > > > ##### CGI::Application community mailing list ################ > ## ## > ## To unsubscribe, or change your message delivery options, ## > ## visit: http://www.erlbaum.net/mailman/listinfo/cgiapp ## > ## ## > ## Web archive: http://www.erlbaum.net/pipermail/cgiapp/ ## > ## Wiki: http://cgiapp.erlbaum.net/ ## > ## ## > ################################################################ > From stephen.carville at gmail.com Wed Feb 6 19:22:32 2008 From: stephen.carville at gmail.com (Stephen Carville) Date: Wed Feb 6 19:23:20 2008 Subject: [cgiapp] Persistence In-Reply-To: <45189.210.54.245.44.1202341143.squirrel@mail.redbone.co.nz> References: <200802031114.29209@centrum.cz> <002c01c866c1$43330ec0$6401a8c0@lousmaster> <47A711AD.3070106@plusthree.com> <001c01c8673e$d233c2e0$6401a8c0@lousmaster> <010701c867e4$0ff99b40$06fe000a@gboffice.gorillabox.net> <1202246282.27200.94.camel@zoe.savage.net.au> <039401c86898$95ec7b00$06fe000a@gboffice.gorillabox.net> <1202334445.27200.103.camel@zoe.savage.net.au> <45189.210.54.245.44.1202341143.squirrel@mail.redbone.co.nz> Message-ID: <2428c0380802061622u50ae1267kd17adfdac937e341@mail.gmail.com> On Feb 6, 2008 3:39 PM, Dan Horne wrote: > Mark Fuller said: > > > I thought the problem with putting the session ID in the URL is that > > the user might copy/paste the URL to others. When they try to use it, > > the app would have no way to know it's not the real user? > > > > Another problem is bookmarks. A user may bookmark a page, but when they > come back a couple of days later, the session has expired. They might also > email a link to others, and that link may not work for the same reason. Seems to me it makes more sense to embed the session ID or any other tracking as hidden variables in a form and send it back as a POST. -- Stephen Carville From karen.cravens at gmail.com Wed Feb 6 21:11:50 2008 From: karen.cravens at gmail.com (Karen) Date: Wed Feb 6 21:11:51 2008 Subject: [cgiapp] Persistence In-Reply-To: <45189.210.54.245.44.1202341143.squirrel@mail.redbone.co.nz> References: <200802031114.29209@centrum.cz> <002c01c866c1$43330ec0$6401a8c0@lousmaster> <47A711AD.3070106@plusthree.com> <001c01c8673e$d233c2e0$6401a8c0@lousmaster> <010701c867e4$0ff99b40$06fe000a@gboffice.gorillabox.net> <1202246282.27200.94.camel@zoe.savage.net.au> <039401c86898$95ec7b00$06fe000a@gboffice.gorillabox.net> <1202334445.27200.103.camel@zoe.savage.net.au> <45189.210.54.245.44.1202341143.squirrel@mail.redbone.co.nz> Message-ID: <7cc7c1ce0802061811x34f0a4aat95caabe8da262ca3@mail.gmail.com> On 2/6/08, Dan Horne wrote: > Another problem is bookmarks. A user may bookmark a page, but when they > come back a couple of days later, the session has expired. They might also > email a link to others, and that link may not work for the same reason. If you want a poster child for this particular evilness, and how it can be compounded: Joann.com (fabric/craft chain). You get bloggers who post links (craftblogging is a big thing), with their session id, and when you read and click, you get taken to a page that informs you that the session has expired... and it dumps you to the joann.com home page. If you're savvy editing the url, you can go back and edit it to get there, but otherwise there is absolutely no way to tell where the blogger meant you to go. I think they've been trying to fix that lately. I am only guessing, though, since the only symptom of change I've seen is that now if I go directly to the joann.com homepage, I am sent to a page telling me my session has expired, and I have to click a link to go back to the homepage. So apparently they're doing something with cookies now, but it's not an improvement... From ron at savage.net.au Thu Feb 7 02:57:32 2008 From: ron at savage.net.au (Ron Savage) Date: Thu Feb 7 02:56:41 2008 Subject: [cgiapp] Persistence In-Reply-To: <47AA2AE5.4020208@plusthree.com> References: <200802031114.29209@centrum.cz> <002c01c866c1$43330ec0$6401a8c0@lousmaster><47A711AD.3070106@plusthree.com> <001c01c8673e$d233c2e0$6401a8c0@lousmaster> <010701c867e4$0ff99b40$06fe000a@gboffice.gorillabox.net> <1202246282.27200.94.camel@zoe.savage.net.au> <039401c86898$95ec7b00$06fe000a@gboffice.gorillabox.net> <1202334445.27200.103.camel@zoe.savage.net.au> <47AA2AE5.4020208@plusthree.com> Message-ID: <1202371052.27200.107.camel@zoe.savage.net.au> On Wed, 2008-02-06 at 16:47 -0500, Michael Peters wrote: Hi Michael > Maybe I'm being dense, but XSS is about letting user's embed HTML/JS into other Maybe I'm raving again. I was hoping OP could use XSS as a search key to save me thinking. Perhaps I should have tried the search myself :-(. Everybody can go back to sleep now. -- Ron Savage ron@savage.net.au http://savage.net.au/index.html From ron at savage.net.au Thu Feb 7 03:00:23 2008 From: ron at savage.net.au (Ron Savage) Date: Thu Feb 7 02:59:29 2008 Subject: [cgiapp] Persistence In-Reply-To: <47AA31CF.6010608@plusthree.com> References: <200802031114.29209@centrum.cz> <002c01c866c1$43330ec0$6401a8c0@lousmaster> <47A711AD.3070106@plusthree.com> <001c01c8673e$d233c2e0$6401a8c0@lousmaster> <010701c867e4$0ff99b40$06fe000a@gboffice.gorillabox.net> <1202246282.27200.94.camel@zoe.savage.net.au> <039401c86898$95ec7b00$06fe000a@gboffice.gorillabox.net> <1202334445.27200.103.camel@zoe.savage.net.au> <47AA31CF.6010608@plusthree.com> Message-ID: <1202371223.27200.111.camel@zoe.savage.net.au> On Wed, 2008-02-06 at 17:16 -0500, Michael Peters wrote: Hi Michael > This is why escaping any data that could potentially come from a user is so > important. Not just escaping. OP should be warned that server code cannot just rely on Javascript-base validation. Someone might disable Javascript and sumbit something nasty. That means the validation should be duplicated on the server too. And yes, that's a PITA. -- Ron Savage ron@savage.net.au http://savage.net.au/index.html From mark at rawcane.net Thu Feb 7 03:57:46 2008 From: mark at rawcane.net (Mark Knoop) Date: Thu Feb 7 03:57:53 2008 Subject: [cgiapp] Persistence References: <200802031114.29209@centrum.cz><002c01c866c1$43330ec0$6401a8c0@lousmaster><47A711AD.3070106@plusthree.com><001c01c8673e$d233c2e0$6401a8c0@lousmaster><010701c867e4$0ff99b40$06fe000a@gboffice.gorillabox.net><1202246282.27200.94.camel@zoe.savage.net.au><039401c86898$95ec7b00$06fe000a@gboffice.gorillabox.net><1202334445.27200.103.camel@zoe.savage.net.au> <45189.210.54.245.44.1202341143.squirrel@mail.redbone.co.nz> Message-ID: <032f01c86967$827ff130$06fe000a@gboffice.gorillabox.net> > Mark Fuller said: > >> I thought the problem with putting the session ID in the URL is that >> the user might copy/paste the URL to others. When they try to use it, >> the app would have no way to know it's not the real user? >> > > Another problem is bookmarks. A user may bookmark a page, but when they > come back a couple of days later, the session has expired. They might also > email a link to others, and that link may not work for the same reason. > > I think for my purposes having a 5 minute expiry time is sufficient to preventing this kind of problem. If the session has expired it will renew the session data. I am only using sessions to avoid having to do remote calls for every request. I could also use the IP security feature and UA matching to lock it down further but is not critical. Cheers Mark From david at sitesuite.com.au Thu Feb 7 04:04:50 2008 From: david at sitesuite.com.au (David Baxter) Date: Thu Feb 7 04:06:04 2008 Subject: [cgiapp] Multiple run modes In-Reply-To: <727692630802061451v772b03dibca485821e077e5f@mail.gmail.com> References: <727692630802061451v772b03dibca485821e077e5f@mail.gmail.com> Message-ID: <47AAC9B2.9060907@sitesuite.com.au> Hi Mike, My preferred way is to simply call the view runmode after the update has completed. That way you can pass variable or parameters back to the view to prompt a message to be displayed. e.g. sub update { my $self = shift; # update the record ... # set a message to be displayed in the view runmode my $message = "The $id record was successfully updated."; return $self->view($message); } Regards, David Mike Tonks wrote: > Hi, > > I'm looking at CGI::Application prior to use, and one thing is unclear to me. > > I'll outline a little senario to demonstrate the question: > > I have a simple app with four run modes - list, view, edit & update > > list does what it say on the tin - lists records in a data table > > view ditto, displays a single record > > edit displays a form to edit (or add) a record > > update sends the posted data to the database > > > In my example, I would like the update run mode to then call the view > run mode, rather then simply display a rather useless 'update > complete' message. > > Is there a good way to do this with CA? I suppose a simple option is > to simply have update() call view() and return the results, but I > wondered if there was a preferred solution to this? > > Another thought that occurred from scanning the docs would be to put > the update function in prerun, but this seems wrong somehow. > > Thanks for any assistance, > > mike > > ##### CGI::Application community mailing list ################ > ## ## > ## To unsubscribe, or change your message delivery options, ## > ## visit: http://www.erlbaum.net/mailman/listinfo/cgiapp ## > ## ## > ## Web archive: http://www.erlbaum.net/pipermail/cgiapp/ ## > ## Wiki: http://cgiapp.erlbaum.net/ ## > ## ## > ################################################################ > > > > > From mark at rawcane.net Thu Feb 7 05:34:25 2008 From: mark at rawcane.net (Mark Knoop) Date: Thu Feb 7 05:34:32 2008 Subject: [cgiapp] params, params, params... Message-ID: <040e01c86975$02b18e60$06fe000a@gboffice.gorillabox.net> Hi I would be grateful if someone could offer me some guidance. When I started thinking about reorganising my app with CGI::Application but before I knew much about it I thought it would be good to have a Globals object which I set up when the script is called which stores all the things I need - some query params and some other values which I calculate based on the query params and things like session ids etc rather than have loads of package variables. In practice I am not sure if this is an improvement although there are some individual get and set methods that require extra functionality so is quite nice to have these in my own class. Also I see that CGI::Application has its own params - am I right in thinking these are completeley different to the query params? Is there any relationship between the two? Should I just be using these for 'global' values? It also looks like I will be using the session plugin and the session object also has its own params, some of which I would set with the global/query/params that I am interested in. So I have three lots of params as well as my own Globals class and I am not sure which the tidiest option is. Can anyone suggest any best practices on which params to use where? I want to make my variables easy to keep track of and keep the code as maintainable and readable as possible. Regards Mark From mpeters at plusthree.com Fri Feb 8 10:24:16 2008 From: mpeters at plusthree.com (Michael Peters) Date: Fri Feb 8 10:26:24 2008 Subject: [cgiapp] Persistence In-Reply-To: <2428c0380802061622u50ae1267kd17adfdac937e341@mail.gmail.com> References: <200802031114.29209@centrum.cz> <002c01c866c1$43330ec0$6401a8c0@lousmaster> <47A711AD.3070106@plusthree.com> <001c01c8673e$d233c2e0$6401a8c0@lousmaster> <010701c867e4$0ff99b40$06fe000a@gboffice.gorillabox.net> <1202246282.27200.94.camel@zoe.savage.net.au> <039401c86898$95ec7b00$06fe000a@gboffice.gorillabox.net> <1202334445.27200.103.camel@zoe.savage.net.au> <45189.210.54.245.44.1202341143.squirrel@mail.redbone.co.nz> <2428c0380802061622u50ae1267kd17adfdac937e341@mail.gmail.com> Message-ID: <47AC7420.7010107@plusthree.com> Stephen Carville wrote: > Seems to me it makes more sense to embed the session ID or any other > tracking as hidden variables in a form and send it back as a POST. This assumes then that every request you make is now a post request. Which means not more links, just forms. And this also breaks REST style apps (and really anything that tries to have meaningful HTTP semantics) since POST requests are for things that could change the data server-side and GET requests are for anything that won't (idempotent). In this day and age you really have to expect your users to use cookies. I can understand people not wanting to be tracked long term, but why should anyone object to memory-only cookies? -- Michael Peters Developer Plus Three, LP From mpeters at plusthree.com Fri Feb 8 10:28:26 2008 From: mpeters at plusthree.com (Michael Peters) Date: Fri Feb 8 10:30:33 2008 Subject: [cgiapp] Persistence In-Reply-To: <1202371223.27200.111.camel@zoe.savage.net.au> References: <200802031114.29209@centrum.cz> <002c01c866c1$43330ec0$6401a8c0@lousmaster> <47A711AD.3070106@plusthree.com> <001c01c8673e$d233c2e0$6401a8c0@lousmaster> <010701c867e4$0ff99b40$06fe000a@gboffice.gorillabox.net> <1202246282.27200.94.camel@zoe.savage.net.au> <039401c86898$95ec7b00$06fe000a@gboffice.gorillabox.net> <1202334445.27200.103.camel@zoe.savage.net.au> <47AA31CF.6010608@plusthree.com> <1202371223.27200.111.camel@zoe.savage.net.au> Message-ID: <47AC751A.8060304@plusthree.com> Ron Savage wrote: > On Wed, 2008-02-06 at 17:16 -0500, Michael Peters wrote: > > Hi Michael > >> This is why escaping any data that could potentially come from a user is so >> important. > > Not just escaping. OP should be warned that server code cannot just rely > on Javascript-base validation. Someone might disable Javascript and > sumbit something nasty. That means the validation should be duplicated > on the server too. And yes, that's a PITA. Very true. In fact, I almost never do Javascript validation because of this. Why duplicate my effort? But, it's important to remember that unless you're allowing your users to submit HTML or JS code, validation is not what prevents XSS. It's output encoding: http://www.oreillynet.com/onlamp/blog/2005/10/repeat_after_me_lack_of__outpu.html -- Michael Peters Developer Plus Three, LP From mpeters at plusthree.com Fri Feb 8 10:40:27 2008 From: mpeters at plusthree.com (Michael Peters) Date: Fri Feb 8 10:42:36 2008 Subject: [cgiapp] XSS In-Reply-To: <06483281-05D5-4CFB-B4EF-B99B18BEF917@genetics.utah.edu> References: <78A40BC4-66B7-4759-9C0C-F9F8BA478B88@genetics.utah.edu> <06483281-05D5-4CFB-B4EF-B99B18BEF917@genetics.utah.edu> Message-ID: <47AC77EB.4000801@plusthree.com> Barry Moore wrote: > Basically one version of an XSS attack would be for me to enter > javascript code into a form on your web page. Then if you include my > form submission in other web pages then my javascript could execute on > any other users machine that subsequently loaded those tainted pages. > My JS code could do anything that they could do including contact your > server on behalf of them and send data back to my server. Is this correct? Yes. This is what XSS means. There are variations on this, but it's bascially the same thing. > Then the rational for you to html escape any input that comes from me > and any other user is because that escaping would render the JS code > in-operable. Is that correct? Yes. Imagine you have a form that asks me a survey question and I enter my name as: Michael Peters. Then you log into the admin side of you application and see my survey result. You will get p0wnd. Now imagine that I instead of doing a simple alert() I inserted a Peters. > > Then you log into the admin side of you application and see my > survey result. > You will get p0wnd. Now imagine that I instead of doing a simple > alert() I > inserted a