Re: Apache::DBI
On Mon, 18 Aug 2003, wrote: Date: Mon, 18 Aug 2003 16:57:13 -0700 From: [EMAIL PROTECTED] To: [EMAIL PROTECTED] Subject: Apache::DBI What's the diference between DBI and Apache::DBI? Have you bothered to read the docs at all? http://search.cpan.org/author/TIMB/DBI-1.37/DBI.pm http://search.cpan.org/author/ABH/Apache-DBI-0.92/DBI.pm ky -- Reporting bugs: http://perl.apache.org/bugs/ Mail list info: http://perl.apache.org/maillist/modperl.html
Re: templating system opinions
On Fri, 18 Jul 2003, Patrick Galbraith wrote: Date: Fri, 18 Jul 2003 14:25:32 -0700 (PDT) From: Patrick Galbraith [EMAIL PROTECTED] To: [EMAIL PROTECTED] Subject: templating system opinions Hi there, Just wondering what the best templating system is to use and/or learn. I've briefly read up on the pros and cons of each, and am just wondering which one is the most widely _used_ and best to learn if you're wanting to know something that there are jobs for. thanks ;) Search the guide: http://perl.apache.org/search/swish.cgi?query=templatesbm=submit=search ky
Re: make test fails
On Thu, 10 Jul 2003, The Alliett's wrote: Date: Thu, 10 Jul 2003 11:23:11 -0400 From: The Alliett's [EMAIL PROTECTED] To: [EMAIL PROTECTED] Subject: make test fails Trying to compile mod_perl 1.28 with apache 1.3.27 on redhat 7.3 system Here is the output of the errors. Any idea's on how to fix this. ../apache_1.3.27/src/httpd -f `pwd`/t/conf/httpd.conf -X -d `pwd`/t httpd listening on port 8529 will write error_log to: t/logs/error_log letting apache warm up...\c done /usr/bin/perl t/TEST 0 still waiting for server to warm up...not ok server failed to start! (please examine t/logs/error_log) at t/TEST line 95. make: *** [run_tests] Error 9 [EMAIL PROTECTED] mod_perl-1.27]# tail t/logs/error_log [notice] Destruction-DESTROY called for $global_object Prototype mismatch: sub Socket::INADDR_ANY vs () at /usr/lib/perl5/5.6.1/i686-linux/Socket.pm line 329. Prototype mismatch: sub Socket::INADDR_BROADCAST vs () at /usr/lib/perl5/5.6.1/i686-linux/Socket.pm line 330. Prototype mismatch: sub Socket::INADDR_LOOPBACK vs () at /usr/lib/perl5/5.6.1/i686-linux/Socket.pm line 331. Prototype mismatch: sub Socket::INADDR_LOOPBACK vs () at /usr/lib/perl5/5.6.1/i686-linux/Socket.pm line 332. [Thu Jul 10 10:56:16 2003] [warn] [notice] child_init for process 22132, report any problems to [no address given] Are you using the default Perl binary that came preinstalled by RedHat on the system? If so, I'd recommend doing and rpm -e --nodeps perl and then rebuilding Perl from source. Then try rebuilding Apache/mod_perl. ky
Re: A::Registry vs. mod_perl handler philosophy
On Fri, 20 Jun 2003, Ged Haywood wrote: Date: Fri, 20 Jun 2003 17:25:23 +0100 (BST) From: Ged Haywood [EMAIL PROTECTED] To: Peter B. Ensch [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Subject: Re: A::Registry vs. mod_perl handler philosophy Hi there, On Fri, 20 Jun 2003, Peter B. Ensch wrote: I'm beginning to develop apps under mod_perl. I'm curious as to how people decide between coding for Apache::Registry vs. mod_perl handlers. Use Apache::Registry only if you have to in order to get legacy CGI scripts working. It's been suggested to me that content generating apps should be done under A::R, whereas logging, authentication Etc. should be implemented as mod_perl handlers. All new code should use handlers. 73, Ged. I wouldn't be so strict about such definitions. If you're only looking to generate content, then I don't see a problem with writing standard CGI scripts and running them under A::R. If you stick with strict and warnings and follow the gotchas listed in The Guide[1], you should be fine. If you also choose to code carefully, you can use the same script under mod_perl or not without changing anything (if that's important to you). Or am I missing something? At CSHL, all our Apache servers are compiled with mod_perl, but Lincoln still has us write most everything as CGI scripts. It's easy and works just fine for us. Also saves having to add Location directives to httpd.conf everytime you want to add a new script. Whatever works for you, I say. But mayhap I'm too permissive. ky [1]-http://perl.apache.org/guide
Re: error running mysql test
On Tue, 10 Jun 2003, Abd El-Hameed Mohammed wrote: Date: Tue, 10 Jun 2003 19:36:30 +0300 From: Abd El-Hameed Mohammed [EMAIL PROTECTED] To: [EMAIL PROTECTED] Subject: error running mysql test Dear all I had installed mysql. Things comes right till i tried to execute perl run-all-tests i got the following error /usr/local/bin/perl: relocation error: /usr/local/lib/perl5/site_perl/5.8.0/i686-linux/auto/DBD/mysql/mysql.so: undefined symbol: mysql_init Any ideas? hamid Um...how is this related to mod_perl? Probably you should send your question to a MySQL list? ky
Re: font width to pixel width in perl - but also offtopic in javascript
On Wed, 4 Jun 2003, Martin Moss wrote: Date: Wed, 4 Jun 2003 14:46:52 +0100 From: Martin Moss [EMAIL PROTECTED] To: [EMAIL PROTECTED] Subject: font width to pixel width in perl - but also offtopic in javascript Hi All, I'm sure this can't be an issue that hasn't been tackled, but I couldn't find anything in the archives so:- I'm trying to find a way in which I can calculate the pixel width of a string in a given font. I'm doing this to feed a javascript file, so I am also looking at doing this in javascript also. currently all I can find is the php 'imagefontwidth' function. Does anybody know of an equivalent in perl? I remember having issues like this in TK, but not sure the solution there would be appropriate. I guess this is fuzzily on topic, but if anybody has any off topic experience I'd be greatful. any approx solutions which can 'guarentee' a 'larger than the minimum space required' would also suffice, e.g. is there an approximation which I can use based upon the maximum character width possible for a font etc... Regards Marty Just a wild guess, but perhaps you could load GD.pm and get various font widths from there? ky
Compiling libapreq 1.1 on Mac OS 10.2.4
I've been trying to compile libapreq 1.1 (Apache::Request) on Mac OS 10.2.4 for a couple of hours, but I'm having no luck. I've been following the directions in the INSTALL.MacOSX file and following along with David Wheeler's article Installing libapreq on Jaguar: An Update (http://www.macdevcenter.com/pub/a/mac/2003/02/07/libapreq_update.html), but nothing seems to be working for me. In particular, I'm stuck on two errors: 1) libtool: ltconfig version `' does not match ltmain.sh version `1.3.5' 2) libtool: unrecognized option `-arch_only' To get to this point, let me recount what I did. I got this machine yesterday, reinstalled OS X (so I wouldn't have OS 9), installed the Developer Tools, installed Fink, and then used Fink to install lots of GNU goodies. Then I tried building libapreq following the directions for OS X: cd libapreq-1.1 sh BUILD.sh ./configure --with-apache-includes=/usr/local/apache/include make sudo make install That gave me the first error above. Seeing that I had a libtool in /usr/bin provided by Apple and seeing that I could install a libtool using Fink (into /sw/bin/), I did so. Then I moved /usr/bin/libtool to /usr/bin/libtool.orig and linked /sw/bin/glibtool to /usr/bin/libtool. Now I get past the first error, but I receive the second. The reason, of course, is that the libtool provided by Apple accepts the option -arch_only, but the one in /sw/bin doesn't. I've been working on this for a while and haven't kept any notes, but I know that at some point I Googled up a tip about changing the darwin section of the file ltconfig (I changed the one in /sw/share/libtool) like so: allow_undefined_flag='-undefined suppress' to: allow_undefined_flag='-undefined warning -flat_namespace' That didn't seem to help. I would very much appreciate any pointers. ky
Compiling libapreq 1.1 on Mac OS 10.2.4: Solved
Well, I guess taking a break from the problem helped me fix it, but I'm not sure how. I came back to my machine, removed the symlink in /usr/bin/ to /sw/bin/glibtool and restored the original libtool binary, removed the existing libapreq source directory, unpacked it from the tarball, and started over. This time it worked. Perhaps in all my efforts before I was still linking to something incorrect, but I seem to have Apache::Request installed now. Perhaps, at least, my earlier message will help point other OS X users in the right direction if they make the same mistakes I did. ky
Re: Spell Checkers and EMail
On Thu, 6 Mar 2003, Bill Moseley wrote: [snip] A bit off topic, but I have a similar need. I have a form where HTML is entered. I can easily parse out the text with HTML::Parser, and build a list of incorrectly spelled words, open in another window and show the words and a list for suggestions or a text field. I have not figured out how best to update the existing form inplace, though. I fear javascript is in my future. I helped implement a spell-checking system for a customer that was pure mod_perl. In the end, though, a fairly sharp JavaScripter helped make my somewhat-kludgy solution fairly elegant by popping up a window, calling my stuff to replace misspelled words, then resetting the original text with what was left in the pop-up when done checking (or the user aborted). It wasn't that bad, but I'm glad I didn't have to write the JavaScript. ky
Re: How do I convert HTML to PDF
On Wed, 26 Feb 2003, Chris Pizzo wrote: Date: Wed, 26 Feb 2003 12:41:58 -0500 From: Chris Pizzo [EMAIL PROTECTED] To: [EMAIL PROTECTED] Subject: How do I convert HTML to PDF Hi All, I want to take an Invoice that exists as an html doc and convert it to a PDF file to attach to an email. I have been looking at DocSet but this seems better suited for large documents. Any help? Thanks, Chris Chris, This isn't a mod_perl question. Have you tried to Google html2ps? ky
Re: Query
On Tue, 7 Jan 2003, Chandrasekhar R S wrote: Date: Tue, 7 Jan 2003 12:52:27 +0530 From: Chandrasekhar R S [EMAIL PROTECTED] To: [EMAIL PROTECTED] Subject: Query I am having a requirement as follows : I need to execute/interpret the perl requests away from mod_perl. Like, could mod_perl delegate the execution/interpretation of perl scripts to some other process. In the end, mod_perl would be used just to accept requests from the Web Server, but processing will be done elsewhere and response will be routed back through mod_perl. - rsr. Namaste, R S Chandrasekhar [EMAIL PROTECTED] ISD : 091-080-2052427 Telnet : 847-2427 Phone : 2052427 RSR, You can certainly do something like this, in many different ways. This *is* still Perl, you know. :-) You could use your mod_perl process to update a queue that's in a file or database table, then have another process (written in Perl or whatever) executed by a cron job to look at the queue and process the next job. The user could be given a token to associate with the job, then then check back later to get the results of the job. If you need it to be more immediate, then you'll have to get fancier. If it's a really long-running process you need to kick off, you'll need to take into account the dangers of forking your mod_perl process or having it wait around for the end of the job. Have you tried searching the archives for similar questions? Here's one place you can search: http://mathforum.org/discussions/epi-search/modperl.html Namaste, ky
RE: Query
On Tue, 7 Jan 2003, Chandrasekhar R S wrote: Date: Tue, 7 Jan 2003 21:38:57 +0530 From: Chandrasekhar R S [EMAIL PROTECTED] To: 'Ken Y. Clark' [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Subject: RE: Query Hello Ken, You gave me a glimmer of hope and enthusiasm. I have scanned through the recent postings on Mod Perl list in vain. I would like to know any such standalone servers that could process the perl requests offline (taking requests from a file or queue end). I definitely would like to get fancier as my requirement is immediate. Upon finding a server that could process the requests away from mod_perl, I most probably would modify mod_perl to communicate with the standalone servers via sockets (and maybe maintain persistence). many thanks rsr. RSR, I really think you're making this harder than it is. As was pointed out by another poster, there's nothing about your problem as you've described it that requires mod_perl. A simple CGI script could take your user input, write something to a file or database, and return a job ID. A separate Perl script could be launched every 60 seconds by crond and inspect the file or database for new jobs, process them, and write the results to another file or update the table. The user could then check back later with the original job ID for the results. There's no need for you to look for a server that could process the requests away from mod_perl. There's nothing wrong with the standard toolset that Unix already provides. And I really don't understand why you want to use sockets. First just solve your problem using the simplest solutions. If you then find things aren't performing to your expectations, tweak. Remember: Premature optimization is the root of all evil (Hoare). That's just one of many ideas you could use given how little I actually know about your problem. As none of what we've talked about involves mod_perl, I suggest we end this thread. Best of luck, ky -Original Message- From: Ken Y. Clark [mailto:[EMAIL PROTECTED]] Sent: Tuesday, January 07, 2003 9:02 PM To: Chandrasekhar R S Cc: [EMAIL PROTECTED] Subject: Re: Query On Tue, 7 Jan 2003, Chandrasekhar R S wrote: Date: Tue, 7 Jan 2003 12:52:27 +0530 From: Chandrasekhar R S [EMAIL PROTECTED] To: [EMAIL PROTECTED] Subject: Query I am having a requirement as follows : I need to execute/interpret the perl requests away from mod_perl. Like, could mod_perl delegate the execution/interpretation of perl scripts to some other process. In the end, mod_perl would be used just to accept requests from the Web Server, but processing will be done elsewhere and response will be routed back through mod_perl. - rsr. Namaste, R S Chandrasekhar [EMAIL PROTECTED] ISD : 091-080-2052427 Telnet : 847-2427 Phone : 2052427 RSR, You can certainly do something like this, in many different ways. This *is* still Perl, you know. :-) You could use your mod_perl process to update a queue that's in a file or database table, then have another process (written in Perl or whatever) executed by a cron job to look at the queue and process the next job. The user could be given a token to associate with the job, then then check back later to get the results of the job. If you need it to be more immediate, then you'll have to get fancier. If it's a really long-running process you need to kick off, you'll need to take into account the dangers of forking your mod_perl process or having it wait around for the end of the job. Have you tried searching the archives for similar questions? Here's one place you can search: http://mathforum.org/discussions/epi-search/modperl.html Namaste, ky
Re: Question from a newbie regarding apache and mod_perl
On Mon, 6 Jan 2003, sireesha vudatha wrote: Date: Mon, 6 Jan 2003 16:25:04 -0800 (PST) From: sireesha vudatha [EMAIL PROTECTED] To: [EMAIL PROTECTED] Subject: Question from a newbie regarding apache and mod_perl Hi all, I am a beginner and am doing a course project for which I want to know if mod_perl is suitable for my problem at hand. My problem is: When a user types in a question, then my perl program(or whatever) has to go to the database and return the answer back to the user. If its not able to find the question in the database, then it has to transfer the connection to a person who will answer the question and the database has now got to be updated with this new question and answer. (I had written a simple program using the DBI and DBD::Mysql for just retrieving the answer from the database) I don't know if the rest of my problem can be solved using mod_perl... Can anyone give me some ideas or suggestions that would help me out... Thanking u all in anticipation.. Sireesha Sireesha, Nothing you descibe seems to require mod_perl. I think perhaps you are unclear on just what mod_perl is meant to do. A great many people just use mod_perl to speed up execution of their Perl scripts. More advanced users want to manipulate different parts of the Apache request cycle using Perl. It sounds like your task will be most easily accomplished by sticking with a standard CGI script. If you find the performance is not what you desire, then consider running it under Apache::Registry. ky
Re: segmentation fault using a startup file
On Wed, 27 Nov 2002, Ged Haywood wrote: Date: Wed, 27 Nov 2002 20:56:01 + (GMT) From: Ged Haywood [EMAIL PROTECTED] To: Jan Theofel [EMAIL PROTECTED] Cc: mod_perl mailinglist [EMAIL PROTECTED] Subject: Re: segmentation fault using a startup file Hi Jan, On 27 Nov 2002, Jan Theofel wrote: Am Mit, 2002-11-27 um 17.33 schrieb Ged Haywood: What is it about compiling your own Apache that troubles you? It is a lot of work to do. Only the first couple of times. Takes me about two minutes nowadays. I agree. The first few times I compiles anything on Unix, I thought Wow, this is hard. Now I understand how things fit together and why it's a Good Thing to compile your own stuff. I feel dirty now when I use RPMs of Perl, Apache, or vi. Especially because we use SuSE Linux Enterprise Server which is a hihgly integrated system and we would loose the benefits of this system when we compile apache on our own. I don't understand that at all. Can somebody help me out here? A few months ago I tried out some different Linux distros. I liked Debian a lot until I got this wierd feeling about system dependencies on their own Perl. I ditched it within hours of that as I felt that it might prove easy to break the system. If you feel that you can't compile your own Apache on SuSE, you should probably consider a different distro for your web server and rely on those other nice bits on systems where you can do without the flexibility of compiling your own stuff. What will you do when the next security hole is found in Apache and you can't upgrade for fear of breaking your system? ky
Re: adding company Foo uses mod_perl ads
On Tue, 26 Nov 2002, Stas Bekman wrote: advertising the merits of your product or going down on your competitors ^^ For future reference, this phrase has certain ... um ... sexual connotations, at least in the US. :-o (Of course, so does the way I sign my e-mails. ;-) ky
Re: Migrating from CGI.pm to Apache::Request question.
On Tue, 19 Nov 2002, Coexec wrote: Date: Tue, 19 Nov 2002 15:40:37 -0800 (PST) From: Coexec [EMAIL PROTECTED] To: [EMAIL PROTECTED] Subject: Migrating from CGI.pm to Apache::Request question. Hello all, I have been searching through the mailing list archives for the answer to my question, but I have not found it. I am experienced with using the CGI.pm, and now I want to rewrite all of my CGI's using mod_perl and Apache::Request. According to everything that I have been reading, the Apache::Request module handles only GET, POST and Cookie data, and no HTML. Basically, my question is, what is the most commonly used module for generating HTML like the CGI.pm does ? Thanks There are so many different ways to handle HTML generation that it will make your head spin. You're always welcome to continue using CGI.pm's methods for generating HTML, but that usually couples the logic and presentation of your application so tightly that it makes for less-than-maintainable code -- less than what, however, remains the question. Many people like to use templating systems (HTML::Template, Template::Toolkit), some like to use more all-inclusive packages (Mason, Apache::ASP, Embperl), some people just use print statements (arguably the worst choice). Asking what is the most common way people on this list won't likely generate a consensus; ask 10 people how they do this and you'll probably get 10 different answers. As for me, I'm quite partial to Template::Toolkit. You'll have to decide what works best for you. No need to use a sledgehammer to drive a finishing nail. Use whatever tool is the simplest to use for your situation, but no simpler. :-) ky
Testing mod_perl app on Windows
My boss has asked me to pick up a Windows box so that I can test my application using the standard browsers on that OS. OK, I can see how it is a Good Thing to make sure that those people unfortunate enough to use Windows are able to use my application without errors. But I also had another idea: As I'm trying to make sure my code is platform-neutral, I'd like to try installing everything on the Windows platform as some people who download my app might try to do this. Not having touched Windows in about 3 years, all the different products really confuse me. When I go to the local PC store to pick up a box, what should I ask for? Windows 2000, ME, XP? Is there a specific XP server, or can I install Apache/mod_perl on the standard desktop OS? ky
Re: OT: Are things really this bad?
On Fri, 11 Oct 2002, Todd Finney wrote: Date: Fri, 11 Oct 2002 15:42:08 -0400 From: Todd Finney [EMAIL PROTECTED] To: [EMAIL PROTECTED] Subject: OT: Are things really this bad? I was looking at jobs.perl.org this afternoon, and there are a lot of things on there like this: - we'll pay you when we have some money - $20-$30 an hour - Do all this, we'll give you $75. I'm not *really* in the market, but more work is always better. Are the jobs on there really representative of what's going on out there, or are they somehow skewed? Just curious. cheers, Todd I subscribe to the Perl jobs list, not because I'm looking, but just to stay up on what people are looking for and what they will pay. I've seen plenty like what you describe, but I've also seen a position in the equities dept. of a finance company that pays $90-110, and O'Reilly just posted with a full-time Perl gig in Cali. There is definitely a wide range of pay and prestige, but I think there are some good positions out there. ky
Re: CGI Forms Problems (Getting Old Params)
On Sat, 28 Sep 2002, Shannon Appelcline wrote: [snip] I start off with a simple index.cgi that I've made extremely short to avoid the issue of nested subroutines. It has a require: -- $main::filePath = /var/www/skotos/myskotos; require ${main::filePath}/modules/lib/mylib.pm; Shannon, I'll make some suggestions about style that might help solve your problems. First off, I wouldn't recommend explicitly including package names with your variables ($main::foo, $bar::baz, etc.). You mentioned getting things to work with strict, but the above does not use my for $filePath, which leads me to believe you might be declaring this as a global. And while your require is technically fine, why not just set a use lib line for your custom library path and then use your module? (Your library path doesn't need to be variable, does it? Will this change dynamically at run-time?) I'd recommend changing the above to: use lib '/var/www/skotos/myskotos'; my $filePath = /var/www/skotos/myskotos; use mylib; From that required library, I set my $cgi variable: -- package mylib; use CGI; use CGI::Pretty qw( :html3 ); $mylib::cgi = new CGI; -- It's a global variable, but that seems entirely appropriate for something that's used in nearly every function. And, it gets explicitly set every time the program is run. But this isn't a good way to set a global. Either use use vars or our (depending on your version of Perl). And, stylistically, I prefer to make globals and constants stand out with all-caps: package mylib; use CGI; use CGI::Pretty qw( :html3 ); use vars '$CGI'; $CGI = CGI-new; I don't necessarily agree with making this a global, though. I don't use CGI (I usually use the faster and mod_perl-appropriate Apache::Request), so I'd read up on the docs to see if making this a persistent global isn't causing some of your headaches. Would it be that bad to just have that be redeclared every time with a my? Back in the original index.cgi, I have the problems when it's called to process form information. Here's that particular segment of code: -- require ${main::filePath}/modules/web/myedit.pm; my $action = $mylib::cgi-param('action'); $main::pageNumber = $mylib::cgi-param('pageNumber'); $main::contentType = $mylib::cgi-param('contentType'); if ($action eq editpage) { myedit::ProcessEditPage(); } elsif ($action eq editcontent) { myedit::ProcessEditContent(); } -- And, pretty much ANY of those parameters that I call in from $cgi can come up wrong. Both the local variables defined by my ($action) and the global variables set to $main ($pageNumber, $contentType) ... which tells me that the problem is back in that $cgi reference. But why? Can I not set variables which might change down in modules? That would seem grossly limiting if so, given that I've moved everything to modules in order to avoid the nested subroutine problems. Or am I missing something else? I'm still on the style issue of explicitly manipulating another package's variables. It really seems like you want to make those extra modules of yours into real objects, and then call methods against them: package mylib; use CGI; use CGI::Pretty qw( :html3 ); sub new { my $class = shift; my $self = bless { cgi = CGI-new }, $class; return $self; } sub cgi { return shift-{'cgi'}; } 1; --- use lib '/var/www/skotos/myskotos/modules/web/'; use myedit; use mylib; my $lib = mylib-new or die 'No mylib object'; my $edit= myedit-newor die 'No edit object'; my $cgi = $lib-cgi or die 'No CGI object'; my $action = $cgi-param('action') ||'editpage'; my $pageNumber = $cgi-param('pageNumber') || 0; my $contentType = $cgi-param('contentType') || 'text/html'; if ( $action eq 'editpage' ) { $edit-ProcessEditPage( $cgi ); } elsif ( $action eq 'editcontent' ) { myedit-ProcessEditContent( $cgi ); } Of course, you should be writing code a lot more bullet-proof than the above (what's going to catch the die, what happens in mylib if CGI-new fails, taint checking, etc.). My guess is that in your myedit package, you were explicitly referencing $mylib::cgi because I see you weren't passing it (as I made sure to above). Again, I differ with you on style, but I think this is part of your problem. I should mention, that out of extreme paranoia at this point I'm even trying to undef $cgi when I'm done, to no effect. -- END { $mylib::dbh-disconnect if $mylib::dbh; undef $mylib::cgi; } I don't think undefing your CGI object is the problem. I think it probably never gets created anew as you expect it would. You've declared it as a
Re: Mod_perl Application Development
On Sun, 18 Aug 2002, Jonathan Lonsdale wrote: Date: Sun, 18 Aug 2002 00:31:03 +0100 From: Jonathan Lonsdale [EMAIL PROTECTED] To: [EMAIL PROTECTED] Subject: Mod_perl Application Development I'm curious to know how people approach application development with mod_perl in situations where there could be dozens of distinct screens/interfaces. I'm currently using the HTML::Template system. Here's a few approaches I thought of: 1. Single monolithic content handler. Could be hard to maintain. 2. Distinct content handlers each with their own Location directive. Could be a pain to maintain the server config. I've usually done #2, and it is a pain. When you're developing and making up just one Location at a time, it's not so bad, but when you go to distribute the application and you see that someone will have to set up 10 or so or them, then it looks a little hacky. I've considered going to #1 and using CGI arguments (e.g., page=foo) or path_info (e.g., /my_handler/foo) to dispatch to the correct module. I certainly wouldn't advise that the logic for all these Locations be in one module. 3. Take a small performance hit and use an Apache::Registry script for each screen to handle the content phase. Use 'PerlSetupEnv Off', $r and Apache:: modules and don't bother being backwardly compatible with CGI. There's nothing wrong with this or just about any other way you can think as long as it works properly for you. I'm currently looking at the new Apache::TT2 module (http://apache-tt2.sourceforge.net/) as a way of getting rid of all Location directives. The templates are called in the same manner as HTML pages (i.e., by specifying a URL) and Apache::TT2 processes the pages as it normally would, allowing you to call out to objects and libraries and such. The exhaustive list of how other people are doing this would be difficult to compile and voluminous. I'd recommend you also look into all the other very fine application frameworks, like HTML::Mason, CGI::Application, Apache::PageKit and others. ky
Re: variables not changing with modperl??
On Tue, 13 Aug 2002, Michael Drons wrote: Date: Tue, 13 Aug 2002 07:46:16 -0700 (PDT) From: Michael Drons [EMAIL PROTECTED] Reply-To: [EMAIL PROTECTED] To: Perrin Harkins [EMAIL PROTECTED], darren chamberlain [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Subject: Re: variables not changing with modperl?? Sorry, There is a my in front of the ($cookie,$user) code. I am confused about your second statement about parsing the input. What should I be doing? Do you mean I should use $r-read($content, $r-header_in('Content-length'))? to read in the variables? Michael, In one of your posts, you included the following code: #!/usr/bin/perl -wT use strict; print body; my $r = Apache-request; $r-content_type(text/html); $r-status(200); my $auth_type = $r-auth_type; $cookie=$auth_type-key; ($user,$hash)=split(/:/,$cookie); read(STDIN, my $buffer, $ENV{'CONTENT_LENGTH'}); my @pairs = split(//, $buffer); foreach my $pair (@pairs) { } There is no my in front of $cookie or $user variables. If you are lexically scoping them somewhere else in your script, please include enough of an example for us to help you. I use the AuthCookie modules to set the cookies and to authenicate. As for this and Perrin's comment about parsing on your own, the point is that you've written a lot of code that has already been written and debugged by a lot of really smart people. There's no reason for you to be reading STDIN and spliting and all that. If you're using mod_perl, then you really should do yourself a favor and read up on Apache::Request and Apache::Cookie for doing all this stuff. It's much faster (it's written in c), safer (it's been debugged), easier (just install the module), and standard (i.e., more maintainable). Of course, some people say that the nice thing about standards is that there are so many to choose from. :) ky
Re: Preserving POST data on external redirect?
On Mon, 24 Jun 2002, Kirk Bowe wrote: Date: Mon, 24 Jun 2002 16:22:42 +0100 (BST) From: Kirk Bowe [EMAIL PROTECTED] To: [EMAIL PROTECTED] Subject: Preserving POST data on external redirect? Hi all, my content handler does some work with POSTed data, and at the end wants to redirect to a totally unrelated server, preserving the POST data that the client originally sent, so that the unrelated server can do its own further processing with its own mod_perl, cgi, or whatever. I can't get it to work, as I think I'm getting confused by some pre-Apache::Request hints that I've seen for this. This is the mess I've got so far (condensed): sub handler { my $r = Apache::Request-new(shift); ... some calls to other subs here to do work ... $r-method(POST); $r-method_number(M_POST); $r-headers_in-unset(Content-length); $r-args($content); $r-header_out('Location' = http://j.random.server.com/foo.cgi;); $r-status(REDIRECT); $r-send_http_header; return REDIRECT; } It redirects, but doesn't pass the POST data. I thought it may have been due to the original post data being deleted because I use it, so I tried using Request-instance instead of Request-new, but that made no difference either. Is it actually possible to do it if I'm using the Request object? Cheers I think this is what you want: http://theoryx5.uwinnipeg.ca/cgi-bin/guide-filter?page=snippets/Redirect_a_POST_Request_Forward.html;query=GET%20POST;match=and;where=all;stem=no ky
Re: mod_perl/passing session information (MVC related, maybe...)
On Wed, 12 Jun 2002, Vuillemot, Ward W wrote: Date: Wed, 12 Jun 2002 06:58:24 -0700 From: Vuillemot, Ward W [EMAIL PROTECTED] To: 'Peter Bi' [EMAIL PROTECTED], [EMAIL PROTECTED], Eric Frazier [EMAIL PROTECTED] Subject: mod_perl/passing session information (MVC related, maybe...) I was wondering how people are saving state between pages of a session. There is a Apache::Session which is sufficient to check to see if they are logged in, et cetera. But I want to be able to remember the last query so that I can return results into multple pages along with memory of where in the stack I am at. The easiest would to be store the query parameters along with the count information. . .but I do not want to use Apache::Session as I believe that has too much overhead for this sort of thing. There are persistent modules, but I am wondering if there is a better way with Apache and mod_perl -- that ppl have tried and can vouche for its validity. Thanks! Ward Ward, I do things like this all the time, though I wonder if I don't do it the Hard Way. Basically, I define a MAX_RESULTS per page (like 25) and return the first set of records to the user. To make the clickable links to Previous, Next, and the 1-n pages, I've munged the query results in Perl and a couple template packages to make each link contain everything necessary to perform the query again (including every parameter from the original request) and putting in the appropriate limit_start number (or whatever you want to call your limiting variable) for the set. E.g., if I'm looking for all the records where name=foo and size=M and I got back 100 results, with a MAX_RESULTS of 25, I'd have to make four pages. The second page might look like this: a href=/search?name=foo;size=M;limit_start=0Previous/a | a href=/search?name=foo;size=M;limit_start=01/a | 2 | a href=/search?name=foo;size=M;limit_start=503/a | a href=/search?name=foo;size=M;limit_start=754/a | a href=/search?name=foo;size=M;limit_start=50Next/a Now, that's a lot of stuff to make sure is in your output, and adding or changing a parameter means a lot of fixing. However, it is fairly simple, and I can grok it, so I stick with it. I'd be happy to hear of better ways. FWIW, I do pretty much the same thing to re-sort tables of data by column headers. So for a table of shirts with attributes of color and price, I'd do something like: FWIW, I do pretty much the same thing to re-sort tables of data by column headers. So for a table of shirts with attributes of color and price, I'd do something like: tr ... tha href=/view_shirts?order_by=colorColor/a/th tha href=/view_shirts?order_by=pricePrice/a/th ... /tr Sprinkle in the same code for limiting to a managable result set, and those are all my tricks. HTH, ky
Re: separating C from V in MVC
On Mon, 3 Jun 2002, Rob Nagler wrote: Date: Mon, 3 Jun 2002 08:09:12 -0600 From: Rob Nagler [EMAIL PROTECTED] To: [EMAIL PROTECTED] Subject: Re: separating C from V in MVC Perrin Harkins writes: You can actually do that pretty comfortably with Template Toolkit. You could use a filter for example, which might look like this: [% FILTER font('my_first_name_font') %] ... some text, possibly with other template directives in it... [% END %] One of the reasons Perl is popular is its idioms. Having to say something in three lines is not as idiomatic as one line. It takes a lot of discipline to use it everywhere. In other words, I don't think the above is more comfortable than: String(['User.first_name'], 'my_first_name_font'); Note also the accessor for User.first_name in Template Toolkit is probably nontrivial. Rob Not to see this discussion devolve into Yet Another Template War, but there's more than one way to do filters in Template Toolkit: [% User.first_name | my_filter %] Add to the handy pipe syntax the number of built-in filters (esp. the html and uri ones), and you get a large amount of convenience because you don't have to pre-format your data before passing it to a template (which seems to more strongly couple to the C to the V). It's just my opinion, baby, I may be right or wrong. -- Robert Johnson ky
[OT] Re: Image::Size, TT, and mod_perl Question
On Tue, 21 May 2002, Mike Melillo wrote: Hey, Mikey! Date: Tue, 21 May 2002 23:28:29 -0400 From: Mike Melillo [EMAIL PROTECTED] To: [EMAIL PROTECTED] Subject: Image::Size, TT, and mod_perl Question I posed this question to the Template Toolkit list and got no response, so I figured I'd give this list a shot... - Hello, below is some code I have in a mod_perl handler that checks to see if an uploaded image is less than 300 pixels tall or wide. Everything seems to be working except the fact that the template is not returning with the proper values processed. Below is the code and the err_log output when I output an image that is too wide. [snip] my $upload = $r-upload; my $type= $upload-type; my $fh = $upload-fh; my $username= $r-param('username'); my ($x, $y) = imgsize($fh); print STDERR Dumper($x); print STDERR Dumper($y); unless ($x 300) { print STDERR the greater than works\n; # This checks to make sure the image isnt more than 300 x 300 my %vars = {TOO_WIDE = 1}; You're creating the hash incorrectly. Do either: my %vars = ( TOO_WIDE = 1 ); or my $vars = { TOO_WIDE = 1 }; ky my $config = { INCLUDE_PATH = '/moc/html/templates', POST_CHOMP = 1, EVAL_PERL = 1, }; my $template = Template-new($config) || die New Template Failed: $!\n; #the process method prints the template out to the browser via $r $template-process('pic_upload.tt2', \%vars, $r) || do { $r-log_reason($template-error()); return SERVER_ERROR; }; return OK; } # end of X/Y coordinate if [snip] The err_log output: $VAR1 = 310; $VAR1 = 72; the greater than works [end of err_log] The problem is the template pic_upload.tt2 has this in it: [% IF TOO_WIDE %] font color=redYour File was too big. Make it under 30K/fontp [% END %] But that isn't showing up. I do the almost identical thing immediately after this if clauses to check if the file's type is a jpeg. That works, so I don't understand what I pasted in wrong, or forgot to paste in. Mike -- # - # k e nKen Y. Clark # r y [EMAIL PROTECTED] # a l c972-542-7923 # -
Re: How to generate pre-filled forms? (fwd)
Forgot to cc the list. -- Forwarded message -- Date: Fri, 26 Apr 2002 11:35:37 -0400 (EDT) From: Ken Y. Clark [EMAIL PROTECTED] To: F.Xavier Noria [EMAIL PROTECTED] Subject: Re: How to generate pre-filled forms? On Fri, 26 Apr 2002, F.Xavier Noria wrote: Date: Fri, 26 Apr 2002 16:15:52 +0200 From: F.Xavier Noria [EMAIL PROTECTED] To: [EMAIL PROTECTED] Subject: How to generate pre-filled forms? I am writing some modules that receive a form, process it, and return a page that includes that very form. Is there a standard way to fill that returned form so the user sees the same data he sent there, as CGI.pm does? -- fxn PS: I am using Apache modules + HTML::Template if that matters. I'll throw my technique into the ring, too. I use Template Toolkit most of the time, and I pass the original Apache request object back to the template as a parameter. Then I call the param method to fill in the value of form elements, like so: In code: sub handler { my $r = shift; my $apr = Apache::Request-new($r); my $t = Template-new; my $html; $t-process('/foo/bar.tmpl', { apr = $apr }, \$html); $apr-content_type('text/html'); $apr-send_http_header; $apr-print( $html ); return OK; } In template: form input name=foo value=[% apr.param('foo') %] textarea name=text[% apr.param('description') %]/textarea /form Nothing gets placed there the first time through as calling $apr-param returns nothing. This seems to work great for me. I've not used HTML::Template in a while, but possibly you can do this, too? Template Toolkit makes it easy to call methods (or deference hashes and hash references) with the dot notation. HTH, ky
Re: full-featured online database apps
On Wed, 24 Apr 2002, Adi Fairbank wrote: Date: Wed, 24 Apr 2002 13:27:11 -0700 From: Adi Fairbank [EMAIL PROTECTED] To: [EMAIL PROTECTED] Subject: Re: full-featured online database apps For example, what I'm looking for are other projects similar to Gedafe: http://isg.ee.ethz.ch/tools/gedafe/ but maybe with a more customizable front-end. -Adi Adi, I've written so many on-line database apps in mod_perl/MySQL/Oracle that I think I'll go crazy sometimes. They all have so much in common, esp. the typical administrative interface where you have to show all, show one, edit, create, [confirm] delete, etc. Everytime I find myself following the same basic formula, but they're all so significantly different that I can't really see reusing much code. I guess you could abstract things to such a degree that lots of directives could be passed to extremely generic methods, but that actually has always seemed more trouble to me than it's worth. I guess my bit of insight I'm trying to share is that you should probably just write your own from scratch. It sounds like you're somewhat new to this, anyway, so the experience will do you good. :) I guess I just don't think you're going to find anything that will ever be as flexible and powerful as something you write yourself. You'd likely spend as much time trying to grok someone else's code so you could modify it as you'd spend hacking your own. If you'd like examples of how to go about this, write me off-list and I'll send you a lot of nasty code. ky
Re: Future versions
On Wed, 20 Mar 2002, Aaron Roberts wrote: Date: Wed, 20 Mar 2002 13:34:46 - From: Aaron Roberts [EMAIL PROTECTED] To: [EMAIL PROTECTED] Subject: Future versions Hi, I noticed that your May be done list on www.apache-asp.org mentions an interpreter for VBScript. I have been asked to setup a Linux based corporate website, though my developers insist on using VBScript and ASP. I realise that this is a bit of a time -wasting question, but how certain is the May be done list of to dos? - should I wait for your apache module to include VBScript support, or am I going to have to work with something like Sun's Chilli ASP for apache/linux ? Many thanks for your time, Aaron Aaron Robertsmailto:[EMAIL PROTECTED] Technical Support Engineer Domicilium (IOM) Ltd. 32-34 Malew Street Castletown Isle of Man IM9 1AF Tel: 01624 825278 Fax: 01624 829525 http://www.domicilium.com Aaron, Your question is specific to Apache::ASP only, so it might be better suited for their list. Still, I've used Apache::ASP in the past (and I've also had my dark days using M$'s ASP on IIS), so I might conjecture that Joshua probably won't ever fully implement VBScript (though I think I remember him talking about a VBScript-to-Perl converter). I shouldn't speak for Joshua, though. He may be planning to support VBScript. I might point out, however, that if your requirements include a Linux-based website, then you're going to have troubles with these developers [who] insist on using VBScript and ASP. If they're not interested in the enlightenment that comes from using Perl and Apache::ASP, then you'll probably have to lay down the dough for IIS. The short answer is probably Don't hold your breath for VBScript. I couldn't comment on Sun's product. Sorry. Try your question on the Apache::ASP list: http://www.apache-asp.org/support.html ky
Re: Apache::Session problem with DBD::Oracle
On Mon, 11 Mar 2002, Brian Lavender wrote: Date: Mon, 11 Mar 2002 11:24:35 -0800 From: Brian Lavender [EMAIL PROTECTED] To: [EMAIL PROTECTED] Subject: Apache::Session problem with DBD::Oracle I am trying to install Apache::Session and it is failing on the DBD::Oracle tests. It is asking for a default user. Do I need to configure Oracle for a default user? Or do I need to set some environment variable with a user id and password? brian Here are the errors I am getting: t/99oracle..DBI-connect(sgum) failed: ORA-01004: default username feature not supported; logon denied (DBD ERROR: OCISessionBegin) at blib/lib/Apache/Session/Store/Oracle.pm line 45 (in cleanup) DBI-connect(sgum) failed: ORA-01004: default username feature not supported; logon denied (DBD ERROR: OCISessionBegin) at blib/lib/Apache/Session/Store/Oracle.pm line 45 t/99oracle..dubious Test returned status 255 (wstat 65280, 0xff00) DIED. FAILED tests 1-10 Failed 10/10 tests, 0.00% okay Oracle is fairly picky about the connection info. Here's an example of one I use: use constant FooDataSource = 'dbi:Oracle:'; use constant FooDBUser = q{user/password@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=host)(PORT=1521))(CONNECT_DATA=(SID=sid)))}; use constant FooDBPassword = ''; use constant FooDBOptions = { RaiseError = 1, FetchHashKeyName = 'NAME_lc', LongReadLen = 3000, LongTruncOk = 1, }; my $db = DBI-connect(FooDataSource, FooDBUser, FooDBPassword, FooDBOptions); I'm also fairly sure that some environment variables should be set. If I grep my env for ORA, I see: ORACLE_SID=name changed to protect the innocent ORACLE_BASE=/oracle1/app/oracle ORACLE_HOME=/oracle1/app/oracle/product/8.0.5 ORACLE_TERM=xsun5 Obviously, the $ENV{'ORACLE_SID'} matches the SID in the FooDBUser string. The above string is used from a host other than the machine that houses Oracle, so it may have more in it than you need if you're on the same machine. HTH, ky
Re: Apache::Subprocess availability
On Thu, 21 Feb 2002, Balazs Rauznitz wrote: Date: Thu, 21 Feb 2002 08:52:54 -0500 From: Balazs Rauznitz [EMAIL PROTECTED] To: [EMAIL PROTECTED] Cc: Balazs Rauznitz [EMAIL PROTECTED] Subject: Apache::Subprocess availability After compiling and installing mod_perl 1.26 I do not see Apache::Subprocess anywhere. Is it a separate module ? If so how do you get it; http://perl.apache.org/dist/contrib/ did not have it either. Thanks for the insight, Balazs Balazs, First, it's Apache::SubProcess (with a capital P), and it's not installed by default. You can snag it from CPAN in the /modules/by-module/Apache/ directory (or use the CPAN shell [as root]: perl -MCPAN -e 'install Apache::SubProcess' ky
Re: perl cgi's and apache
On Tue, 5 Feb 2002, Jeff wrote: Date: Tue, 5 Feb 2002 19:21:39 -0500 From: Jeff [EMAIL PROTECTED] To: [EMAIL PROTECTED] Subject: perl cgi's and apache I am having a problem getting my cgi script to complete processing when it is launched via apache server. The script itself runs fine from the command line. It is a script that processes a long array of values and interacts with a database per value. When the array is relatively short, the program will complete and everything is fine (even when launched through the browser). When the array is larger, and only when launched through the browser, the perl.exe on the Windows 2000 machine just seems to hang after about 30 seconds or so and if I stop apache server, it will start processing again and finish its job. I think I have all the apache timeout parameters set long enough. Can anyone help me out on this? Thanks Jeff, The browser may be what's timing out the process. There are many things you can do to work around such problem. Did you look in the guide (http://perl.apache.org/guide)? I searched for timeout, and the first suggestion is this: http://thingy.kcilink.com/modperlguide/debug/Handling_Server_Timeout_Cases_an.html However, you never mentioned that you're using mod_perl -- just Perl -- so the guide may not help all that much. (This is a *mod_perl* list you wrote to, you know. :) Regardless, one thing you can always do is to throw more hardware at the problem (bigger, faster machine; more memory; split up the load to a dedicated database server/light-weight frontend mod_perl-less Apache/big, fat mod_perl server backend). Or try to streamline your code -- maybe make one big SQL query for all your values rather than individual calls for each one. If none of that works for you, you may need to pass off the long-running process to a queue for a cronjob to pick up (well, maybe not cron if you're on Windows) or you spin it off to an external script to do the work. Search the guide. HTH, ky
Re: [OT] Perl and Microsoft Excel?
On Thu, 29 Nov 2001, Tom Servo wrote: Date: Thu, 29 Nov 2001 14:37:34 -0800 (PST) From: Tom Servo [EMAIL PROTECTED] To: Ian [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Subject: Re: Perl and Microsoft Excel? There's probably a far better answer to this than I can give, but if not, an interim solution might be having whoever maintains these Excel files save them as .csv files. Excel can do that, and while you lose all the fancy formatting, it just dumps them in a comma seperated list, then you can split on commas to get the values out of it. Hopefully someone else knows of a CPAN module to work with Excel files, though... Brian Nilsen [EMAIL PROTECTED] Here's a sampling: http://theoryx5.uwinnipeg.ca/mod_perl/cpan-search?search=excelnew=Searchfiletype=+distribution+name+or+descriptionjoin=andarrange=filedownload=autostem=nocase=clikesite=ftp.funet.fiage= ky On Thu, 29 Nov 2001, Ian wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 In the wide and wonderful world of Microsoft and Linux, I'm in the need of an interesting soloution. I'm presenting this to the list because I've ran out of good ideas. The campus phone system has a 911 database that is in Microsoft Excel format, and they want to be able to take that information, and show it on a webpage, either via a search form, or in one big table. The problem is, they want to do it dynamically...the web server needs to yank it down from a samba share (or ftp), parse it, show it, and terminate. I'm really **really** new at anything perl wise...so I haven't the foggiest clue as to where I should start. I've finally gotten Apache/Mod Perl/Mod SSL installed, and working properly. Are there any modules for pulling information from an excel sheet? How about modules that keep the overworked admin from insanity? Ian - - From RFC 1925: (3) With sufficient thrust, pigs fly just fine. However, this is not necessarily a good idea. It is hard to be sure where they are going to land, and it could be dangerous sitting under them as they fly overhead. -BEGIN PGP SIGNATURE- Version: PGPfreeware 7.0.3 for non-commercial use http://www.pgp.com iQA/AwUBPAa3NHRiiq+WL4fKEQKsRACgutpROPjPllax3Nvfat2R7YERlSQAn35Q 0vwYEFLgdzsz4Dfu98dUJzBy =Qs9B -END PGP SIGNATURE-
Re: CVS
On Thu, 15 Nov 2001, Jonathan M. Hollin wrote: Date: Thu, 15 Nov 2001 14:31:57 - From: Jonathan M. Hollin [EMAIL PROTECTED] To: mod_perl Mailing List [EMAIL PROTECTED] Subject: CVS Hi people, I am currently developing a content management system under mod_perl, with data stored in an RDBMS (MySQL at present, but Oracle on the production server). I would like to add version control to published documents (read pages) and wondered if anyone has any experience of this who would be willing to offer me some advice. I have a CVS server and am curious as to whether there is some way this can used (bearing in mind that I want to manage DB data, not files). I would like to be able to rollback to any previous version (if possible), and would also like to document the different versions themselves. I'm thinking that I could maybe commit the database files to CVS and then use a module to communicate with the CVS server (Apache-CVS, VCP, VCS-CVS, etc). Is this possible? Has anyone ever tried anything like this? I have searched CPAN and used Google to search the web and Usenet but have so far drawn a blank. I suspect that I will not be able to use CVS in this manner and that therefore I am going to have to roll my own. If this does turn out to be case - can anyone lend me any guidance as to how I work out what's changed in a record (between versions)? Then I can just store the changes in a DB as required. Jonathan M. Hollin - WYPUG Co-ordinator West Yorkshire Perl User Group http://wypug.pm.org/ Jonathan, I worked on a system earlier this year that had a need for revision control of files. I decided to use RCS and the Rcs.pm Perl module. The Rcs.pm module actually had several flaws which I tried to communicate to the author, but I never heard from him. However, with my fixes, I found using RCS to be perfectly adequate for my needs. I interacted with a database, as well (MySQL), but only to store the file's location and some meta-data on the file. I really enjoyed using RCS, allowing it to handle the manipulation of the files. Personally, I didn't feel I could roll anything better than RCS, though you may feel different about replicating CVS's functionality. ky
RE: CVS
On Thu, 15 Nov 2001, Sheth, Niraj wrote: Date: Thu, 15 Nov 2001 10:05:29 -0500 From: Sheth, Niraj [EMAIL PROTECTED] To: 'Ken Y. Clark' [EMAIL PROTECTED] Cc: mod_perl Mailing List [EMAIL PROTECTED] Subject: RE: CVS Ken, I am using Rcs.pm in production. Could you give me more details about the flaws you have found and if possible could you post the patch(or code change)? Thanks, -Niraj Niraj, Well, I seem to have misplaced my version of the module. I found something old, but it doesn't look quite right. The biggest thing I can remember is that I couldn't get the original to work well under mod_perl because errors were reported via Carp::croak. I changed all those to die statements which I then caught with my calling module. I'm continuing to search for what I believe is a more reliable copy of what I used. If I find anything, I'll try writing Craig Freter again. I believe previous e-mails to him bounced or went unanswered, but that was several months and a couple projects ago, so I don't quite remember everything too clearly. ky
Re: Cookie authentication
On Thu, 15 Nov 2001, John Michael wrote: Date: Thu, 15 Nov 2001 14:02:04 -0600 From: John Michael [EMAIL PROTECTED] To: [EMAIL PROTECTED] Subject: Cookie authentication This may seem off subject but, If you bare with me, I don't think it is. I am interested in using the cookie based system referred to in the programming the apache api book but oftend wonder this. Can you count on everyone to use cookies. It seems that some surfers are afraid of cookes are that maybe some browsers don't even handle them. I wrote a mod perl script to do member traking in my members site to see what pages were being viewed the most and used cookies also to make sure that more than one person was not using a particular username and find that some people either arn't using a browser that uses cookies or do not have them turned on. What are your thoughts on this because I thought of implementing the token cookie system but did not because I was afraid I would loose members that did not have or use this feature. Can you legimately require surfers to have cookies turned on and do you know of many sites that do this successfully without loosing members. Thanks John Michael John, For what might be called premium services, I believe it is justified to require user's to accept cookies. I've used cookie-based authentication on several sites that offer some special to the user, like a private view of data or something else that requires they identify themselves. That being the *only* thing I've ever required of users (e.g, I *never* require something like JavaScript, only using it to enhance the UI but always with alternatives), I think it's OK. If they don't want to use cookies, they don't have to use the service I'm providing. That being said, some people might not accept frivolous cookies myself just for reading a web page, but I'd imagine most don't even monitor such things. ky
Re: CGI.pm - Unnamed parameter
On Fri, 2 Nov 2001, James Wilson wrote: Date: Fri, 2 Nov 2001 01:42:13 + (GMT) From: James Wilson [EMAIL PROTECTED] To: [EMAIL PROTECTED] Subject: CGI.pm - Unnamed parameter Hi, Hopefully a quick and easy question... I'm accessing as follows: /cgi-bin/script.pl?data And want to know how to get 'data' from somewhere using CGI.pm Am familiar with using $cgi-param{'it'} to read .../script.pl?it=data and also using $cgi-path_info() to read .../script.pl/data but I don't know how to get at it using the format at the top. I've noticed from experiment that given /script.pl?data, I seem to be able to get it using $cgi-param{'keywords'}, but if I am using .../script.pl?param=valuedata then I can access 'value' from $cgi-param{'param'}, but can no longer get 'data' from $cgi-param{'keywords'} I'm therefore obviously concerned about just asssuming that $cgi-param{'keywords'} will return 'data' given an access of .../script.pl?data as I can find no reference in CGI.pm docs about this being a standard behaviour. Does anyone know a fail-safe way of retrieving 'data' using a CGI.pm call given an access as above ??? Thanks, James James, Do you have to use CGI.pm? Why not use the Apache::Request module? It's much quicker and powerful, IMO. $apr-path_info() should work just fine for you, but it's only going to give you the data part of /script.pl?data. Also, if you're going to stick to using CGI.pm, why are you saying $cgi-param{'foo'} and not making the method call, $cgi-param('foo')? ky
Re: mod_perl-1.26, threads and LWP.pm
On Mon, 5 Nov 2001, Toni Andjelkovic wrote: Date: Mon, 5 Nov 2001 22:43:32 +0100 From: Toni Andjelkovic [EMAIL PROTECTED] To: [EMAIL PROTECTED] Subject: mod_perl-1.26, threads and LWP.pm i will need to request an external URL multiple (several hundred) times, where each request contains a different arg. then i need to process each response: http://foo/bar?arg=84375 http://foo/bar?arg=43896 http://foo/bar?arg=98945 ... the problem is that i need to do this from within a single Apache/mod_perl process. so i'd like to spin off about 10-20 threads and let them handle the task concurrently by using LWP, join on them, collect the response data and finally send a summary to the client. is this possible on mod_perl-1.26 (with 5.6.1, on either Linux, FreeBSD or Solaris)? what are the caveats? if possible, one thread blocking for socket IO should not block the entire Apache/mod_perl process. will perl take advantage of kernel threads if the host OS supports them? is there anything special regarding perl/mod_perl/Apache compilation (besides of -Dusethreads)? should i use 5005threads (Thread.pm) or ithreads for this task? is LWP considered thread-safe? thanks, I would like to unask your many interesting questions by asking if it's absolutely necessary that the data being returned by your processes has to be done through an HTTP request. If you need some large dataset that can be had by making all these requests, could you not package up the logic into one module to do all the requisite queryring (or whatever) and return you one large chunk of data? If the HTTP interface is absolutely necessary, I'd still question whether you could make put all your logic into something like a SOAP interface. ky
Re: Unpredictable Effects after Upload...
On Wed, 31 Oct 2001, Jonathan M. Hollin wrote: Date: Wed, 31 Oct 2001 12:34:40 - From: Jonathan M. Hollin [EMAIL PROTECTED] To: [EMAIL PROTECTED] Subject: Unpredictable Effects after Upload... Hello all, Platform: Windows 2000, Apache, mod_perl Problem: When submitting forms that include files (uploads) my script becomes very unpredictable - CGI.pm doesn't seem to be able to recognise any data that's passed as part of the query string (it does still process form input though) once a file has been uploaded. Submit the same form but without attaching a file and everything works perfectly. There is nothing in the error logs to indicate what the problem might by (I'm using the -w flag). Can anyone offer any insight into what might me going on here? Jonathan M. Hollin - WYPUG Co-ordinator West Yorkshire Perl User Group http://wypug.pm.org/ Jonathan, Please try using Apache::Request instead of CGI.pm. Furthermore, look into Apache::Upload. I'll bet these modules will fix your problems. `perldoc` those modules (install them if you have to) and also read The Guide (tm) for more information: http://perl.apache.org/guide/ ky
Re: CGI.pm params not being cleared?
On Mon, 1 Oct 2001, Alex Harper wrote: Date: Mon, 1 Oct 2001 16:16:34 -0500 From: Alex Harper [EMAIL PROTECTED] To: [EMAIL PROTECTED] Subject: CGI.pm params not being cleared? I'm sure this is a FAQ somewhere, but I'm not finding it... In our switch to mod_perl we're seeing two problems with CGI.pm (version 2.752). I'm uncertain if they are related or not. 1. Across multiple requests to a single script, the params are not cleared. The first params sent to that script (per Apache server) are wedged permanently. It doesn't seem to matter if the params came from GET or POST. 2. Despite precompiling CGI.pm using its compile method in our mod_perl startup, we constantly see warning for CGI.pm subroutine redefinitions (start_html, etc.) We precompile CGI.pm in our mod_perl startup as follows (from the guide): use CGI qw(-compile :all); In the script in question params are read like so: use CGI; $cgi = new CGI; if ($cgi-param(dataaction) eq whatever) { # Does something useful } Perhaps you ought to declare $cgi with a my? Some of our modules also create (and destroy) CGI objects, but none of them are global, and I can't see any way for the script to be getting confused with a module's copy (the script itself does not user those modules, though they are precompiled during mod_perl startup). Obviously I must be doing something wrong... Any suggestions? Well, despite CGI.pm's overall usefulness, is there any reason you don't use Apache::Request? It's definitely faster. ky
Re: browser refresh problem
On Fri, 28 Sep 2001, Michael Manning wrote: Date: Fri, 28 Sep 2001 13:50:31 -0400 From: Michael Manning [EMAIL PROTECTED] To: [EMAIL PROTECTED] Subject: browser refresh problem Hi: I am using a server with the following info: Apache/1.3.11 (Unix) mod_perl/1.24 secured_by_Raven. 5.7 Generic_106541-08 sun4u sparc SUNW, Ultra-5_10. I have developed a program which reads a flat file, processes the data, prints out the rows of data, a counter then adds up the rows and produces a Total field. The total field is then set to zero and the loop continues until the end of the program, where a Grand Total is printed. On the initial running of the .cgi script it works fine producing the proper results. But, if I then press the refresh button on Internet Explorer (generally within 5 seconds), the total field does not clear. My program starts adding up the data again with a starting number at my final total value before the refresh. This continues every time I press the refresh button until I wait over five seconds. Then all is well and my program is cleared. Can anyone explain to my why this is happening and what I need to do to correct it? Thanks, Michael Manning [EMAIL PROTECTED] Michael, It sounds like you've not properly declared and/or scoped your variable. Are you running under strict? Is the variable a global? Can you post the relevant parts of your code? Also, do you notice this behavior when you running Apache in single server mode (httpd -X)? ky
Re: Perl Scripting help
On Thu, 27 Sep 2001, Matthew Blacklow wrote: Date: Thu, 27 Sep 2001 09:22:41 +1000 From: Matthew Blacklow [EMAIL PROTECTED] To: [EMAIL PROTECTED] Subject: Perl Scripting help I am writing a script at the moment which among others things creates another process using the system call. What I need to do is capture the screen output of this process into a string variable so that it can latter be manipulaterd. ie. capture the STDOUT. Any help, suggestions or sample code would be appreciated. Thanks, Matthew Matthew, This isn't the right forum for general Perl help. Generally speaking, you should only post mod_perl-specific questions. If your question is how best to capture STDOUT from an external program from within a mod_perl program, then I might suggest you examine something like Apache::SubProcess or just search The Guide (http://perl.apache.org/guide) or use Google to search the web for your answer -- all of which is not to say that you couldn't just backtick your program and capture the output in a scalar. There's lots of information on this. `perldoc perlop` and look for backtick, or, again, use Google to look for your answer. Or consider posting your question to an audience who will be more likely to answer your question, like comp.lang.perl.misc. ky
Re: Share data between pages web?
On Wed, 19 Sep 2001, jlm wrote: Date: Wed, 19 Sep 2001 18:00:05 +0200 From: jlm [EMAIL PROTECTED] To: [EMAIL PROTECTED] Subject: Share data between pages web? ¡Hello! I'm a student what is constructing a web site with CGI and nothing but perl. I have a problem, how share data between pages web? Do you know about the excellent guide? http://perl.apache.org/guide It sounds like you're just getting started, so it'd be best to read some docs and books, like the Eagle book (_Writing Apache Modules in Perl and C_). I want some similar a object Session in ASP, but en perl. Do you know about Apache::ASP? It is a pure Perl implementation of Microsoft's ASP. The system of object of perl to allows? I can make it? I have use mod_perl? Not sure what you mean here. mod_perl is not (exactly) like CGI/Perl. There's more to it. Are you using mod_perl or just CGI/Perl stuff? If you're just looking for a way to store state information between CGI requests, then check out this older article from _The Perl Journal_: Saving State with CGI.pm by Lincoln Stein Issue 2, Summer 1996 http://www.samag.com/documents/s=1283/sam01020004/ Help me. Thank by advanced. PD: I'm sorry by my english. Does that help? ky
Re: Apache::DBI
On Thu, 26 Jul 2001, Castellon, Francisco wrote: Date: Thu, 26 Jul 2001 07:48:14 -0600 From: Castellon, Francisco [EMAIL PROTECTED] To: [EMAIL PROTECTED] Subject: Apache::DBI Does anyone know if Apache::DBI is included with mod_perl? if not could someone tell me where i could get it from? http://cpan.org/ ky
Re: Errors when trying to use AuthAny.pm
On Wed, 11 Jul 2001, Justin Rains wrote: Date: Wed, 11 Jul 2001 07:04:43 -0700 (PDT) From: Justin Rains [EMAIL PROTECTED] Reply-To: [EMAIL PROTECTED] To: [EMAIL PROTECTED] Subject: Errors when trying to use AuthAny.pm Hi all. I am relatively new to mod_perl so try to bear with me. I am trying to use the AuthAny.pm module to provide some basic authentication. First off.. Do I put it in the same directory as Registry.pm? That is where I have it now. In my httpd.conf file I put the following in: Location /tools AuthName Test AuthType Basic PerlAuthenHandler AuthAny require valid-user /Location /VirtualHost I am running on a cobalt raq 3. Here is what I have in AuthAny.pm: package Apache::AuthAny; # file: Apache/AuthAny.pm use strict; use Apache::Constants qw(:common); sub handler { my $r = shift; my($res, $sent_pw) = $r-get_basic_auth_pw; return $res if $res != OK; my $user = $r-connection-user; unless($user and $sent_pw) { $r-note_basic_auth_failure; $r-log_reason(Both a username and password must be provided, $r-filename); return AUTH_REQUIRED; } return OK; } 1; __END__ The error log message is: [Wed Jul 11 09:04:59 2001] [error] (2)No such file or directory: access to /tools/ failed for nr2-216-196-142-76.fuse.net, reason: User not known to the underlying authentication module Am I missing something here? I am using the standard apache that came with the raq. Thanks for any help! Justin == Justin Rains WSI.com Consulting http://www.wsicnslt.com/ Justin! Wassup? Welcome to mod_perl! It's good to see your name on the list. Since no one seems to have answered your question, I'll give it a shot. The only thing I can come up with right now is that you might have mistyped the Location directive. You have: PerlAuthenHandler AuthAny And the Eagle book (page 283) has: PerlAuthenHandler Apache::AuthAny Other than that, I can't really see a problem. I pasted your code into my own module (not in the Apache namespace, however), and it all worked without a problem. FWIW, I tend to carve out my own namespaces and place my Apache Perl modules into a library path that gets a use() in a startup file. To be more explicit, I'll put my stuff into a directory like /usr/local/apache/lib/perl. Then in my httpd.conf, I'll add a line line like PerlRequire conf/perlstartup.pl (where conf is relative to the server root, or just whereever you want to put it). My Perl startup file then uses all the modules I've written, like so: #!/usr/bin/perl # file: perlstartup.pl use lib '/usr/local/apache/lib/perl'; use Foo::Bar; use Foo::Baz; use Foo::AuthAny; 1; HTH! ky
Re: mod_perl and 700k files...
On Wed, 9 May 2001, Morbus Iff wrote: Date: Wed, 09 May 2001 17:45:03 -0400 From: Morbus Iff [EMAIL PROTECTED] To: Perrin Harkins [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Subject: Re: mod_perl and 700k files... Ok. Thanks for the replies everybody. Collectively, I'm looking for a solution that DOES NOT require an Apache restart, or one that requires me to use a kill/killall command. I'm not in front of the server 100%, and I won't have access to telnet/ssh in to issue commands. Ultimately, I'm looking for something I can do totally from within Perl. Couldn't you create a Perl script to run as a cron job that could stat the file off-line for you and HUP the server when it has changed? That would seem easy enough. You'd just have to work out the perms on the cron user to make sure it could affect httpd. Restarting Apache isn't the end of the world, is it? ky
Re: forbidden vs. cookie
On Mon, 30 Apr 2001, will trillich wrote: Date: Mon, 30 Apr 2001 18:17:11 -0500 From: will trillich [EMAIL PROTECTED] To: [EMAIL PROTECTED] Subject: Re: forbidden vs. cookie On Mon, Apr 30, 2001 at 03:46:17PM -0400, Ken Y. Clark wrote: Here is some code I've used in the past in a mod_perl app to set a cookie and do a redirect at the same time. I believe it works for most browsers -- or at least this code has been working for over a year and I haven't heard too many complaints about this piece (that I can think of). my $cookie = Apache::Cookie-new($apr, -name= 'foo', -value = 'bar', -expires = '+30m', -domain = '.domain.com', -path= '/', ); $cookie-bake; $apr-method_number(M_GET); $apr-method('GET'); $apr-headers_in-unset('Content-length'); $apr-headers_out-add('Location' = '/foo'); $apr-status(REDIRECT); $apr-send_http_header; return OK; i presume $apr is as in sub handler { my $apr = shift; ... ? Yes. I'm sorry, I should have been more explicit. Actually, the first line of the handler() is this: my $apr = Apache::Request-new( shift() ); and is this in PerlAuthhandler? No, I used this in a PerlHandler as the Location for logging a user into the mp3.boston.com site. Again, I believe my method works -- though I never tested it exhaustively in every conceivable browser. I simply made sure it worked on the major browsers (Netscape and IE) on Linux, Solaris, Mac and Windows. I wanted to do exactly what you want: Set a cookie (mine being the logged in information) and simulaneously redirect the user to their home page on the site. I do, however, use a PerlAccessHandler like so: Location /upload PerlAccessHandler BGEP::MP3::VerifyLogin ErrorDocument 403 http://mp3.boston.com/login/login.shtml /Location It checks every request for a valid session cookie (which contains nothing more than the user's id and will fail to be returned when the cookie expires). after seeing the 'expires' dilemma brought about by poorly configured client system clocks, what advice should we follow? (what's the Official Party Line on expiring cookies?) I'm not really sure how to answer your question. I have usually understood that the client handles all of this. That is, you tell the client that the cookie is good for 30 minutes, and it figures out when those 30 minutes have expired and then quits sending a valid cookie back to the server. Is that right? Anyone? Anyone? Bueller? ky
Re: forbidden vs. cookie
On Mon, 30 Apr 2001, will trillich wrote: Date: Mon, 30 Apr 2001 14:31:02 -0500 From: will trillich [EMAIL PROTECTED] To: [EMAIL PROTECTED] Subject: forbidden vs. cookie i could really use some dumbed-down tips on setting cookies during a redirect. boy, this is really getting to me. using apache 1.3.9 on debian 2.2/potato in trying to implement the concept of the Apache::Ticket*.pm modules from the Apache Modules (eagle) book in chapter 6 (on pages 304+) i'm running into browser compatibility problems. SOME browsers (differs among platforms, too) see the forbidden or redirect codes and take action immediately, ignoring any set-cookie headers that are also sent. as a workaround, i was trying to change TicketAccess.pm to # the munged version trying to accomodate rude browsers: package Apache::TicketAccess; use strict; use Apache::Constants qw(OK FORBIDDEN REDIRECT); use Apache::TicketTool (); sub handler { my $r = shift; my $ticketTool = Apache::TicketTool-new($r); my($result, $msg) = $ticketTool-verify_ticket($r); unless ($result) { $r-log_reason($msg, $r-filename); my $cookie = $ticketTool-make_return_address($r); #the original code that works for SOME browsers: # $r-err_headers_out-add('Set-Cookie' = $cookie); # return FORBIDDEN; my $login_uri = $r-dir_config(TicketLogin); # as AccessHandler, this was very much a bad idea: # use CGI '-autoload'; # print # header(-refresh = 1; URL=$login_uri, -cookie = $cookie), # start_html(-title = 'Redirecting to login', -bgcolor = 'white'), # h1('Gotta log in, first'), # p(You're being redirected to , # a({-href=$login_uri},$login_uri), #in just a moment.), # h2(Please stand by...), # end_html(); # return OK; # it does manage to redirect the browser but there's lots # of duplicated headers and garbage (plus just hitting the # BACK button bypassed the need to log in) # this don't work so not, neither: $r-header_out(-cookie=$cookie); $r-header_out(-location=$login_uri); return REDIRECT; # neither header is sent. } return OK; } 1; __END__ i've spent hours flipping back and from from the index to the text, slapping postit notes on every other page, scanning Apache::*.pm source code -- and it's still not sinking in... a little help would be appreciated! AAUGH! Will, Here is some code I've used in the past in a mod_perl app to set a cookie and do a redirect at the same time. I believe it works for most browsers -- or at least this code has been working for over a year and I haven't heard too many complaints about this piece (that I can think of). my $cookie = Apache::Cookie-new($apr, -name= 'foo', -value = 'bar', -expires = '+30m', -domain = '.domain.com', -path= '/', ); $cookie-bake; $apr-method_number(M_GET); $apr-method('GET'); $apr-headers_in-unset('Content-length'); $apr-headers_out-add('Location' = '/foo'); $apr-status(REDIRECT); $apr-send_http_header; return OK; HTH, ky
Re: Long waits on SQL Stored Procs. Should I use chained contenthandlers?
On Mon, 2 Apr 2001 [EMAIL PROTECTED] wrote: Date: Mon, 2 Apr 2001 14:06:40 GMT From: [EMAIL PROTECTED] To: [EMAIL PROTECTED] Subject: Long waits on SQL Stored Procs. Should I use chained content handlers? I need to run some stored procedures that take upwards of a minute to generate result sets. Ok, thats grand but I dont want the browser to sit there and twiddle. I'd like to display an animated gif. Simple. Right? I hope. I'm looking into chained handlers in my mod_perl code, but I'm not sure if this is what I need. 0) Request page and report. 1) Push 'Waiting...' animated gif 2) Process report, Perl waits for result set 3) Perl pushes the report html to the browser as if it opened in a target = _blank window. IE: That same window... Stumped (or rather - RTFMing), Any ideas? I cant, for the life of me, figure out how this would work with http redirects, and thought there might be something with mod_perl that would help this. Fork() maybe. I'm trying a few ideas. Thanks a bunch. If this is slightly OT, I apologize. Tom Sullivan, [EMAIL PROTECTED] - This message was sent using Endymion MailMan. http://www.endymion.com/products/mailman/ Could you make the page displaying the animated gif have a "refresh" tag of maybe 30 (or fewer) seconds, at the end of which it could redirect to a page that could see if the query has finished? If not, it would return to the animated gif page again and wait some more. ky
Re: Send a cookie, AND a redirect ?
On Thu, 8 Feb 2001, Harrison wrote: Date: Thu, 8 Feb 2001 12:30:31 - From: Harrison [EMAIL PROTECTED] To: [EMAIL PROTECTED] Subject: Send a cookie, AND a redirect ? Dear All. I can set a cooke fine using: $r-content_type('text/html'); $r-header_out('Set-Cookie' =$cookie); $r-send_http_header; And i can also send a redirect fine using: $r-content_type('text/html'); $r-header_out('Location'=$the_url); return REDIRECT; BUT! how do i do both? if i use my redirect code, and add an extra header_out , the cookie is not sent (because i have not called send_http_header ? ). If i add send_http_header, i see the full sent http_header in my browser. My idea was to have something like $r-content_type('text/html'); $r-header_out('Location'=$the_url); $r-header_out('Set-Cookie' =$cookie); $r-send_http_header; return REDIRECT; Which does not work. Thinking about it whilst typing this email, does header_out have a field where i can set the REDIRECT status? Thanks in advance, Richard Harrison. I've had good luck using Apache::Cookie. Like so: sub handler { my $apr = shift; my $cookie = Apache::Cookie-new($apr, -name= 'foo', -value = 'bar', -expires = '+30m', -domain = 'baz.com', -path= '/'); $cookie-bake; $apr-method_number(M_GET); $apr-method('GET'); $apr-headers_in-unset('Content-length'); $apr-headers_out-add('Location' = 'index.html'); $apr-status(REDIRECT); $apr-send_http_header; return DONE; } ky
Re: IDE for Perl
On Thu, 1 Feb 2001, Jimi Thompson wrote: Date: Thu, 01 Feb 2001 11:48:07 -0600 From: Jimi Thompson [EMAIL PROTECTED] To: [EMAIL PROTECTED] Subject: IDE for Perl Can anyone tell me if there's a good IDE for PERL? I have some big projects coming and having the debug/testing etc. would be sooo bonus. I looked at ActivePerl, but was hoping that maybe there was something else either better or cheaper. I wish Adobe and Macromedia would make a Linux version of everything. Then I'd never have to touch "the other OS" again. -- Jimi Thompson Web Master Link.com "It's the same thing we do every night, Pinky." I prefer vi. ;^) ky
Re: [OT] Design Patterns in mod_perl apps?
On Tue, 30 Jan 2001, Bakki Kudva wrote: Date: Tue, 30 Jan 2001 14:13:14 -0500 From: Bakki Kudva [EMAIL PROTECTED] To: [EMAIL PROTECTED] Subject: [OT] Design Patterns in mod_perl apps? I am studying mod_perl and the GoF Desing Patterns book in parallel and had a few questions I would like to throw to the list. 1. Is there anyone who is using GoF design patterns (eg. Chain of Responsibility for handlers) in their mod_perl apps? Well, I don't want to sound stupid, but I don't know what you're talking about. That's one of the hazards of having a degree in English and not CS, I guess? :) 2. Is the overhead of OO Perl acceptable for mod_perl apps, generally speaking? Sure. 3. Are there any new patterns useful for mod_perl apps? I'm not sure what was old or what constitutes new. I tend to write a lot of vanilla handlers. I've looked into Mason and AxKit and such, and they're fantastic, but just shifting $r and returning OK seems to work really well most of the time. 4. Am I wasting my time with OO and design patterns if the goal was writing a mod_perl app? Absolutely not. If an OO design is appropriate, then use it. When I've wanted an object, I've created it. I've even used OO methodology to write base classes for handlers and deriving from them for other handlers. Just do what feels right and enjoy yourself. ky
Re: Advice needed. (web app. performance)
On Mon, 29 Jan 2001, Vladislav Safronov wrote: Date: Mon, 29 Jan 2001 17:52:42 +0300 From: Vladislav Safronov [EMAIL PROTECTED] To: [EMAIL PROTECTED] Subject: Advice needed. (web app. performance) Hi, I've just finished a simple web based spellcheck application based on ispell, it's written as perl module which just call ispell on every request (actually keeps it open afert first request). The bad thing is N users used spellcheck there are N running useless ispells and it is not good I think. I think as sort of spellcheck server should be written which can fork accordingly to user requests. Where can I find sample code (skeleton code) for such server? Would you recommend any other method? Thanx, \Vlad. How funny. I just spent the last several days working on the exact same code. I used Lingua::Ispell to communicate with ispell. It's pretty good, but I think it could be written much more cleanly. (I know, I know patches are always welcome :) I spent a long time last week closely examing the source for Lingua::Ispell because I encountered what turned out to be a bug in mod_perl versions 1.23 and higher built with Perl 5.6.0 where the STDIN and STDOUT get very, very confused. You could always take a look at that code to get a feel for where to start. I began hacking on my own implementation, playing with IPC::Open2 and IO::* modules. Very interesting stuff. Anyway, that's what I'd recommend. BTW, any chance I could take a look at how you solved the problems? I'm still working on my version. ky
Re: dynamic vs. mostly static data
On Thu, 2 Nov 2000, Neil Conway wrote: Date: Thu, 2 Nov 2000 16:45:28 -0500 From: Neil Conway [EMAIL PROTECTED] To: ModPerl List [EMAIL PROTECTED] Subject: dynamic vs. mostly static data I'm writing a web app in mod_perl, using a PostgreSQL database backend and HTML::Template. In looking for ways to optimize performance, I noticed that although my code is doing several (say, 4-5) database queries per handler/webpage, a large part of the data (~2 queries) is mostly static (it will change perhaps once per week, or once per month). It's obviously inefficient to run these queries on the database for every single request. How can I 'cache' this data so that all Apache children can access it quickly? Is there a way to automatically update this cache periodically (say every 10 minutes)? Also, this solution should work on any reasonably modern UNIX system (Win32 is not important for now). I couldn't find this anywhere, but if someone tells me where, I'd be happy to RTFM. Ask me if you need more info. TIA, Neil neil, i often do something like this where i allow each individual child process to cache it's data. i do something like this: package Apache::Foo; use strict; use Apache::Constants; use POSIX 'strftime'; use constant CACHE_EXPIRES = 3600; # one hour use vars qw[ %CACHE ]; %CACHE = (); sub handler { my $r = shift; eval { my $expires = $CACHE{'expires'} || 0; if ($expires time) { my @data = some routine ; my $t = HTML::Template-new(filename = 'foo.tmpl', die_on_bad_params = 0, cache = 1); $t-param('data', \@data); $CACHE{'data'}= $t-output; $CACHE{'expires'} = time + CACHE_EXPIRES; } $r-print($CACHE{'data'}); }; return print_err($r, $@) if $@; return OK; } 1; btw, i'd really recommend you look into using Template Toolkit. it's a much more powerful and flexible templating system than HTML::Template, but i digress (and might start a flame war against myself by saying this). hth, ky
Re: Uploading File
Lola Petzold ([EMAIL PROTECTED]) said something to this effect: New to mod_perl and am having problems writing a script to allow our creative department the ability to upload banners to a directory on our server. I'm using Apache::Request, but keep getting stuck and am ready to pull my hair outanother problem i have to deal with is that the banners have to go into different directories within the banner directory depending on what size they are. Can anyone give me any hints or tips? Or if anyone has a chunk of code I could possibly use I would really appreciate it. I'm ready to give up! perldoc Apache::Request and read about the Apache::Upload object. i think that will solve your problems. ky
Re: executing a cgi from within a handler (templating redux)
On Wed, 23 Aug 2000, Todd Finney wrote: Hi, I'm building a simple templating system. The major requirement of the system is that allow custom dynamic headers, footers, and toolbars based upon the identity of the user. is there a particular reason why you've not chosen to use one of the very excellent existing templating systems? i've used HTML::Template for many things; it's very lightweight and incredibly easy, and i'm pretty sure it would solve your problems. lately, i've been getting into Template::Toolkit, and i find it to be *very* powerful, easy, and much more flexible than HTML::Template. i'd really recommend you exhaust all your options with one of the currently available template kits on CPAN before you roll your own. ky
Re: Apache::Upload buffering issues?
On Tue, 15 Aug 2000, Ian Mahuron wrote: What is the proper way to take the filehandle provided by $upload-fh and write the file to disk? I seem to be having buffering issues w/ the following (file is truncated): if (open(OUTFILE, "$u_fullpath")) { print OUTFILE $buffer while read($fh, $buffer, 8*1024); } else { ... } a simple $| = 1; before the print didn't seem to help.. maybe OUTFILE is not hot? Dunno.. this is my first run in w/ buffering issues. I hope someone can help. TIA Ian here's what i do in one of my modules: my $file_size = $upload-size || 0; if ($file_size == 0) { return $self-err_out("You didn't supply a valid file."); } # # write the data to file, making sure what gets # written is the same as what we expected # my $umask = umask 02; eval { no strict 'refs'; my $fh = $upload-fh or die 'No file handle'; my $data = ''; my $length = 0; { local *F; open(F, " $file_path") or die "Failed to open '$file_path': $!"; while ( read($fh, $data, 4096) ) { print F $data; $length += length($data); } close F; } if ($length != $file_size) { die "Failed to write '$file_path' to file"; } }; # # reset umask # umask $umask; hth, ky
Re: Templating System
On Thu, 27 Jul 2000, Roger Espel Llima wrote: On Thu, Jul 27, 2000 at 01:28:06PM +0200, Darko Krizic wrote: There is one big difference in the enhydra approach: The templates are standard HTML, because the id tag is part of the HTML standard. The designer can create the whole site and make a dry test, because all links even work. The tags (with ids) can contain valid values. i know it's already been mentioned in this thread in passing, but i'd like to stress how easy i've found it is to work with HTML::Template. the templates are straight HTML w/obvious and easy-to-work-with template tags embedded, like so: html head title ABC, Co. Website /title /head body h1 ABC, Co. Website /h1 hr Welcome, tmpl_var name=customer_name. p asdf asdf adsf asdf asdf asdf asdf afs asdf asdf asdf asdf /p p tmpl_if name=print_data table tr th First Col /th th Second Col /th /tr tmpl_loop name=data tr td tmpl_var name=column_one /td td tmpl_var name=column_two /td /tr /tmpl_loop /table tmpl_else I'm sorry, but no data was returned. /tmpl_if /p /body /html that's a simple example, but you can see that you have some rudimentary control structures (if, loop) and simple variable substitution. the perl code controlling it can be fairly lightweight, too. my $sth = $db-prepare($sql); $sth-execute; my (@data, $hashref); push @data, $hashref while $hashref = $sth-fetchrow_hashref; my $t = HTML::Template-new(filename = '/path/to/templates/foo.tmpl'); $t-param('customer_name' = 'Tom Jones', 'print_data'= (@data) ? 1 : 0, 'data' = \@data); $r-print($t-output); HTML::Template may not solve all your problems, but if you need something quick, i think it's a pretty good solution. ky
Re: Data structure question
On Tue, 6 Jun 2000, Drew Taylor wrote: I have a question about data structures. Currently, I am doing SQL queries and returning an array ref and a hash ref. The array is to preserve order, and the hash contains various bits of data about that not to be dense, but can't you just issue an "order by" clause as part of your SQL statement? ky
Re: database efficiency
On Mon, 15 May 2000, Jeffrey W. Baker wrote: On Mon, 15 May 2000, Jay Jacobs wrote: I've been reading over the guide on "Efficient Work with Databases under mod_perl" and there's one thing I don't quite grok about it. Let's say I have a site that goes through select statements like water. If I were to cache the statement handler (as described in the guide), how does the database (database dependant) handle a bunch of dangling statement handlers? Will the database process size grow a ton? I'm not sure if I'm hitting what I wanted to ask, but hopefully I'm close enough. Every statement handle that you leave open will consume resources on the database server, and also on the client side. These resources are presumed to be more plentiful than the resources (CPU time and network packets) needed to frequently setup and teardown statement handles. if this behavior is unacceptable, i believe you can use the finish method: finish $rc = $sth-finish; Indicates that no more data will be fetched from this statement handle before it is either executed again or destroyed. It is rarely needed but can sometimes be helpful in very specific situations in order to allow the server to free up resources currently being held (such as sort buffers). (from perldoc DBI) ky
Re: Templates.
On Wed, 3 May 2000, Jason C. Leach wrote: I'm looking for some good ideas on developing web sites w/ mod_perl. One think we were looking at was to write template HTML pages, and run them through a perl prg to replace home made tags w/ data. Another was to write an apache mod that will contain/load the HTML on the first hit and cach all the pages and gfx (not too much). Can anyone comment on some good techniques to develope mod_perl sites? We will need mod_perl to be fast, interact w/ a DB, and run of FreeBSD or Linux. we use the following at boston.com on numerous sites (mp3.boston.com, www.digitalmass.com, travel.boston.com, ae.boston.com, www.boston.com) with great success: Linux Apache/mod_perl HTML::Template MySQL this combination makes for a very stable development environment for us. hth, ky
Re: Problem with deleting uploaded files
On Thu, 4 May 2000, Srinidhi Rao S wrote: Hi all, Here I have a problem. I used CGI module to upload a file. But the problem is that the temp file created by CGI module is not getting deleted even after execution finished. It simply getting heaped in temp directory eating memory. Can anyone please give me a way through this??? Here is a part of code I have written use CGI; use CGI qw (:standard); use CGI::Carp qw (fatalsToBrowser); $CGI::POST_MAX=1024 * 350; my $QObject = new CGI; print $QObject-header; $file_name = $QObject-param('upload'); open (FILE,"../xxx.jpeg") || die "cannot open the image file\n"; while(read($file_name,$data,1024)) { print FILE $data; } close(FILE); print "Success"; I also have one more problem. If I upload a Image file, the image will be corrupted in the uploaded file. Why is this hapenning? Any help is hugely appriciated. from `perldoc CGI`: STARTING AND ENDING A FORM multipart/form-data This is the newer type of encoding introduced by Netscape 2.0. It is suitable for forms that contain very large fields or that are intended for transferring binary data. also: To be safe, use the upload() function (new in version 2.47). When called with the name of an upload field, upload() returns a filehandle, or undef if the parameter is not a valid filehandle. $fh = $query-upload('uploaded_file'); while ($fh) { print; } This is the recommended idiom. there's some more info there. do perldoc and then search for "binary." ky
Re: Upload file
On Wed, 3 May 2000, Srinidhi Rao S wrote: Hi all, I am new to perl programming. I am working in a project where I need to upload some files in a web interface. I used HTML file upload object with POST method. My question how do I receve the uploded file on the server side. Is there is any module o call in PERL to do this job. Please help me in this regard. Any help is appriciated. TIA Srinidhi Rao Robosoft Technologies E-mail: [EMAIL PROTECTED] www.robosoftin.com welcome to the wonderful world of perl. you should know that your question is not really a mod_perl question, but a straight-up perl/cgi one. that said, under cgi, you're best using CGI.pm, which is a standard perl module. for more information, do "perldoc CGI" to learn how to use this module. if you move to a mod_perl evironment, you should consider using Apache::Request/Apache::Upload. again, 'perldoc $_ for qw(Apache::Request Apache::Upload)'. ky
Re: environment
On Mon, 1 May 2000, Thomas Glass wrote: Hi everyone,I'm having a problem and I wonder if you guys couldhelp me out: I have a script whose behaviour depends on the main path environment variable (and a cookie). The problem is that after a couple of reloads, the environment variables seem to get cached and the result comes out -obviously- wrong. I guess my question is: Is there any way to ensure that the script will get the right environment variables? maybe something in the apache configuration file? i don't like to rely on %ENV in a mod_perl environment. there are just so many better ways of doing this using the Apache API we havebut: http://perl.apache.org/guide/control.html#Wrapper_to_Emulate_the_Server_En i'd recommend doing things w/PerlSetVar and such: http://perl.apache.org/guide/config.html#PerlSetVar_PerlSetEnv_and_PerlP ky
Re: how to rewrite to a POST
On Wed, 26 Apr 2000, David Hajoglou wrote: so, is it possible to take a GET request and rewrite the uri into a POST request and if so how? i'm not sure if that's really necessary. you could just put the GET args into $r-pnotes, perhaps like so: sub handler { my $r = shift; return DECLINED unless $r-is_main(); my $apr= Apache::Request-new($r); my @params = $apr-param; my %args = (); $args{$_} = $apr-param($_) for @params; $r-pnotes('args', %args); return OK; } ky
Re: Remote URL
On Fri, 14 Apr 2000, Paul McCumber wrote: I want to build a web page dynamically with content from several other web sites. I need to be able to fetch the remote URL's content into variables. How do I do that? For starters, I just have a module that just goes and gets a URL and writes that URL back to the browser. Can't even get that to work. I think the hardest thing for me is that there is just no way to debug it. Admittedly, I'm new to this environment but I just getting killed. Very easy thing to do in ASP but I want to use Perl and Apache and Linux. well, this isn't really mod_perl, just perl. if you're having trouble debugging (yes, mod_perl is a bit more of a challenge to debug, having to restart your server b/w code changes, unless you use StatINC), then i'd recommend writing your first iteration as a straight CGI script, using "strict" and all that good stuff. if it works properly, you could always run it (mostly) unchanged under Apache::Registry. for the fetching of remote web sites: have you tried LWP? very nice package. ky
Re: Compiler errors...
On Fri, 14 Apr 2000, Robert Jenks wrote: We are currently using Linux/Apache/mod_perl (and Stat::INC) with good success (thanks to the help of this list) as a replacement for WinNT/IIS/Velocigen. Everything is (now) going good except that we miss one of Velocigen's debugging features. Velocigen would display compiler errors to the browser (after a file-change recompile). I'm currently using CGI::Carp qw(fatalsToBrowser), but this only shows runtime errors. Is there a way to do this? I've thought about using the Apache "ErrorDocument" config to call a perl script which would display the last few lines of the error_log, but it wouldn't be very elegant. robert, i would suggest wrapping all the meat of you code in an eval, and then checking for errors on exit. when things go wrong, you handle the error. when things are fine, you create output, like so: package Foo::Bar; use Apache; use Apache::Constants qw(:common); use strict; sub handler { my $r = shift; eval { # put anything here that could possibly error out # like database connections, file reads, etc. }; $r-content_type('text/html'); $r-send_http_header; if ($@) { $r-print("There was an error: '$@'"); } else { $r-print('Apache/mod_perl rules!'); } return OK; } 1; hth, ky
Re: [slightly OT] Problem with cookies
On Fri, 7 Apr 2000, Drew Taylor wrote: Randal, Thanks for the tip. So my question is: what is the best solution? I want to redirect http://cloudstock.com/ to http://www.cloudstock.com/. Should I take out the permanent in the Redirect directive? Should the www entry come first? Do I need to get another IP address? i'm just learning about the beautiful magic of the RewriteEngine. could this be a good solution for you? in order to make sure cookies always work properly on http://mp3.boston.com which is aliased as http://music.boston.com, we use the following RewriteRule: RewriteEngine on RewriteCond %{HTTP_HOST} !^mp3\.boston\.com [NC] RewriteRule ^/(.*) http://mp3.boston.com/$1 [L,R] this ensures that every request gets fixed as "mp3.boston.com" no matter how it comes to us. i think this is what you want. see here for more documentation: http://www.apache.org/docs-1.2/mod/mod_rewrite.html ky
Re: mod_perl + database?
On Mon, 3 Apr 2000, Wu, Gordon wrote: Can I use mod_perl to access database, such as oracle? Which database are supported in mod_perl? thanks, Gordon Wu gordon, the answer is an emphatic "Yes!" thanks to the developers of the freely available Perl DBI/DBD modules (see http://search.cpan.org), many database interfaces are supported. perhaps you start at the very excellent mod_perl guide: http://perl.apache.org/guide/ ky
Re: Perl and SQL, which is the most scalable SQL server to use?
On Wed, 9 Feb 2000, Ryan, Aaron wrote: Hi, We have designed a web site creator that uses Perl and DBI to work with MySQL. The integration between the two was great, but recently our website has been over run with users and our poor MySQL database is showing some major slow downs. So we have two possible solutions we are researching. Trying to optimize the MySQL to work better under these stressful condition (which are going to get worse) or moving the SQL server onto another machine with a more scalable SQL server such as Sybase. However, we would like to make the move with the least amount of perl code modification. So if we could replace the current DBI:MySQL calls with Sybase DBI:DBLib calls or the like, that would be very attractive. at the very least, you should move mysql to a separate box, anyway. 3-tiered architecture should include physical and as well as logical separation of presentation/logic/data/. ky
Re: Problems w/ CGI under mod_perl
On Wed, 19 Jan 2000, Richard L. Goerwitz wrote: Before I turn everything inside out, let me ask a quick question: Has anyone encountered problems using CGI and CGI::Cookie with mod_perl? The Problem I am noticing emanates from CGI-new(). Here's the section of code: if ($MOD_PERL) { Apache-request-register_cleanup(\CGI::_reset_globals); undef $NPH; } The error I'm seeing is (taken from my Apache log files): Wed Jan 19 11:33:45 2000] [error] Can't call method "register_cleanup" on an undefined value at /usr/lib/perl5/5.00503/CGI.pm line 263. perhaps you should call Apache-request-new($r)-register_cleanup(\CGI::_reset_globals); ?? just a thought. ky
Re: can't load Apache::DBI in starup.pl file
On Tue, 21 Dec 1999, Nancy Lin wrote: Hi - I'm running apache 1.3.9/modperl 1.19/ApacheDBI-0.87/perl5.003 on redhat 6.0 In my startup.pl file, I have the following lines: use Apache::DBI; $Apache::DBI::DEBUG = 2; When I run it w/ the -c option, I get the following error message: Can't locate object method "module" via package "Apache" at /usr/lib/perl5/site_perl/5.005/Apache/DBI.pm line 202. BEGIN failed--compilation aborted at startup.pl line 35. One possible reason may be i'm using the apache-1.3.9-4.i386.rpm from redhat. The archives mentions that the default rpm for redhat 6.1 doesn't work. However, I couldn't find anything on the 6.0 rpms. Has anyone have any problem w/ 6.0's rpm? I would rather not compile the server myself if I don't need to. i have mod_perl compiled (not RPM's) on two different servers, and i see this message, too, when running perl -cw on my modules. however, it doesn't not prevent me from restarting my servers. i just have to run "./apachectl configtest" to really find my coding errors, which is kind of a pain. i just recently noticed this message happening, but i can't recall exactly what changed to bring it about. ky
trouble reading query string
i'm currently converting several CGI scripts into mod_perl modules, and i'm having difficulty in one particular situation reading the variable input (i.e., query string on a GET or STDIN on POST). quick background: i had a PerlHandler on the end of this request for a while, accepting input like "/foo?arg1=xarg2=y" which would create a form w/posted data (including binary info like .png, .gif, .jpg, and .mp3), save that data and return a user to a location. that was in the early stages of developing this. i'm now incorporating a more realistic shell around my dynamic output, one that show our ads which are proxy calls to a netscape ad server. my solution was to create a basic HTML page that has a simple perl sub on it, like so: !--File: foo.shtml -- html head title My Dynamic Page /title /head body !--#AD CALL -- !--#perl sub="Foo::Bar" -- !--#MORE AD CALLS -- /body /html a user gets to this page by clicking on a link like this: "/foo.shtml?arg1=xarg2=y". my module starts off like this: my $r = shift; $r = $r-is_main ? $r : $r-main; my %args = ($r-method_number == M_GET) ? $r-args : $r-content; but when i went from having the PerlHandler doing everything to having the module being called like an SSI call, %args doesn't get populated anymore. so i tried a hack i've done before with CGI.pm, like this: unless (%args) { my $q = CGI-new; my @names = $q-param; $args{$_} = $q-param($_) for @names; } but now, even this doesn't work, so i've had to put one more hack in, like this: unless (%args) { my $original_request = $r-the_request; my ($query_string) = ($original_request =~ m/\?(.*?)\s+HTTP.*/); my $q = CGI-new($query_string); my @names = $q-param; $args{$_} = $q-param($_) for @names; } so it now works, but i feel kinda dirty. and here's the last bit of strangeness: i have another page that is generated in the same manner that works just fine. the only difference is that the perl sub generates a form that is *not* enctype="multipart/form-data". both forms do, however, POST their data. any ideas why things are behaving so strangely? is my hack as objectionable as i think it is? ky
Re: Intercepting CGI.pm Header
On 6 Dec 1999, Martin Holz wrote: "Ken Y. Clark" [EMAIL PROTECTED] writes: On 6 Dec 1999, Martin Holz wrote: I am trying to catch the output of a CGI script and put the body of the generated HTML page in a template. Works fine unless the CGI script calls CGI::header. If the scripts calls CGI::header, two headers are sent, the first by Apache::Registry/CGI.pm, the second by my own content handler. Aparently CGI::header does not send its output to STDOUT, if it runs under Apache::Registry. How can I intercept the first header? [...] any reason why you can't use HTML::Template? it works beautifully for me, both under a CGI/Registry format as well as mod_perl modules. ky I use HTML::Embperl::Execute inside a mod_perl handler to process the template and it works fine with static files. The trouble starts when I want to embed the output of a CGI script into a template. I could easly solve the problem by modifing the CGI script, but I don't want to change it, because I didn't wrote it. Problem is both the CGI script and the my mod_perl-handler send a header. Martin Holz my experience w/something like the following: my $subr = $r-lookup_uri('/foo.html'); $subr-run; is that you have no control over what goes to STDOUT after you say "$subr-run". i would imagine you'll have the same problem when you run your CGI script. i assume you want to do something like read the output of the CGI into a string or array and then delete the header lines? can you do something like : my $result = `/usr/local/bin/perl /my/very/good/path/foo.cgi`; $result =~ s/bad-header//; $r-content_type("text/html"); $r-send_http_header; $r-print($myheader); $r-print($result); $r-print($myfooter); ??? i'm not sure this is such a good idea. if you could easily "solve the problem by modifing the CGI script," i would probably recommend doing just that. hth, ky
Re: mod_perl Programmers demand is going up...
On Fri, 3 Dec 1999, Jeffrey Baker wrote: Most people are lazy. Since it is easier to get started with VB/ASP/Crapomatic-9000, most people are going to start there. The people with real initiative and drive will always find their way over to mod_perl or other advanced solutions. The only way to make more people use mod_perl is to make mod_perl easier for the lazy people. I think dougm's book and your upcoming book will do a lot to make mod_perl more accessible. i definitely agree that most people are lazy. (some even refuse to use capital letters! :-) my first experience programming for desktop or web came from redmondware, but i was convinced that wasn't the best way to program. a friend told me about linux and perl, and i was on my way. it's been a difficult row to hoe at times, which is why i left my m$ past to find a unix shop w/guys to help me learn. making the transition from CGI to mod_perl was a conceptual leap for me that took several weeks to digest, but less time than it took for me to go from vb/pascal to perl, and less time for me to learn basic system tasks in moving from windows to *nix. after a great deal of effort expended learning how to do everything in the unix/perl/apache/mod_perl world -- everything from compiling my own kernels and packages to using $r -- i would agree that creating paths to learning that are well illuminated and logical in structure is a Good Thing(tm). as long as we never think that the way to increase the popularity of *nix-based tools is to dumb them down. if people are capable and will to learn perl and apache and such, they will. if they're not, they won't. i hope that doesn't come off as elitist, but i feel there's something to be said for paying your dues. if you want a gourmet meal, you're going to have to learn to cook it yourself (w/a substantial time investment) or you're going to have to go to a good restaurant (and probably pay a good bit for it). same with finding mod_perlers: you're either going to have to put in the time to grasp the concepts or you're going to have to pay a mod_perl/cordon-blue-trained-chef-of-web-development to write the stuff for you. either way, you tend to get a good product that won't give you literal or figurative heartburn, IMHO. ky
Re: return() and REDIRECT Disasters Within mod_perl: Please Help
On Fri, 3 Dec 1999, Jason Simms wrote: I am having a _really_ strange problem with return() under mod_perl. It seems that any time I attempt to do a return REDIRECT after I have accessed any passed parameters, the redirect will fail. However, if I do the redirect without accessing any passed parameters (either via POST or GET), the redirect works fine. I have debugged and debugged, and what I have found is that if I create a hash of the passed parameters using $r-content, $r-args, or even looping through with CGI::param, and then try and redirect, it will fail. The hash does indeed get created (I can loop through and output the values fine), but the browser will "hang" right when it tries to execute the return REDIRECT. If I do not create the hash, the redirect works perfectly. Perhaps some examples would help...: per http://perl.apache.org/guide/snippets.html#Reading_POST_Data_then_Redirect: Reading POST Data, then Redirecting or doing something else If you read POST data, then redirect, you need to do this before the redirect or apache will hang: $r-method_number(M_GET); $r-method('GET'); $r-headers_in-unset('Content-length'); $r-header_out('Location' = $ENV{SCRIPT_NAME}); $r-status(REDIRECT); $r-send_http_header; After the first time you read POST data, you need the code above to prevent somebody else from trying to read post data that's already been read. hth, ky
Re: $r-args missing data
On Thu, 2 Dec 1999, Christian Gilmore wrote: We just updgraded from apache-1.3.3/mod_perl-1.16 to apache-1.3.9/mod_perl-1.21 on solaris-2.5.1. $r-args does not contain any data for us now when it did before during the URI translation phase. [ snip ] The module: package TransTest; use lib qw(/weblab/services/pushweb/lib); use strict; use Apache::Constants ':common'; use Apache::Log; sub handler { my($r) = @_; $r-handler("perl-script"); $r-push_handlers(PerlHandler = \transtest_handler); return OK; } sub transtest_handler { my($r) = @_; my $log = $r-server-log; $log-debug("TransTest Handler entry"); $log-debug("The Entire Request: " . $r-as_string); $log-debug("The Request Line: " . $r-the_request); $log-debug("The Path Information: " . $r-uri); $log-debug("The Args: " . $r-args); my $response = "htmlbodyTransTest "; $response .= "response/body/html\n"; $r-no_cache(1); # Apache's no-caching (as of 1.3.0) is broken. # It just modifies stamp $r-header_out('Pragma', 'no-cache'); $r-header_out('Cache-control', 'no-cache'); $r-header_out('Content-Length', length($response)); $r-send_http_header(); $r-print($response); $log-debug("TransTest Handler exit"); } you might try referencing $r-main-args because you are passing $r to your trastest_handler. this has been a consistent thorn in my side for many applications. sometimes $r-main-args has it, sometimes $r-args, and sometimes i can successfully use a CGI query object and get it from $q-param. hth, ky
Re: Intentional Premature Finish in an Apache Module
On Thu, 28 Oct 1999, Public Interactive wrote: I'd like to be able to prematurely end the thread of execution within a Perl apache module from someplace *other than* the PerlHandler entry point subroutine (usually "handler()"). That is, when I'm a few subroutines deep inside my module, I want to be able to spit out an error page and have the module finish as if handler() had returned OK. Right now I'm painstakingly propagating return values back up to my handler() subroutine, but I'm hoping there's a better way. for what it's worth, here's what i do: package Foo::Bar; use strict; use Apache; use Apache::Constants qw(:common); use Foo::Error; sub handler { my $r = shift; eval { # any statements that could die go here do_something or die "can't do that"; }; return err_out($r, $@) if $@; $r-content_type('text/html'); $r-send_http_header; $r-print($t-output); return OK; } sub err_out { my $r = shift; my $err = shift; $r-push_handlers(PerlHandler = \Foo::Error::handler); $r-pnotes(ERROR_NAME, $err); return DECLINED; 1; # package Foo::Error; use strict; use Apache; use Apache::Constants qw(:common); use CGI qw(:html); use HTML::Template; # custom stuff use lib '/tech/bgeplib'; use BGEP::Splank::Constants; sub handler { my $r = shift; my $err = $r-pnotes(ERROR_NAME) or return OK; $r-content_type('text/html'); $r-send_http_header; my $template = TEMPLATE_DIR.'Error.html'; my $t = HTML::Template-new(filename = $template, die_on_bad_params = 0, cache = 1); $t-param('err', $err); $r-print($t-output); return OK; } 1; hth! ken