Thoughts on Mason?

2002-10-24 Thread Shannon Appelcline
I see there's a new book coming out from O'Reilly on mason, which seems 
to be perl integrated into web pages and claims to support mod_perl.

http://www.masonbook.com/

Any thoughts on mason from this esteemed community?

Shannon



CGI Forms Problems (Getting Old Params)

2002-09-28 Thread Shannon Appelcline

Yesterday I ported a few thousand lines of code I'd been working on 
over to Perl. It was quite a bit of work getting all of the strict 
stuff correct and then fighting with the modules-do-not-reload 
problem, but it's now mostly dealt with, and my code's much cleaner 
and more modularized. (Huzzah.)

Unfortunately I've been continuing to have one program that I can't 
figure out. Somehow, my information being submitted through forms 
sometimes reverts to old data after I've clicked Submit and before 
it's processed.

Now, I've read through much of the mod_perl documents, FAQs, etc., 
and I understand the general shape of *why* this happens. It's the 
result of mod_perl keeping the perl modules, and thus the variables, 
in memory. When I hit a server that's already been loaded, I get 
incorrect results. What I don't understand is *how* it's happening in 
this specific case, because I'm being very careful about clearly 
setting my variables each time through.

There must be some aspect of how mod_perl works that I'm missing. I'm 
hoping someone here can (1) tell me what I'm doing wrong in this 
specific case and (2) tell me where my mental map is incorrect.

Anyway, here we go.

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;
--

 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.

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 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;
}
--

Help?

Shannon


-- 
Shannon
--
You met me at a very strange time in my life. --_Fight Club_