Form Reading
Hello This is off topic, thanks for a direct hint to a module or an appropriate mailing list. I want to read an HTML form into an hash. But I don't want to use HTML::Tree or similar DOM Object trees. I need simply all form relevant information as an hash which is human readable. Example: my $formfields = { printorder = ['Name','Request','Newsletter','Message'], Name = { tag = 'input', attr = { value = bbb, type = text, style = width:200, class = singleinput, size = 30 } }, Request = { tag = 'select', options = [ { value = casea, selected = 1, label = xxx },{ value = caseb, label = yyy },{ value = casec, label = zzz } ], attr = { style = width:200, multiple = multiple, class = singleinput, size = 2 } }, Newsletter = { label = Newsletter, tag = 'input', attr = { value = , type = checkbox, style = width:22, class = singleinput, size = 30 } }, Message = { label = Nachricht, tag = 'textarea', attr = { value = sdgdsfgdsfg, style = width:200, class = singleinput, rows = 5, cols = 28 } } }; I've tried HTML::Form but I found a leek of support to attributes as 'class' or 'onClick'. On the print side i can not access each input reference in a loop. Best Regards Christian
Beginner's FixupHandler question
Hello everyone I've just started learning modperl and I started with a simple module for apache httpd 1.3.22. This simple module (see below) sets gets a cookie at every request. I thought it wasn't too difficult. I put it into the fixup phase (any problem with it?). First it seemed to work, but when I put a 'print STDERR' line in it, I saw that my script ran many times on one request. Thanks in advance czinkos ps: I've searched the archives but I didn't find anything. Here's my config in httpd.conf ... PerlFreshRestart On PerlModule SetMyCookies PerlFixupHandler SetMyCookies ... --- Here's my simple script: package SetMyCookies; use Apache; use Apache::Constants; use Apache::Cookie(); sub handler { my $r = shift; $c = $r-header_in(Cookie); local(@rawCookies) = split (/; /,$c); local(%cookies); foreach(@rawCookies){ ($key, $val) = split (/=/,$_); $cookies{$key} = $val; } foreach $name (keys %cookies) { print STDERR $name = $cookies{$name}\n; } my $cookie = Apache::Cookie-new($r, -name = 'lofos', -value = 'lofos13', -expires= '+24M', -path = '/' ); $r-header_out(Set-Cookie,$cookie-as_string); return OK; } 1; --- And here's the error_log on one request: kakukk = kukka234534 kakukk = kukka234534 kakukk = kukka234534 kakukk = kukka234534 kakukk = kukka234534 kakukk = kukka234534 kakukk = kukka234534 kakukk = kukka234534 kakukk = kukka234534 kakukk = kukka234534 kakukk = kukka234534 kakukk = kukka234534 kakukk = kukka234534 kakukk = kukka234534 kakukk = kukka234534 kakukk = kukka234534 kakukk = kukka234534 kakukk = kukka234534 kakukk = kukka234534 kakukk = kukka234534 kakukk = kukka234534 kakukk = kukka234534 kakukk = kukka234534 kakukk = kukka234534 kakukk = kukka234534 kakukk = kukka234534 kakukk = kukka234534 kakukk = kukka234534 kakukk = kukka234534 kakukk = kukka234534 kakukk = kukka234534 kakukk = kukka234534
Re: problems with Apache::AuthTicket
Tomasz Konefal wrote: PerlSetVar FtpFuTicketSecretTable ticketsecrets:sec_version:sec_data PerlSetVar FtpFuTicketExpires 15 PerlSetVar FtpFuTicketLogoutURI /authorized/ftpfu.cgi PerlSetVar FtpFuTicketLoginHandler /ftpfulogin PerlSetVar FtpFuTicketIdleTimeout 1 PerlSetVar FtpFuPath / PerlSetVar FtpFuDomain .compt.com PerlSetVar FtpFuSecure 1 PerlSetVar FtpFuLoginScript /ftpfuloginform A few things that might cause this: 1) Did you remember to create a secret key in table ticketsecrets? 2) Are you accessing the forms using HTTPS (NOT HTTP)? You need to use HTTPS if ${AuthName}Secure is true (which it is above). 3) Make sure FtpFuDomain matches the hostname you are accessing. Everything else looks fine as far as I can tell. Mike
[OT] Re: Form Reading
At 12:55 PM 1/8/2002 +0100, C.Hauser - IT assistance GmbH wrote: Hello This is off topic, thanks for a direct hint to a module or an appropriate mailing list. I want to read an HTML form into an hash. But I don't want to use HTML::Tree or similar DOM Object trees. I need simply all form relevant information as an hash which is human readable. Example: [... example deleted ...] There's a thread that looks like the same as what you're asking going on currently on the Template Toolkit mailing list under the subject [Templates] Sticky forms with hierarchical template vars. A list of submissions is available (by subject) at: http://www.template-toolkit.org/pipermail/templates/2002-January/subject.html a few of these posts have sample code that transforms the result of a form post back into a hierarchical data structure that looks similar to your example. Matthew Pressly
Re: mod-perl, modules and initializations
What is the difference between how a BEGIN block and an anonymous block in a module loaded into mod_perl? It looks to me like you are confused about our and BEGIN. If you change the our to a use vars I think it will fix your problems. This is not mod_perl-specific. Are anonymous blocks in a module only read and executed when mod-perl first loads them, ie once? The block in your example is not inside of a subroutine, so it will only be called once when the module is loaded. Another problem is when I try to build a SELECT HTML element with a call to the CGI module. In my anonymous block all of a sudden the HTML form variables are no longer available with the CGI::param call. Yet I can build the select element later in the cgi scripts using the same variables without a problem. I'm guessing it's more scoping problems with our. In a simpler line, should I have a use DBI() in startup.pl as well as the PerlModule Apache::DBI in httpd.conf? You need to use both Apache::DBI and DBI somewhere. Either place is fine. I usually pull in lots of modules, so it's easier to do in startup.pl. - Perrin
Re: Form Reading
Hello This is off topic, thanks for a direct hint to a module or an appropriate mailing list. I want to read an HTML form into an hash. But I don't want to use HTML::Tree or similar DOM Object trees. I need simply all form relevant information as an hash which is human readable. Example: Write your own like me ;-) #!/usr/bin/perl use strict; use Data::Dumper; my $htmlsource = ''; while(STDIN) { $htmlsource .= $_; } my $formfields = {}; my @tags = split(/[\\]/,$htmlsource); my $i = 0; for ($i = 0;$i @tags; $i++) { my $tag = $tags[$i]; if($tag =~ /^(input|select|option|textarea)\b/i) { my $type = lc($1); if($type eq input) { my $attr = parse($tag); push(@{$formfields-{'printorder'}},($attr-{'name'} || '')); $formfields-{$attr-{'name'}} = { 'tag' = $type, 'attr' = $attr, 'orig' = $tag }; } elsif($type eq select) { my $attr = parse($tag); push(@{$formfields-{'printorder'}},($attr-{'name'} || '')); my $rec = { 'tag' = $type, 'attr' = $attr, 'orig' = $tag, 'options' = [], }; while($tags[$i] !~ /^\/select/i) { my $opt = $tags[$i]; if($opt =~ /^option/i) { my $tmp = parse($opt); $tmp-{'label'} = $tags[$i+1]; push(@{$rec-{'options'}},$tmp); $i++; } $i++; } $formfields-{$attr-{'name'}} = $rec; } elsif($type eq textarea) { my $attr = parse($tag); push(@{$formfields-{'printorder'}},($attr-{'name'} || '')); my $rec = { 'tag' = $type, 'attr' = $attr, 'orig' = $tag, 'options' = [], }; my $val = ''; while($tags[$i] !~ /^\/textarea/i) { $val .= $tags[$i]; $i++; } $rec-{'value'} = $val; $formfields-{$attr-{'name'}} = $rec; } } } print Dumper($formfields); sub parse { my $tag = shift; $tag =~ s/^\w+//; $tag =~ s/^\s+//; return {} unless $tag; my $attr = {}; my $inquote = 0; my $pair = ''; for my $char (split(//,$tag)) { if($char eq '') { $inquote = $inquote ? 0 : 1; next; } if($char =~ /\s/ !$inquote) { if($pair) { my ($k,$v) = split(/\=/,$pair); $v ||= 1 if($k =~ /selected|checked/i); $attr-{lc($k)} = $v; } $pair = ''; next; } $pair .= $char; } if($pair) { my ($k,$v) = split(/\=/,$pair); $v ||= 1 if($k =~ /selected|checked/i); $attr-{$k} = $v; } return $attr; } Call it script.pl. $ perl script.pl html_page_to_parse.html Note that it doesn't differentiate between multiple forms on a single page. I'll leave that as an exercise to the reader. Enjoy, Rob p.s. This hasn't been fully tested. -- When I used a Mac, they laughed because I had no command prompt. When I used Linux, they laughed because I had no GUI.
Re: Beginner's FixupHandler question
I've just started learning modperl and I started with a simple module for apache httpd 1.3.22. This simple module (see below) sets gets a cookie at every request. I thought it wasn't too difficult. I put it into the fixup phase (any problem with it?). First it seemed to work, but when I put a 'print STDERR' line in it, I saw that my script ran many times on one request. What is your interpretation of 'one' request? Remember, when requesting a url there may be 'many' requests that go along with it for loading images and other media. If you don't want to set/get cookie for every request try filtering based on $r-content_type. But, your handler will still be called for every request : ) -- There is always somebody better than you . . . -- Until you realize this you can never be the best. Stathy G. Touloumis Coder
Re: Beginner's FixupHandler question
On Tue, Jan 08, 2002 at 10:07:18AM -0600, Stathy G. Touloumis wrote: I've just started learning modperl and I started with a simple module for apache httpd 1.3.22. This simple module (see below) sets gets a cookie at every request. I thought it wasn't too difficult. I put it into the fixup phase (any problem with it?). First it seemed to work, but when I put a 'print STDERR' line in it, I saw that my script ran many times on one request. What is your interpretation of 'one' request? Remember, when requesting a url there may be 'many' requests that go along with it for loading images and other media. If you don't want to set/get cookie for every request try filtering based on $r-content_type. But, your handler will still be called for every request : ) Apache provides configuration tools that can help. PerlFixupHandlers can be placed within a Location or LocationMatch container. For example: LocationMatch ^/myapp/.*html$ will insure that your fixup handler is only called on requests that start with /myaap/ and end with .html. -- Paul Lindner[EMAIL PROTECTED] | | | | | | | | | | mod_perl Developer's Cookbook http://www.modperlcookbook.org Human Rights Declaration http://www.unhchr.ch/udhr/index.htm
Re: Beginner's FixupHandler question
My One request is: [czinkos@vajradhara apache]$ telnet localhost 8080 Trying 127.0.0.1... Connected to localhost. Escape character is '^]'. GET / HTTP/1.0 Cookie: pritty=prutty It is only 1 html source. Thanks czinkos On Tue, Jan 08, 2002 at 10:07:18AM -0600, Stathy G. Touloumis wrote: I've just started learning modperl and I started with a simple module for apache httpd 1.3.22. This simple module (see below) sets gets a cookie at every request. I thought it wasn't too difficult. I put it into the fixup phase (any problem with it?). First it seemed to work, but when I put a 'print STDERR' line in it, I saw that my script ran many times on one request. What is your interpretation of 'one' request? Remember, when requesting a url there may be 'many' requests that go along with it for loading images and other media. If you don't want to set/get cookie for every request try filtering based on $r-content_type. But, your handler will still be called for every request : ) -- There is always somebody better than you . . . -- Until you realize this you can never be the best. Stathy G. Touloumis Coder
Re: Beginner's FixupHandler question
At 2:40 PM +0100 1/8/02, Zsolt Czinkos wrote: --- Here's my simple script: package SetMyCookies; use Apache; use Apache::Constants; use Apache::Cookie(); Very important to use strict when writing anything in mod_perl. sub handler { my $r = shift; $c = $r-header_in(Cookie); $c is going to persist across multiple connections without my(). local(@rawCookies) = split (/; /,$c); local(%cookies); Use my()... my() is more appropriate in this case. Always reset %cookies = (); # just in case foreach(@rawCookies){ ($key, $val) = split (/=/,$_); $cookies{$key} = $val; } be sure to my() $key and $val foreach $name (keys %cookies) { print STDERR $name = $cookies{$name}\n; } My() $name. my $cookie = Apache::Cookie-new($r, -name = 'lofos', -value = 'lofos13', -expires= '+24M', -path = '/' ); $r-header_out(Set-Cookie,$cookie-as_string); return OK; } 1; --- And here's the error_log on one request: More importantly, check your access log. Something like a nimda in association with the above code might produce multiple lines in your error log like this. kakukk = kukka234534 kakukk = kukka234534 kakukk = kukka234534 kakukk = kukka234534 Good luck, Rob -- When I used a Mac, they laughed because I had no command prompt. When I used Linux, they laughed because I had no GUI.
mod_accel English documentation
Danil Pismenny had begun to translate into English mod_accel documentation: http://dapi.chaz.ru/articles/mod_accel.xml?lang=en Please send him ([EMAIL PROTECTED]) corrections. If you don't understand some translation at all ask me. Igor Sysoev
Apache::RPC::Server questions
Ciao! Looking at RPC::XMl::Server and subsequently the Apache::RPC::Server subclass I see that methods are implemented via passing a code ref to a named or anonymous subroutine that implements the actual method logic. Given the persistent nature of perl in an Apache/modperl environment, is there any inherient problems this might cause in a complex method, other than those caused via bad modperl coding practices? The first thing I thought about is the dangers of closures and the potential for persistent variables and data between requests. Will the avoidance of using any type of globally scoped variables within this method defining subroutine be enough to avoid these types of problems? Does this method defining subroutine ever go out of scope during the life of a modperl process, therefore freeing lexicals and other local data and data structures? Do I need to do any explicite destruction of objects prior to exiting the subroutine, for example? I may need to make database accesses from within the method. Will Apache::DBI still work within this framework? The documentation indicates it is dangerous to change package namespace within the method defining subroutine. Does this apply to the 'use' or 'require' of modules within the subroutine as well? Frankly, I'm so used to writing the actual handler subroutine and supporting modules that I'm feeling a little out of my element given the method definition paradigm the RPC::XML::Server is introducing. Thanks for any information you might be able to provide on this matter. Peace.
Re: take23 and what we're doing - TERMIUMplus
TERMIUMplus --- TERMIUMplus (www.termium.com) is a trilingual application that allows translators and terminologists to search a collection of 1.5 million entries in English, French and Spansih. The system is freely available to any employee of the Canadian Federal government as well as by subscription to individuals and organizations outside. The terms and the user interface are both trilingual. mod_perl plays an integral role in the success of this system. Because the server experiences significant amounts of traffic during the middle of the day effecient request handling is of paramount concern. It is not uncommon to be servicing over 100 concurrent requests at 2pm. Not only does the system perform very well but it is also very stable. I don't think our httpd's have ever crashed - and almost all requests are in the sub-second response range. If great performance and stability were not enough - mod_perl (Perl) - has allowed us to provide a very easy to use and enjoyable interface to our database servers. The servers are actually on NT running a proprietary database software package. The database software is very good at performing both full text and exact term searches of the term data. However, the software interface to the databse engines is weak and unusable at best. By using Perl to talk to the database server's HTTP interface we were able to extract the desired results data and then use Perl's power to reformat the results into something pleasing and tailored to the user's preferences. Because each record has over 100 fields and each field can have a number of sub components - I don't think the job would be doable in any other language than Perl! In addition to reformatting the output of the database we also employ some processing of search terms. This processing is unique to our data collection but helps increase recall by eliminating stopwords such as a, an, le, les, etc. In addition to the fancy user interface TERMIUMplus also offers a server-to-server term translation service. This allows other search engines to offer on-the-fly term translation as part of their service. An excellent feature when dealing with a bi or tri-lingual document corpus. You are welcome to see this yourself by visiting: http://strategis.ic.gc.ca/engdoc/search.html Check on Bilingual search and try a word such as turbofan. As a note, I am not aware of what software the Strategis search system was built with. The entire system runs on a dual processor Sun 250 with 2G of RAM (We discovered how important lots of RAM is for this level of concurrent user activity) for the front end of the request processing. For the database queries we have 2 quad Xeon NT boxes which we divide between Extranet and Internet traffic. We will be replacing the Sun 250 with a quad processor Sun 450 with 8G of RAM. In addition to mod_perl we use MySQL as our user sessions database and intend to start replacing many functions of our proprietary back end database with functions developed using mod_perl and MySQL. Linux is our front-line development system and CVS is our versioning management system. We use CVS to then move our work on to a Sun staging system for pre-release testing and then finally rsync to push final code on to production servers. All of our code runs as well on Linux as it does on Solaris - with no modifications other than compile time options for the major packages of the application. I feel that using mod_perl to build TERMIUMplus has allowed for the construction of a high quality service which is capable of handling a significant user load. It is very rare (never?) that we experienced any major problems with the Apache, mod_perl, and Perl portion of our system. Most of our operational difficulties are coming from our vendor supplied software at the database backend where daily server problems are experienced. Software costs aside I wouldn't build this appliation using anything but mod_perl, Apache and MySQL! Jay Lawrence
Problem with exception handler in guide?
I am trying to get the exception class described in the guide to work, but am having trouble with die returning the class incorrectly. The example in the guide was: die My::Exception-RetCode(code = 204); The module code is at: http://thingy.kcilink.com/modperlguide/perl/The_My_Exception_class_in_its_e.html with two modifications (the last die in sub AUTOLOAD was changed to CORE::die to prevent a perl warning message about it being ambiguous, and the missing semicolon at the end of the first line package ... was added). The following script code does not work #- use My::Exception; eval { die My::Exception-Return(code = abc); }; if ($@) { use Data::Dumper; print Dumper($@); } #- It generates the output: #- $VAR1 = bless( { 'text' = 'My::Exception', 'caller' = { 'line' = 19, 'filename' = 'My/Exception.pm', 'package' = 'My::Exception' } }, 'My::Exception::UnCaught' ); #- with the class indicating that the exception was not caught. Tracing it in the debugger shows that it executes My::Exception::die using My::Exception as the first argument. If I put parens around the argument to die, as follows, it works (calls AUTOLOAD first then returns result of that as first argument to My::Exception::die), returning the correctly classed object. Code: #- use My::Exception; eval { die (My::Exception-Return(code = abc)); }; if ($@) { use Data::Dumper; print Dumper($@); } #- Output: #- $VAR1 = bless( { 'caller' = { 'line' = 5, 'filename' = './exceptions2', 'package' = 'main' }, 'code' = 'abc' }, 'My::Exception::Return' ); #- It appears that - is too low a precedence. Is there a way around this without requiring that parentheses be used around die's arguments? I'm running this under perl5.6.0. Here is output of perl -V: Summary of my perl5 (revision 5.0 version 6 subversion 0) configuration: Platform: osname=linux, osvers=2.4.0, archname=i586-linux uname='linux manson 2.4.0 #1 wed aug 2 20:22:26 gmt 2000 i686 unknown ' config_args='-ds -e -Dprefix=/usr -Di_db -Di_dbm -Di_ndbm -Di_gdbm' hint=recommended, useposix=true, d_sigaction=define usethreads=undef use5005threads=undef useithreads=undef usemultiplicity=undef useperlio=undef d_sfio=undef uselargefiles=define use64bitint=undef use64bitall=undef uselongdouble=undef usesocks=undef Compiler: cc='cc', optimize='-O2 -pipe', gccversion=2.95.2 19991024 (release) cppflags='-fno-strict-aliasing -I/usr/local/include' ccflags ='-fno-strict-aliasing -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64' stdchar='char', d_stdstdio=define, usevfork=false intsize=4, longsize=4, ptrsize=4, doublesize=8 d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12 ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8 alignbytes=4, usemymalloc=n, prototype=define Linker and Libraries: ld='cc', ldflags =' -L/usr/local/lib' libpth=/usr/local/lib /lib /usr/lib libs=-lnsl -ldl -lm -lc -lcrypt libc=, so=so, useshrplib=false, libperl=libperl.a Dynamic Linking: dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-rdynamic' cccdlflags='-fpic', lddlflags='-shared -L/usr/local/lib' Characteristics of this binary (from libperl): Compile-time options: USE_LARGE_FILES Built under linux Compiled at Jan 19 2001 05:42:10 %ENV: PERL5LIB=/home/mpressly/development/library @INC: /home/mpressly/development/library /usr/lib/perl5/5.6.0/i586-linux /usr/lib/perl5/5.6.0 /usr/lib/perl5/site_perl/5.6.0/i586-linux /usr/lib/perl5/site_perl/5.6.0 /usr/lib/perl5/site_perl . Matthew Pressly
Re: take23 and what we're doing - EDDS
EDDS There are few things more sure in life than death and taxes. Ok, well I can think of one more - tax forms! The Canada Customs and Revenue Agency (CCRA - our Federal tax collection agency - like the infamous IRS) has a collection of approximate 10,000 forms, guides and other publications that require management and control. For the past 6 or 7 years these forms were managed using a proprietary database software that was costly to maintain and difficult to extend. As well the system was housed on aging SPARC processors. In order to meet on going and changing business requirements the system would need to be upgraded or replaced. It turns out that by using mod_perl, Linux and MySQL plus some contracting time the entire system was replaced for the cost of 1 years operation costs. A customized document management system was created to meet the unique business requirements of the forms management group at CCRA. This includes document versioning and multiple document formats for each document name. The filing and classification methods are continuously evolving and so the addition and decomission of some metadata fields is necessary. New documents are created by either starting a new version of an existing form or document or creating a new document header record. Then each document format, PDF, MS Word, Form Flow, etc., is uploaded using the file upload feature and the libapreq module to decode the uploaded files. Since security is a concern - we cannot place access to this document collection on the internet. Instead we must report out files and then use rsync to move our data to a staging server. By using Perl we have been able to change from a weekly reporting cycle to a daily reporting cycle. As well, by using Perl we have been able to fix some really nasty decisions that were made 6 or 7 years ago when publishing to the web was an unknown process to most. Finally, by dumping the old software CCRA and its clients were able to chuck out all those modems and go via the web. Perl is practical for extracting and reporting - the turnaround time and cost effectiveness of this project is a testimony to that claim! Jay Lawrence
RE: [ANNOUNCE] Apache::UploadMeter-0.15
So if I have two different html forms that perform uploads, can I define two different forms in the httpd.conf file? -Original Message-From: Issac Goldstand [mailto:[EMAIL PROTECTED]]Sent: Monday, January 07, 2002 10:08 PMTo: [EMAIL PROTECTED]Subject: [ANNOUNCE] Apache::UploadMeter-0.15 Finally, after a month of being bogged down on [EMAIL PROTECTED], the barriers have being cleared and Apache::UploadMeter's hit CPAN! The URL http://telia.dl.sourceforge.net/apache-umeter/Apache-UploadMeter-0.15.tar.gzhas entered CPAN as file: $CPAN/authors/id/I/IS/ISAAC/Apache-UploadMeter-0.15.tar.gz size: 5781 bytes md5: 635457cab775fa4c169d74180b9219f6No action is required on your partRequest entered by: ISAAC (Isaac Goldstand)Request entered on: Tue, 08 Jan 2002 06:04:40 GMTRequest completed: Tue, 08 Jan 2002 06:05:08 GMT Issac
Re: [ANNOUNCE] Apache::UploadMeter-0.15
Eventually, yes, but unfortunately not yet. Until the configuration for _one_ meter isn't 100% stable, I'm not going to set up multiple meters. But it is the first thing on the ToDo list after it becomes stable. Issac eCap wrote: So if I have two different html forms that perform uploads, can I define two different forms in the httpd.conf file? -Original Message- *From:* Issac Goldstand [mailto:[EMAIL PROTECTED]] *Sent:* Monday, January 07, 2002 10:08 PM *To:* [EMAIL PROTECTED] *Subject:* [ANNOUNCE] Apache::UploadMeter-0.15
Re: FixupHandler called twice
On Wed, Jan 09, 2002 at 01:42:58AM +0100, Zsolt Czinkos wrote: Hi My question again (a bit refined): When I request an URI without a filename (e.g: http://localhost:8080/), my perl fixup handler is called three times. Why? How can I avoid this? Can I? http://localhost:8080/index.html works fine. Put a warn DEBUG:, $r-current_callback(), , $r-the_request(), , $r-filename(); in your fixuphandler and see what's geting requested. I bet that first time it'll be you DocumentRoot than DocumentRoot/index.html... -B
Re: [ANNOUNCE] Apache::AppCluster 0.2
Apache::AppCluster is now in CPAN and can be accessed at: http://search.cpan.org/search?dist=Apache-AppCluster This consists of a client and server module that can be used to develop mod_perl clustered web services. A client application can make multiple simultaneous API calls to a mod_perl server (or multiple servers) passing and receiving any perl reference or object as parameters. The server module runs the called module::method in an eval loop and handles errors gracefully while taking advantage of the persistence offered by mod_perl. The client has a bunch of useful methods and includes a timeout for the total time allowed for all remote calls to complete. Let me know if you have any suggestions or find this useful. (or find any bugs) ~mark *snip* The uploaded file Apache-AppCluster-0.02.tar.gz has entered CPAN as file: $CPAN/authors/id/M/MA/MAUNDER/Apache-AppCluster-0.02.tar.gz size: 23995 bytes md5: 0abff0a4a2aa053c9f8ae3c00dd86434 No action is required on your part Request entered by: MAUNDER (Mark D. Maunder) Request entered on: Sun, 06 Jan 2002 16:31:57 GMT Request completed: Sun, 06 Jan 2002 16:33:33 GMT
Re: mod-perl, modules and initializations
By load stage I mean BEGIN blocks, anonymous subroutines in packages loaded at startup, or even named subroutines called from startup.pl All of those things happen during server startup, before any request has been submitted. There is no form data at that time. Maybe if you could explain what you're trying to accomplish by calling CGI methods during initialization, someone could suggest an alternative way to do it. - Perrin
Re: mod-perl, modules and initializations
I'm trying to populate select boxes(or other input types)for my HTML pages. An example would be a drop down list of states and/or provinces. A large number of these are populated from lookup tables in the dba and are relatively static. I understand there is no form data at that time, however, when the server is up and running (and I am accessing it as a client) is when I am having the problem of extracting the data. Hope this is clearer Dave Perrin Harkins wrote: By load stage I mean BEGIN blocks, anonymous subroutines in packages loaded at startup, or even named subroutines called from startup.pl All of those things happen during server startup, before any request has been submitted. There is no form data at that time. Maybe if you could explain what you're trying to accomplish by calling CGI methods during initialization, someone could suggest an alternative way to do it. - Perrin -- Dave Morgan [EMAIL PROTECTED] 403 399 2442
Sample Code for CGI initialization problem
Hi All, I have attached sample code that illustrates the problem Load COMMON.pm on startup, put html and cgi in proper places, configure to run the cgi as an Apache::Registry script. In a browser, load index html, fill out the fields and submit. Your input will not be echoed back Stop apache, remove the BEGIN block from COMMON.pm, restart, test. Input is now echoed back. HTH Dave ### package COMMON; require Exporter; use strict; use CGI qw/:standard/; our (@ISA, @EXPORT); our ($USERID, $PASSWORD, $select_list); @ISA= qw(Exporter); @EXPORT = qw($USERID $PASSWORD $select_list); BEGIN{ $select_list = scrolling_list(-name='TEST', -values=[1,2,3,4], -default='1', -size= 1); } 1; # END #login.cgi #!/opt/bin/perl -T use strict; use CGI qw/:standard :cgi-lib/; use COMMON; # Get Form Values $USERID = param(USERID); $PASSWORD = param(PASSWORD); print header; print $USERID, $PASSWORD; #END ### #index.html html BODY BGCOLOR=white form action=/cgi-bin/login.cgi method=POST table BORDER=0 cellspacing=0 cellpadding=0 width=250 trtd colspan=2 font size=2 FACE=helvetica,arial Login Name: /tdtd input type=text name=USERID size=20 maxlength=20 /td/tr trtd colspan=2 font size=2 FACE=helvetica,arial Password /tdtd input type=password name=PASSWORD size=20 maxlength=20 /td/tr trtd colspan=4 -- /td/tr trtd input type=submit value=Log in /td td colspan=2 font size=2 FACE=helvetica,arial Test /td/tr/table /form /body /html #END -- Dave Morgan [EMAIL PROTECTED] 403 399 2442
Re: mod-perl, modules and initializations
On Tuesday 08 January 2002 08:16 pm, Dave Morgan wrote: I'm trying to populate select boxes(or other input types)for my HTML pages. An example would be a drop down list of states and/or provinces. A large number of these are populated from lookup tables in the dba and are relatively static. Okay, I suspect the problem is that whenever you get a new request the setup you did for CGI.pm gets cleared. You should store the static data in a global, and then populate the CGI widget with it on every request. - Perrin
Ip Address On Outbound
Hello, I havea question on outbound ips. I am writing a program that a user can enter an address and a spider will go and retrieve only the information that was request and then display the results to the enquiring user. My question is though, i have grabed the users ip address as the initiator of the request and i would like to use that ip address (The users) to send the http request instead of my systems addres. How would i changed outgoing requests to reflect the invoking users ip and not my systems ip? Thanks in advance, John
Re: Ip Address On Outbound
On Wed, Jan 09, 2002 at 12:27:12AM -0500, John Buwa wrote: How would i changed outgoing requests to reflect the invoking users ip and not my systems ip? You can't just change the ip you use to connect to other systems... But you may have some luck in using the Via: and X-Forwarded-For: headers: GET / HTTP/1.0 Via: 1.0 agent.mydmn.net:3128 (Yet Another Agent/0.0.1.0a) X-Forwarded-For: 192.168.0.1 Regards, Luciano Rocha -- Luciano Rocha, [EMAIL PROTECTED] The trouble with computers is that they do what you tell them, not what you want. -- D. Cohen
[error] Cannot remove module mod_perl.c: not found in module list
Hello all, I get the message shown as [error] Cannot remove module mod_perl.c: not found in module list when i restart apache after installing mod_perl and adding LoadModule perl_module modules/mod_perl.so in the httpd.conf . my os: windows 2k All my steps: 1. Download apache_1.3.22-win32-x86.msi from http://www.apache.org/dist/httpd/binaries/win32/ and setup it to c:\apache\. 2. Download ActivePerl-5.6.1.631-MSWin32-x86.msi from http://www.activestate.com/Products/Download/Download.plex?id=ActivePerl and setup it to c:\perl\. 3. run: c:\ppm ppmset repository theoryx5 http://theoryx5.uwinnipeg.ca/cgi-bin/ppmserver?urn:/PPMServer ppminstall mod_perl ppmquit 4. add LoadModule perl_module modules/mod_perl.so in the httpd.conf. 5. start apache and the screen display: The Apache service is starting. Failed to start the Apache service. [Wed Jan 09 15:55:01 2002] [error] Cannot remove module mod_perl.c: not found in module list Note the erors or messages above I am not familiar with perl and apache. I come to mod_perl in order to use asp on apache server. Thank you! Best Regards, cloudor [EMAIL PROTECTED] 2002-01-09
cvs commit: modperl-2.0/src/modules/perl modperl_io.c
dougm 02/01/08 11:04:22 Modified:src/modules/perl modperl_io.c Log: plug leaking tied STD{IN,OUT} objects Revision ChangesPath 1.6 +2 -0 modperl-2.0/src/modules/perl/modperl_io.c Index: modperl_io.c === RCS file: /home/cvs/modperl-2.0/src/modules/perl/modperl_io.c,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- modperl_io.c 6 Jan 2002 21:56:22 - 1.5 +++ modperl_io.c 8 Jan 2002 19:04:22 - 1.6 @@ -42,6 +42,8 @@ sv_magic((SV*)handle, obj, 'q', Nullch, 0); sv_magic((SV*)GvIOp(handle), obj, 'q', Nullch, 0); +SvREFCNT_dec(obj); /* since sv_magic did SvREFCNT_inc */ + MP_TRACE_g(MP_FUNC, tie *%s(0x%lx) = %s, REFCNT=%d\n, GvNAME(handle), (unsigned long)handle, classname, SvREFCNT((SV*)handle));
cvs commit: modperl-2.0/t/response/TestModperl print.pm
dougm 02/01/08 14:46:09 Modified:t/conf modperl_extra.pl t/response/TestModperl print.pm Log: add some END blocks for testing Revision ChangesPath 1.12 +4 -0 modperl-2.0/t/conf/modperl_extra.pl Index: modperl_extra.pl === RCS file: /home/cvs/modperl-2.0/t/conf/modperl_extra.pl,v retrieving revision 1.11 retrieving revision 1.12 diff -u -r1.11 -r1.12 --- modperl_extra.pl 22 Dec 2001 18:59:52 - 1.11 +++ modperl_extra.pl 8 Jan 2002 22:46:08 - 1.12 @@ -53,4 +53,8 @@ return $buf; } +END { +warn END in modperl_extra.pl, pid=$$\n; +} + 1; 1.4 +5 -0 modperl-2.0/t/response/TestModperl/print.pm Index: print.pm === RCS file: /home/cvs/modperl-2.0/t/response/TestModperl/print.pm,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- print.pm 1 Jan 2002 10:36:05 - 1.3 +++ print.pm 8 Jan 2002 22:46:09 - 1.4 @@ -21,4 +21,9 @@ Apache::OK; } +END { +my $package = __PACKAGE__; +warn END in $package, pid=$$\n; +} + 1;
cvs commit: modperl-2.0/xs/maps modperl_functions.map
dougm 02/01/08 14:48:38 Modified:xs/Apache/RequestIO Apache__RequestIO.h xs/maps modperl_functions.map Log: dd UNTIE method to avoid warning from pp_untie: untie attempted while %d inner references still exist which is legit in our case, since we do not create a new object in TIEHANDLE, but rather increment the refcount of and existing one. Revision ChangesPath 1.25 +3 -0 modperl-2.0/xs/Apache/RequestIO/Apache__RequestIO.h Index: Apache__RequestIO.h === RCS file: /home/cvs/modperl-2.0/xs/Apache/RequestIO/Apache__RequestIO.h,v retrieving revision 1.24 retrieving revision 1.25 diff -u -r1.24 -r1.25 --- Apache__RequestIO.h 6 Jan 2002 20:45:36 - 1.24 +++ Apache__RequestIO.h 8 Jan 2002 22:48:38 - 1.25 @@ -6,6 +6,9 @@ #define mpxs_Apache__RequestRec_BINMODE(r) \ r ? PL_sv_yes : PL_sv_no /* noop */ +#define mpxs_Apache__RequestRec_UNTIE(r, refcnt) \ +(r refcnt) ? PL_sv_yes : PL_sv_no /* noop */ + #define mpxs_output_flush(r, rcfg) \ /* if ($|) */ \ if (IoFLUSH(PL_defoutgv)) { \ 1.32 +1 -0 modperl-2.0/xs/maps/modperl_functions.map Index: modperl_functions.map === RCS file: /home/cvs/modperl-2.0/xs/maps/modperl_functions.map,v retrieving revision 1.31 retrieving revision 1.32 diff -u -r1.31 -r1.32 --- modperl_functions.map 20 Dec 2001 18:12:16 - 1.31 +++ modperl_functions.map 8 Jan 2002 22:48:38 - 1.32 @@ -30,6 +30,7 @@ apr_size_t:DEFINE_PRINT | | ... apr_size_t:DEFINE_PRINTF | | ... SV *:DEFINE_BINMODE | | request_rec *:r + SV *:DEFINE_UNTIE| | request_rec *:r, int:refcnt mpxs_Apache__RequestRec_sendfile | | r, filename=r-filename, offset=0, len=0 mpxs_Apache__RequestRec_read | | r, buffer, bufsiz, offset=0 long:DEFINE_READ | | request_rec *:r, SV *:buffer, int:bufsiz, int:offset=0
cvs commit: modperl-2.0/t/response/TestModperl readline.pm getc.pm
dougm 02/01/08 14:49:32 Modified:t/response/TestModperl readline.pm getc.pm Log: untie STDIN Revision ChangesPath 1.3 +2 -0 modperl-2.0/t/response/TestModperl/readline.pm Index: readline.pm === RCS file: /home/cvs/modperl-2.0/t/response/TestModperl/readline.pm,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- readline.pm 5 Dec 2001 05:48:39 - 1.2 +++ readline.pm 8 Jan 2002 22:49:32 - 1.3 @@ -16,6 +16,8 @@ $r-puts($line); } +untie *STDIN; + Apache::OK; } 1.3 +2 -0 modperl-2.0/t/response/TestModperl/getc.pm Index: getc.pm === RCS file: /home/cvs/modperl-2.0/t/response/TestModperl/getc.pm,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- getc.pm 7 Dec 2001 04:47:13 - 1.2 +++ getc.pm 8 Jan 2002 22:49:32 - 1.3 @@ -16,6 +16,8 @@ $r-puts($c); } +untie *STDIN; + Apache::OK; }
cvs commit: modperl-2.0/src/modules/perl mod_perl.c
dougm 02/01/08 16:31:39 Modified:src/modules/perl mod_perl.c Log: rid warning #ifdef USE_ITHREADS Revision ChangesPath 1.104 +1 -1 modperl-2.0/src/modules/perl/mod_perl.c Index: mod_perl.c === RCS file: /home/cvs/modperl-2.0/src/modules/perl/mod_perl.c,v retrieving revision 1.103 retrieving revision 1.104 diff -u -r1.103 -r1.104 --- mod_perl.c8 Jan 2002 01:13:28 - 1.103 +++ mod_perl.c9 Jan 2002 00:31:39 - 1.104 @@ -640,10 +640,10 @@ int modperl_response_handler_cgi(request_rec *r) { MP_dDCFG; -MP_dRCFG; GV *h_stdin, *h_stdout; int retval; #ifdef USE_ITHREADS +MP_dRCFG; pTHX; modperl_interp_t *interp; #endif