Re: Perl Cookbook modperl chapter

2002-12-11 Thread Paul Lindner
Hi,

I only speak for myself, but I am happy to see mod_perl covered in the
Perl Cookbook.  Why you ask?  I see the inclusion of mod_perl helping
increase the size of the mod_perl pie.  A rising tide lifts all
boats.  

I'm not too worried about the content.  I'm sure it will be top-notch.
Consider that the Perl Cookbook already gives you good coverage of
several complex domain specific areas: DBI, LWP, CGI, Sockets, Tk,
etc.

I'll be very happy if the Perl Cookbook gets the novice mod_perl
programmer started and then leads them to the mpDC, which is really an
intermediate to advanced work.

My only concern?  If the Perl Cookbook gets any larger I might throw
out my back carrying it around :)  

-- 
Paul Lindner[EMAIL PROTECTED]   | | | | |  |  |  |   |   |

mod_perl Developer's Cookbook   http://www.modperlcookbook.org/
 Human Rights Declaration   http://www.unhchr.ch/udhr/



Re: lame load balancer, mod_proxy, and sticky sessions

2002-09-06 Thread Paul Lindner

On Fri, Sep 06, 2002 at 08:44:39AM -0400, Calbazana, Al wrote:
 Hello,
 
 I'd like to know if it is possible to use mod_proxy as a sticky session
 manager.  Basically, I'd like to put mod_proxy behind the load balancer and
 allow the proxy servers to talk to the mod_perl servers.  Unfortunately, the
 load balancer does not allow for sticky sessions and only bounces the user
 round-robin style.  I am playing with the idea of sending a cookie down to
 the client and using it to stick a user to a particular mod_perl server, but
 I'd like mod_proxy to figure it out which server and send the user to the
 defined machine.  I'd also like to enable a checking mechanism to
 determine if a mod_perl server is up before the user is sent to the location
 specified in the cookie.  If the machine that the client is stuck to is
 down, I'd like to reroute.
 
 I know high powered load balancers do this already, but I'd like to explore
 dedicating a few medium sized servers to do as there is surplus of these and
 f5's cost $$$.  I apologize in advance if this is a bit off topic!

Two things come to mind.  First mod_rewrite has plenty of features that
will let you do primitive load balancing.  See

  http://httpd.apache.org/docs/misc/rewriteguide.html

Look at the examples that show how to combine a cookie with the URI and
you can use regexes to control which host is chosen.

Also check out mod_backhand (discussed on this list, check the archives)

  http://www.backhand.org/

-- 
Paul Lindner[EMAIL PROTECTED]   | | | | |  |  |  |   |   |

mod_perl Developer's Cookbook   http://www.modperlcookbook.org/
 Human Rights Declaration   http://www.unhchr.ch/udhr/



Re: Apache::Util::ht_time outputs dates in local language

2002-09-06 Thread Paul Lindner

On Fri, Sep 06, 2002 at 05:03:32PM +0200, pascal barbedor wrote:
 
  When I have caching problems, I run my pages through cachability to find
 out
  where they are failing. Check it out at:
 
http://www.web-caching.com/cgi-web-caching/cacheability.py
 
  It reports on page headers as well as gives useful info like the
 following:
 
 
 Hi thanks
 
 this helped me determine why the cache did not work
 is it because the date format of Expires or Last-Modified was not RFC
 correct
 
 I noted on the occasion that Apache::Util::ht_time()
 outputs dates in locale language format (french for me)
 Mar, 12 Sept 2002 18:50:20 GMT
 instead of english ones

This function wraps an apache function (apr_ht_time()) which in
turn uses strftime() to do the conversion.

Try changing your LC_TIME or LANG variable before you start your
web server.  Perhaps start by setting LANG=C and go from there.

Consult the strftime() man page for details on the interaction
between the environment variables and the time output.

Cheers,
Paul

-- 
Paul Lindner[EMAIL PROTECTED]   | | | | |  |  |  |   |   |

mod_perl Developer's Cookbook   http://www.modperlcookbook.org/
 Human Rights Declaration   http://www.unhchr.ch/udhr/



Re: Mail::Sender modperl.

2002-07-23 Thread Paul Lindner

Another chunk of sample code is available in chapter 15 of The
mod_perl Developer's Cookbook.  The Cookbook::Mail module uses
MIME::Lite and Email::Valid to send data/attachments around.

Feel free to adapt it to suit your needs:

http://www.modperlcookbook.org/code/ch15/Cookbook/Mail.pm

Regards

On Mon, Jul 22, 2002 at 10:48:52AM -0700, Goehring, Chuck Mr., RCI - San Diego wrote:
 Richard,
 
 I also use MIME::Lite (on Win2000) with mod_perl.  Found it to be quite reliable and 
it supports attachments and receipts like so:
 
   if($aReceipt ne '') {  # If return receipt requested.
 $msg-add(Disposition-Notification-To= $aApobj-getEmail_Address);  
   }
 
 Chuck
 
 -Original Message-
 From: Richard Clarke [mailto:[EMAIL PROTECTED]]
 Sent: Saturday, July 20, 2002 6:28 AM
 To: [EMAIL PROTECTED]
 Subject: Mail::Sender  modperl.
 
 
 List,
 Have any of you had any problems using Mail::Sender from within 
 mod_perl. My script seems to just sit there waiting for $sender-Open to 
 do anything. I will email the author also but imagined he *might* not be 
 familiar with mod_perl so won't be able to offer any suggestions. 
 Anyone? I looked through the archives but saw no reference to a problem 
 like this. Some people indicated much success with Mail::Sender (not so 
 for me however!).
 
 Second, the recommended solution for sending mails is to instead put 
 them on a queue for an external daemon to handle. My question is, is 
 there a standard implementation people use when doing this. Is the KISS 
 theory invoked and the outoing mail simply written to some plain text 
 spool file or do people use something more involved like writing the 
 to,cc,from,subject,body test to a database and storing any temporary 
 files (attachment) in a directory for later encoding?
 
 Ric
 
 p.s. here is an excerpt from my apache log indicating precisely what happens
 
   220 mail.likewhoa.com ESMTP Postfix
 421 Error: timeout exceeded
  ehlo localhost
  mail from: [EMAIL PROTECTED]
  rcpt to: [EMAIL PROTECTED]
  data
  To: [EMAIL PROTECTED]
  From: [EMAIL PROTECTED]
  X-Mailer: Perl script null
   using Mail::Sender 0.7.14.1 by Jenda Krynicky
   running on localhost (127.0.0.1)
   under account root
  Date: Sat, 20 Jul 2002 13:18:12 -
  Message-ID: [EMAIL PROTECTED]
  Subject:  msg msg msg
 
 close sender
 
  .
  quit
 done
 The request took 305.710375070572 seconds

-- 
Paul Lindner[EMAIL PROTECTED]   | | | | |  |  |  |   |   |

mod_perl Developer's Cookbook   http://www.modperlcookbook.org/
 Human Rights Declaration   http://www.unhchr.ch/udhr/



Re: HTML::Entities chokes on XML::Parser strings

2002-05-07 Thread Paul Lindner

The output from your example looks like UTF-8 data (Atilde; is a
commonly seen UTF-8 escape sequence).  XML::Parser converts all
incoming text into UTF-8.  You will need to convert it back to
iso-8859-1.

My favorite is Text::Iconv

 use Text::Iconv;
 $utf8tolatin1 = Text::Iconv-new(UTF-8, ISO8859-1);

 my $buffer_latin1 = $converter-convert($buffer);


On Tue, May 07, 2002 at 10:51:10AM -0400, John Siracusa wrote:
 I ran into this problem during mod_perl development, and I'm posting it to
 this list hoping that other mod_perl developers have dealt with the same
 thing and have good solutions :)
 
 I've found that strings collected while processing XML using XML::Parser do
 not play nice with the HTML::Entities module.  Here's the sample program
 illustrating the problem:
 
 #!/usr/bin/perl -w
 
 use strict;
 
 use HTML::Entities;
 use XML::Parser;
 
 my $buffer;
 
 my $p = XML::Parser-new(Handlers = { Char  = \xml_char });
 
 my $xml = '?xml version=1.0 encoding=iso-8859-1?test' .
   chr(0xE9) . '/test';
 
 $p-parse($xml);
 
 print encode_entities($buffer), \n;
 
 sub xml_char
 {
   my($expat, $string) = @_;
   
   $buffer .= $string;
 }
 
 The output unfortunately looks like this:
 
 Atilde;copy;
 
 Which makes very little sense, since the correct entity for 0xE9 is:
 
 eacute;
 
 My current work-around is to run the buffer through a (lossy!?) pack/unpack
 cycle:
 
 my $buffer2 = pack(C*, unpack(U*, $buffer));
 print encode_entities($buffer2), \n;
 
 This works and prints:
 
 eacute;
 
 I hope it is not lossy when using iso-8859-1 encoding, but I'm guessing it
 will maul UTF-8 or UTF-16.  This seems like quite an evil hack.
 
 So, what is the Right Thing to do here?  Which module, if any, is at fault?
 Is there some combination of Perl Unicode-related use statements that will
 help me here?  Has anyone else run into this problem?
 
 -John

-- 
Paul Lindner[EMAIL PROTECTED]   | | | | |  |  |  |   |   |

mod_perl Developer's Cookbook   http://www.modperlcookbook.org/
 Human Rights Declaration   http://www.unhchr.ch/udhr/



Re: HTML::Entities chokes on XML::Parser strings

2002-05-07 Thread Paul Lindner

On Tue, May 07, 2002 at 11:13:43AM -0400, John Siracusa wrote:
 On 5/7/02 10:58 AM, Paul Lindner wrote:
  The output from your example looks like UTF-8 data (Atilde; is a
  commonly seen UTF-8 escape sequence).  XML::Parser converts all
  incoming text into UTF-8.  You will need to convert it back to
  iso-8859-1.
  
  My favorite is Text::Iconv
  
 use Text::Iconv;
 $utf8tolatin1 = Text::Iconv-new(UTF-8, ISO8859-1);
  
 my $buffer_latin1 = $converter-convert($buffer);
 
 So HTML::Entities only works with ISO8859-1 (or ASCII, presumably)?  What if
 I have actual UTF-8 data?  Won't conversion to ISO8859-1 in service of
 HTML::Entities result in data loss?

Yes, HTML::Entities is based on ISO8859-1 input only.  BTW, for better
performance in mod_perl consider using Apache::Util::escape_html()


 escape_html
   This routine replaces unsafe characters in $string
   with their entity representation.

my $esc = Apache::Util::escape_html($html);


Anyway, back to character entities..

Text::Iconv will fail if you try to convert unconvertable text, so at
least you can test for that condition (and adjust accordingly)

BasisTech sells a comprehensive unicode library called Rosette that
knows how to automatically convert to a target character set while
incorporating SGML entities for any character set.  Perhaps it's time
for an open implementation of that..

Also see http://rf.net/~james/perli18n.html for a perl i18n faq.




-- 
Paul Lindner[EMAIL PROTECTED]   | | | | |  |  |  |   |   |

mod_perl Developer's Cookbook   http://www.modperlcookbook.org/
 Human Rights Declaration   http://www.unhchr.ch/udhr/



Re: SOAP and web services

2002-05-02 Thread Paul Lindner

On Thu, May 02, 2002 at 01:27:48PM -0500, Joe Breeden wrote:
 Bart,
 
 I would have to recommend SOAD::Lite ( http://www.soaplite.org) also. We use it 
accomplish many tasks - not the least of which is exposing Perl data structures to M$ 
ASP applications - which have a moderate load and have had no problems. 
 


A few more examples can be found in chapter 15 of the mod_perl
cookbook.  The (fairly simple) code in HalfLife-QueryServer is here:

  http://www.modperlcookbook.org/code/ch15/

Another simple way to do RPC over HTTP with mod_perl is RPC::XML.
Both it and SOAP::Lite are testaments to the power and simplicity of
perl+apache..

  -Original Message-
  From: Bart Frackiewicz [mailto:[EMAIL PROTECTED]]
  Sent: Thursday, May 02, 2002 12:34 PM
  To: [EMAIL PROTECTED]
  Subject: SOAP and web services
  
  
  Dear List,
  
  i want to create a server in mod_perl/apache, which receives 
  request via get/post (plain), process this request (with 
  database access and some functions) and answers in xml (with 
  correct header), after planning this about a month i realized 
  that this is called a web service.
  
  the difference between my solution and all articles was SOAP, 
  which i understand as an extension to http, so in my opinion 
  i need something that allows to parse the request and creates 
  the output, is there a solution for mod_perl anyway? and is 
  this solution stable for a production server which more than 
  10.000 request/day?
  
  i hope this is the right place to ask, but in all articles i 
  read there were only examples for java/tomcat, not for perl/mod_perl.
  
  Thanks in advance
  
  Bart Frackiewicz
  
  
  -- 
  BART FRACKIEWICZ
  systementwickler
  inity - agentur fuer neue medien gmbh 
  birkenstrasse 71  
  40233 duesseldorf
  

-- 
Paul Lindner[EMAIL PROTECTED]   | | | | |  |  |  |   |   |

mod_perl Developer's Cookbook   http://www.modperlcookbook.org/
 Human Rights Declaration   http://www.unhchr.ch/udhr/



Re: XML::RPC

2002-04-21 Thread Paul Lindner

On Sat, Apr 20, 2002 at 11:49:24PM -0400, Eric Frazier wrote:
 Hi,
 
 I am finally finding yes, there could be a reason for me to use this, I want
 to avoid SOAP, partly because of the license crap(fear), but also because I
 figure that XMLRPC will be easier to learn at first and likely will fit my
 small needs. But as I look at examples and various tools that support
 working with Perl they often are of a nature of a CGI and a standalone
 client. My needs aren't that small :)  The only Apache modules I have found
 are with the SOAP::Lite module. 
 
 So what do the you people recommend? I have found several, Frontier::RPC,
 there is a SOAP::Lite XML::RPC module, but it depends on SOAP::Lite which I
 find confusing, there is just RPC::XML on CPAN. Most important though, I of
 course want to run the server with mod_perl which is the only reason I
 consider this post to be somewhat on topic, I really want to use mod_perl
 with this and what group would be better to advise me on that :) 
 
 What I want to be able to do is to expose some simple method calls, along
 with some hash data to a Java client. Say like a parser object from
 HTML::Parser. The client will be Java, but I get the idea that shouldn't
 really matter. Sorry if my terminology is off, I am swimming a bit..

I think you'll find RPC::XML to be a solidly engineered module.  I've
used it as a client and as a server to good effect.  It includes
stand-alone, CGI, and mod_perl based servers and a very nice client.

If all you need is simple RPC calls I find that XML-RPC provides a
much more straightforward environment.  Even with my background in
http based rpc systems it took me a while to pick up on the
idiosyncrasies of SOAP.

-- 
Paul Lindner[EMAIL PROTECTED]   | | | | |  |  |  |   |   |

mod_perl Developer's Cookbook   http://www.modperlcookbook.org/
 Human Rights Declaration   http://www.unhchr.ch/udhr/



Re: Apache::DProf seg faulting

2002-04-17 Thread Paul Lindner

On Tue, Apr 16, 2002 at 06:05:11PM -0400, Sam Tregar wrote:
 On Tue, 16 Apr 2002, Sam Tregar wrote:
 
   On 16 Apr 2002, Garth Winter Webb wrote:
  
Sam, try getting rid of the 'PerlModule Apache::DB' line.  I've used
Apache::DProf w/o any problems by including only the one PerlModule
line.  Since they both want to use perl debugging hooks, I'm guessing
that Apache::DProf is getting crashed up when it tries to use hooks
already grabbed by Apache::DB...
  
   Same result.  Thanks though!
 
 Aw nuts, that was the problem!  I thought I'd tried that already, but I
 guess not.  I actually got those PerlModule lines from the mod_perl
 Developers Cookbook - guess this is an errata!

I think that this may be a problem with the use of Perl sections.

I believe your original post had something like this:

Perl
  use Apache::DProf
  use Apache::DB
  Apache::DB-init();
/Perl

Geoffrey and I tested our environments today and the recipe given in
the book seems to work just fine:

  PerlModule Apache::DB
  PerlModule Apache::DProf


-- 
Paul Lindner[EMAIL PROTECTED]   | | | | |  |  |  |   |   |

mod_perl Developer's Cookbook   http://www.modperlcookbook.org/
 Human Rights Declaration   http://www.unhchr.ch/udhr/



Help us make the mod_perl Developer's Cookbook better.

2002-04-09 Thread Paul Lindner

Hi there.

First of all, thanks to all of those who are now using the mod_perl
Developer's Cookbook.  We hope that it's made your development easier
and more fun.  Due to the continued popularity of the book, a 2nd
printing is being planned in the next week or so.  This is nice
because we're allowed to correct minor errors.

We'd appreciate your help in fixing any errors in the text or code.
No-one's perfect (especially us, look at our errata page!), so if
you've noticed anything amiss that's not listed at:

  http://www.modperlcookbook.org/errata.shtml

please send it to

  [EMAIL PROTECTED] 

asap.

Thanks again!

-- 
Paul Lindner[EMAIL PROTECTED]   | | | | |  |  |  |   |   |

mod_perl Developer's Cookbook   http://www.modperlcookbook.org/
 Human Rights Declaration   http://www.unhchr.ch/udhr/



Re: [OT?] What exactly is forwarding?

2002-03-12 Thread Paul Lindner

On Tue, Mar 12, 2002 at 10:01:42AM +0100, Martin Haase-Thomas wrote:
 Hi all,
 
 I know this is not perfectly the right list for my topic, but before 
 subscribing to another for just one question... forgive me if I'm going 
 to be boring. Even more, because my question is rather philosophical.
 
 If you consider JSPs, there is a tag called jsp:forward page=... /. 
 My question is: how do I have to understand 'forward'? The java 
 documentation isn't that verbose, and I can imagine two possible meanings:
 1. Forwarding is some sort of an internal redirect to the servlet engine 
 which the browser will not be informed of.  From this point of view 
 forwarding will be nearly the same as a dynamic include.

*ding* correct!  Basically it says, dump any buffered output and start
a new request.

 2. Forwarding is the same as a redirect.

nope, see above.

 Maybe a superfluous question for some of you, for me it isn't actually. 
 So, if anyone knows an answer - or knows the number of the RFC I'll find 
 the information: you're welcome!

You'll find that $r-internal_redirect() is the mod_perl equivalent.
Also Apache::ASP containts the Transfer() method which accomplishes
the same thing.

-- 
Paul Lindner[EMAIL PROTECTED]   | | | | |  |  |  |   |   |

mod_perl Developer's Cookbook   http://www.modperlcookbook.org/
 Human Rights Declaration   http://www.unhchr.ch/udhr/



Re: BerkeleyDB Problems

2002-03-12 Thread Paul Lindner

On Tue, Mar 12, 2002 at 11:06:00AM -0500, Mark Matthews wrote:
 Hello,
 
 I am moving a website that now resides on a i686 server running RedHat
 6.2 with perl v5.005_03 to another i686 server running Suse 7.1 with
 perl v5.6.1.

 The website uses a number of cgi scripts that read and write from
 BerkeleyDB files using the tie function.
 
 The site is currently running fine on the RedHat server, but when
 testing the scripts on the Suse box I am finding the the scripts are
 failing complaining that the db file cannot be opened.

 The function calling the script is as follows...
 $db = blurb;
 tie(%BLURB, DB_File, $db, O_RDONLY, 0664) || die(Error: could not
 open $db: $!\n);
 
 Things I have tried so far..
 - I have checked that the BerkeleyDB file (blurb) in the right path, and
 is readable/writable.
 - I have checked  that the DB file is not corrupt by ftping it back to
 the RedHat box and testing it.. Works fine..
 - the command file blurb shows that the db file is Berkeley DB (Hash,
 version 5, native byte-order) and my guess is the version of DB_File
 cannot read that DB version.   I have installed earlier versions of
 DB_File on the Suse box with no luck.
 - I have successfully created a new db file using tie. The file created
 is version 7.
 
 Since these scripts do infact work on the RedHat server, what do I need
 to do to get them to work on the Suse server

DB_File is usually implemented on top of whatever the latest Berkeley
DB is available.  The file formats are usually not compatible from
major version to another major version.  I believe RH 6.2 uses bdb v2
and Suse uses a newer version 3 or 3.1.  Use the rpm -q -a command to
find out which versions are which.

Anyway, you need to try out the db_upgrade command, it should upgrade
the db file to the latest format.  It might not be installed by
default, so check your local docs.  (I think it's in db3-utils, or
some such..)

You might also try out the BerkeleyDB module for access to more
interesting features provided by the later versions of this library.
In particular the transactions subsystem is very, very cool.

Good Luck

-- 
Paul Lindner[EMAIL PROTECTED]   | | | | |  |  |  |   |   |

mod_perl Developer's Cookbook   http://www.modperlcookbook.org/
 Human Rights Declaration   http://www.unhchr.ch/udhr/



Re: performance testing - emulating real world use

2002-03-12 Thread Paul Lindner

On Tue, Mar 12, 2002 at 01:52:36PM -0800, clayton cottingham wrote:
 Bryan Henry wrote:
  
  Anyone know of good guides or general info on
  performance testing and emulating real use of
  an application.
  
  I would like to understand how to identify
  potential bottlenecks before I deploy web apps.
  
  thank you,
  ~ b r y a n

I've used HTTPD::Bench::ApacheBench (available on CPAN) to do load
testing.  It seems to do a good job.  The hardest part is writing the
testing script  (especially for form transactions..).  

However, if you can do your requests with LWP it's fairly
straightforward to convert over to the ApacheBench data structures.

I'm considering writing a little mod_perl proxy server that records
the different transactions.  Then I could just munge the separate
Authorization: headers to do some serious load testing...

 
 try httpd.apache.org/test/
 
 and perl framework
 there in
 
 as well look on freshmeat for
 
 siege
 it does testing too

-- 
Paul Lindner[EMAIL PROTECTED]   | | | | |  |  |  |   |   |

mod_perl Developer's Cookbook   http://www.modperlcookbook.org/
 Human Rights Declaration   http://www.unhchr.ch/udhr/



Re: Breaks in mod_perl, works in Perl

2002-03-06 Thread Paul Lindner

On Wed, Mar 06, 2002 at 11:27:28AM -0700, Mark Hazen wrote:
 Mark Hazen wrote:
  I wish this were true, but no one will ever get IO::Scalar to catch DBI's
  STDERR output.
 
 If so, it's only because STDERR under mod_perl is already tied.  DBI is
 not an external process.
 
  Throwing all this stuff into a file is already something DBI
  can do, but as I already said, opening several hundred files per minute
 will
  overwhelm my system.
 
 I don't think it does that.  It should open one file per process that
 has tracing turned on and keep writing to it.  I already suggested that
 you can just turn it on for a single process.  That would mean one file
 being written to by one process, which is very unlikely to overwhelm any
 system.
 
 That's your opinion.  In my opinion, a bunch of disk IO and file seeks are a
 waste of resources.  The bigger issue here is that it is better to store in
 memory, and it saddens me that it doesn't seem possible.

This is a design flaw of DBI then.  You might get more results if you
post on the DBI users list.  We got part of the way there by
redefining the trace_msg function, the only part that remains is
gathering the output of the lower-level DBD calls, that might involve
modifying some XS code, (or it might not)..

Propose a 'callback' interface on dbi-users, you'll probably get a
warm reception.

-- 
Paul Lindner[EMAIL PROTECTED]   | | | | |  |  |  |   |   |

mod_perl Developer's Cookbook   http://www.modperlcookbook.org/
 Human Rights Declaration   http://www.unhchr.ch/udhr/index.htm



Re: Breaks in mod_perl, works in Perl

2002-03-05 Thread Paul Lindner
;
*croak = \Carp::croak;
goto croak;
 }
 
 1;
 __END__
 perl -MIO::Capture
$x = IO::Capture-new(\*STDERR);
print now capturing\n;
warn qq[captured ok\n];
print captured text 'captured ok' shouldn't have appeard\n;
$y = $x-capture;
print capture didn't block\n;
print $y;
warn Restored ok\n;
 __END__
 now capturing
 captured text 'captured ok' shouldn't have appeard
 capture didn't block
 captured ok
 Restored ok
 
 perl -MIO::Capture
$x = IO::Capture-new(\*STDERR);
print now capturing\n;
system(q[perl -e print STDERR qq[captured ok\n]]);
print captured text 'captured ok' shouldn't have appeard\n;
$y = $x-capture;
print capture didn't block\n;
print $y;
warn Restored ok\n;
 __END__
 now capturing
 captured text 'captured ok' shouldn't have appeard
 capture didn't block
 captured ok
 Restored ok

-- 
Paul Lindner[EMAIL PROTECTED]   | | | | |  |  |  |   |   |

mod_perl Developer's Cookbook   http://www.modperlcookbook.org/
 Human Rights Declaration   http://www.unhchr.ch/udhr/index.htm



Re: here is a good modperl question on perlmonk

2002-03-05 Thread Paul Lindner

On Tue, Mar 05, 2002 at 04:53:56PM -0600, Dave Rolsky wrote:
 On Tue, 5 Mar 2002, Medi Montaseri wrote:
 
  My suggestion would be to install a Linux on your developer's PC and
  keep with the distributed model. Now everyone can use a common web tree
  and at integeration, bring all of them to a staging box, QC it and ship
  it to production.
 
 Giving everyone their own Apache daemon, which uses their checked out tree
 of code, on a central dev server is really not a problem either.

One other tip... write a small script (or modify apachectl) to start
apache with a port number matched to your unix UID.  This keeps
developers from using clashing port numbers.

  httpd -c Port $UID -c Listen $UID

etc..

-- 
Paul Lindner[EMAIL PROTECTED]   | | | | |  |  |  |   |   |

mod_perl Developer's Cookbook   http://www.modperlcookbook.org/
 Human Rights Declaration   http://www.unhchr.ch/udhr/index.htm



Re: Formatted Printing

2002-02-26 Thread Paul Lindner

On Tue, Feb 26, 2002 at 07:12:55PM -0800, Rasoul Hajikhani wrote:
 Hello folks,
 I have just writen an online ordering system for our company using
 mod_perl. The user must also be able to print the form, preserving the
 format. Since we use netscape (4.5) for Irix 6.5, I can't use the print
 button of the browser, the format is not preserved. Any one know of any
 modules/suggestions on this?

One simple thing is to create a PDF file for the printable format.
Make sure you save it in ascii format, and put simple substitution
strings for each field.  Then just search, replace, and output to the
browser.

There are also PDF modules on CPAN if you're not into templates...

If fancy printing is not your thing, or you want full cross-platform
compatibility consider text/plain output..  You can even send that to
that 20 year old daisy wheel printer..

-- 
Paul Lindner[EMAIL PROTECTED]   | | | | |  |  |  |   |   |

mod_perl Developer's Cookbook   http://www.modperlcookbook.org/
 Human Rights Declaration   http://www.unhchr.ch/udhr/index.htm



Re: Frontier::Responder question

2002-02-18 Thread Paul Lindner

On Mon, Feb 18, 2002 at 10:25:59AM -0500, Robert Landrum wrote:
 I recently picked up Programming web services with XML-RPC.  It 
 mentions a module that I have yet to track down.  I am unable to find 
 Frontier::Responder.  O'Reilly's site mentions that Joe Johnston 
 wrote.  Joe makes it pretty clear that he want's you to use it in 
 place of Frontier::Daemon when writing mod_perl handlers, but never 
 gives an address of where to find it, or how to contact him for it.
 
 The Frontier modules seem to be a little old.  Are there any other 
 newer versions that I should be using instead.  The Frontier::RPC 
 package was last modified in 1999.

Check out RPC::XML.  It is very well implemented, and includes
Net::Server/HTTP::Daemon based server code, and a full client
implementation.  Highly recommended..

-- 
Paul Lindner[EMAIL PROTECTED]   | | | | |  |  |  |   |   |

mod_perl Developer's Cookbook   http://www.modperlcookbook.org/
 Human Rights Declaration   http://www.unhchr.ch/udhr/index.htm



Re: mod_perl cookbook ... next steps

2002-02-18 Thread Paul Lindner

On Thu, Feb 21, 2002 at 01:17:02AM +0200, Issac Goldstand wrote:
 [EMAIL PROTECTED] wrote:
 [snip]
 
 As I need information between the stage of life, I would use $r-notes to
 communicate down the cycle. But then again, if I have some data tied
 to the session (I use Apache::Session), how can I give it to
 the PerlHandler. Is $r-notes proofed for any export, object or blessing
 behavior?
 
 I think $r-pnotes should work fine with this...  But I'm not positive...
 Other than that, it sounds fine...  Except that usually youll 
 authenticate the user in PerlAuthenHandler and use AuthzHandler to 
 decide whether or not to let him do whatever he's trying to do... The 
 Eagle book had some nice explanations of this...

If you have complex data structures pnotes() is definitely the way to
go..  Highly recommended.

Another alternative is to use package globals.  Just make sure that
your PerlInitHandler and PerlCleanupHandler re-initializes them before
every request..

Note: I have not compared the speed differences between these two
approaches.  I would assume the latter would be a little faster.  Of
course it will make your code non-thread-safe, so it's not so good for
potential mod_perl 2.0 compatibility..

-- 
Paul Lindner[EMAIL PROTECTED]   | | | | |  |  |  |   |   |

mod_perl Developer's Cookbook   http://www.modperlcookbook.org/
 Human Rights Declaration   http://www.unhchr.ch/udhr/index.htm



Re: [BUG] Memory Courruption (was: RE: [Q] SIGSEGV After fork())

2002-02-15 Thread Paul Lindner

On Fri, Feb 15, 2002 at 11:44:03AM -0600, Fister, Mark wrote:
 
  Dear mod_perl experts:
  
  Collectively, we've been at this for more than two weeks and have searched
  various mod_perl archives, all to no avail.
  
  Symptom:
  ===
  SIGSEGV after fork().  Very reproducible.  Memory corruption gets moved
  around if the codebase changes.
 
 [ SNIP ]
 
 The above is the key: moved around.  Therefore, I need Purify or similar
 tool.  I'm going to have to go this route, since nobody has any ideas.
 Go go gadget purchasing! :(
 
 The only other way I can think of to solve this is to send my module list
 to this audience.  Please find it, attached, with home-grown modules
 deleted.

To further diagnose this problem you might consider using the sigtrap
module and paying careful attention to your logs...  This at least led
me to the portion of my perl that was causing the problem.

A simple

  use sigtrap;

The default signal handler used in this module gives you a stack trace
before the core dump..


-- 
Paul Lindner[EMAIL PROTECTED]   | | | | |  |  |  |   |   |

mod_perl Developer's Cookbook   http://www.modperlcookbook.org/
 Human Rights Declaration   http://www.unhchr.ch/udhr/index.htm



Re: inheritance and Apache::Request

2002-02-14 Thread Paul Lindner

On Thu, Feb 14, 2002 at 01:55:34PM -0600, Alex Porras wrote:

 Ok, that makes sense.  But the reason I didn't include a new
method for FooBar was because I don't know what A::R's new method
does, so I didn't want to override it.  What if it does some init
stuff to the object? I'm assuming that's what's happening because,
after adding a new method to FooBar, when I try to call
$foobar-param (which I have not overridden), the child process
segfaults.  Oh well, I guess at this point I need to go back to
reading more on perl OO since it's not sinking.

I believe that Apache::Request doesn't really do inheritence properly.
If you look you'll see that the new() method is written in C.  It
should be blessing itself into the passed in class, not using
Apache::Request.  My XS is a little foggy, but it appears that these
lines should be modified to use the passed in class:

CLEANUP:
apreq_add_magic(ST(0), robj, RETVAL);

which ends up as:

ST(0) = sv_newmortal();
sv_setref_pv(ST(0), Apache::Request, (void*)RETVAL);


In any case all you need to do to get around this is define your own
new method and call the Apache::Request object directly and store it
as the value 'r'..  Here's an example:

sub new {
 my ($class, $r) = @_;

 return bless { r  = Apache::Request-new($r),
   }, $class;
}





 Thanks for your help!
 
 --Alex
 
  -Original Message-
  From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
  
  The problem is that package FooBar doesn't have a new 
  method. Here's what happened as a result.
  
  When you called 'FooBar-new($r), perl looked for a sub 
  called new in package
  FooBar. Since it didn't find one, it looked at FooBar's @ISA, 
  and looked in
  Apache::Request for a new method. There it presumably found 
  one, so that
  statement didn't return an error. But, the new() in 
  Apache::Request probably
  returned an Apache::Request object instead of a FooBar 
  object, so when you
  called $form-fooey, it only looked in Apache::Request and 
  any modules in it's
  @ISA.
  
  You might want to look at using the universal isa and can 
  methods while
  you're debugging and trying stuff out. Good luck!
  
  Wes Sheldahl

-- 
Paul Lindner[EMAIL PROTECTED]   | | | | |  |  |  |   |   |

mod_perl Developer's Cookbook   http://www.modperlcookbook.org/
 Human Rights Declaration   http://www.unhchr.ch/udhr/index.htm



Re: About PerlLogHandler phase

2002-02-11 Thread Paul Lindner

On Mon, Feb 11, 2002 at 06:31:25PM -0800, Randy J. Ray wrote:

 * If I install a handler for PerlLogHandler, does the normal logging still
   take place? Is it a function of whether my handler returns OK, DECLINED,
   etc.?

As far as I know return codes are ignored.  This means that all
logging (and cleanup) handlers are called for each request.

 * Are there ways to register other log types, in addition to the access,
   error, etc.? Such that people could specify those (and a format) the
   same way they specify the others? More to the point, so that there
   might be a ready file-descriptor I could print to, rather than having to
   deal with the open/lock/write/unlock/close cycle.

Apache::LogFile (section 16.2) is what you are looking for.  It gives
you a global filehandle that you can print to as much as you care to.

 To explain, I am looking at ways to expand the logging capability in my
 Apache::RPC::Server class. I'd like at the very least to be able to alter the
 URI part such that it reflects the procedure name that was called (this I
 understand how to do). Ideally, I'd like to either write completely different
 lines out to the access log, or (preferable) write to a separate log entirely,
 so that tracking usage statistics is made that much easier. If I go the
 separate log route, I don't want the server to be weighted down by the
 repetitive open/close cycle on the files.

You might also want to consider setting a notes value for each piece
of information you want to log.  This is detailed in section 16.4 of
the cookbook.  It's dead simple, just add this to your httpd.conf:

LogFormat %{RPC_NAME}n %{RPC_ARGS}n %{RPC_RESULTS}n rpc_log_format

Location /RPCSERV
 CustomLog logs/rpc_log rpc_log_format
/Location

and then somewhere in your code do this:

 $r-notes('RPC_NAME', $cow);
 $r-notes('RPC_ARGS', $moo);
 $r-notes('RPC_RESULTS', $milk);


-- 
Paul Lindner[EMAIL PROTECTED]   | | | | |  |  |  |   |   |

mod_perl Developer's Cookbook   http://www.modperlcookbook.org/
 Human Rights Declaration   http://www.unhchr.ch/udhr/index.htm



Re: [Straying from the Topic] Installing from scratch Apache + mod_perl + Apache::ASP (+maybe others) on unix

2002-02-06 Thread Paul Lindner

Two things,

First check out http://www.apachetoolbox.com/ About as out-of-the-box
as you can get.  Last time I tried it seemed to 'do the right thing'
for me.

For mod_perl specifics you might also check out chapter 1 of the
mod_perl Developer's Cookbook.  I think it's a pretty good stab at
showing a novice how to compile and install apache+mod_perl (though
not mod_ssl... alas) The complete chapter is online at
http://www.modperlcookbook.org/


Regards,
Paul


On Thu, Feb 07, 2002 at 12:04:19AM +, Ged Haywood wrote:
 Hi there,
 
 On Thu, 7 Feb 2002, Rod Butcher wrote:
 
 
  professionals are being driven mad, despite reading the Guide (which despite
  being complete is still mysterious, it comes across as having a mission
  statement to contain everything rather than to be useful, sorry). 
 
 Patches, chapters, help are always welcome I'm sure.
 
  My .05 is that all development be stopped until the instal process
  is up to the same standard as M$. This is what made M$ rich, the
  sheer installability and usability. I was visiting somebody
  yesterday and he had Win2K installing while we talked for an hour.
 
 Yeah, I had a car like that once, but I got rid of it.
 
 When I installed the operating system on a Mac last year it took
 about three minutes - including all the tools, browsers and wotnot
 that you could wish for - with no intervention from me at all.
 After the pain I've been through with some W1nd0ze installations
 it was very refreshing.  So I guess what I'm saying is that there's
 a lot more to it than that, or Apple would be ruling the world.
 
 73,
 Ged.

-- 
Paul Lindner[EMAIL PROTECTED]   | | | | |  |  |  |   |   |

mod_perl Developer's Cookbook   http://www.modperlcookbook.org/
 Human Rights Declaration   http://www.unhchr.ch/udhr/index.htm



Re: modifying apache config at runtime

2002-02-04 Thread Paul Lindner

On Mon, Feb 04, 2002 at 04:47:27PM -0500, Peter Beardsley wrote:
 Is is possible to modify the in-memory apache configuration at 
 runtime?  I've seen modules that allow you to parse and modify the 
 httpd.conf file, but that's not really what I'm looking for.  In particular 
 I want to set the value of ErrorDocument.

If all you want to do is that you can just use the custom_response
method.  Here are a couple of examples...

  # on bad requests, redirect to some documentation
  $r-custom_response(BAD_REQUEST,
 http://www.w3.org/Protocols/rfc2616/rfc2616-sec5.html;);

  # but on unauthorized requests, send to a local file
  $r-custom_response(FORBIDDEN, /landlubber.html);


You'll have to do this for every request, because you're cannot change
the global config, only the child's localized configuration..

-- 
Paul Lindner[EMAIL PROTECTED]   | | | | |  |  |  |   |   |

mod_perl Developer's Cookbook   http://www.modperlcookbook.org
 Human Rights Declaration   http://www.unhchr.ch/udhr/index.htm



Re: [OT] Re: mod_perl Developer's Cookbook (and Amazon)

2002-02-02 Thread Paul Lindner

On Sat, Feb 02, 2002 at 10:03:09AM -0600, Mike808 wrote:
  Joe Brenner wrote:
   Spend only $4 more, and you too can show your disgust for
   software patents.
 
 Worth every penny.

I'm against frivolous patents myself.  It harms the industry and could
even be detrimental to mod_perl or Apache if either is found to
infringe upon such a patent.

However, please read the following articles before you boycott.  The
first is an open letter from Jeff Bezos, the second is a fairly
lengthy article on the subject by Tim O'Reilly.

   http://www.amazon.com/exec/obidos/subst/misc/patents.html
   http://www.oreilly.com/ask_tim/patent_reform_0300.html


 And AllBookstores.com is now offering it at the same price as Amazon.
 So now it doesn't cost me anything to show my disgust for software and
 business model patents. As for the Amazon kickback, well, you have a 
 sucky publisher for not giving you more of your directly generated sales.

Well, sometimes you have to take what you can get...  Please note that
it did take some convincing to get this thing published.  No one
seemed to believe that there is a market for mod_perl books.

I am hoping that this book is a success.  Not only for the obvious
altruistic reasons, but also for mod_perl itself.  It's sometimes
depressing going into a bookstore to find shelf-upon-shelf of Java-web
books -- against a puny outcrop of mod_perl related tomes...

So, to reiterate.  Buy your copy whichever way suits you best.  Amazon
or not.  In either case a big THANK YOU to all...  We wouldn't even be
having this discussion if it wasn't for this wonderful community.

-- 
Paul Lindner[EMAIL PROTECTED]   | | | | |  |  |  |   |   |

mod_perl Developer's Cookbook   http://www.modperlcookbook.org
 Human Rights Declaration   http://www.unhchr.ch/udhr/index.htm



Re: mod_perl Developer's Cookbook

2002-01-31 Thread Paul Lindner

On Thu, Jan 31, 2002 at 06:18:55PM -0800, Joe Brenner wrote:
 
  ordered my today through the website (puts a little extra money
  in the hands of mod_perlers:
  
  http://www.modperlcookbook.org/
 
 I just ordered mine through fatbrain, myself...

Thanks!


 I won't deal with amazon:  http://www.noamazon.com

I just added a page with direct links for eight other bookstores.
It's now available at http://www.modperlcookbook.org/order.html


 If there's a mod_perl developer's fund I could contribute to
 (like YAS), I'd be glad to send them a check. 

Now you're talking!  I wonder if YAS would consider funding
perl-related projects like mod_perl?  Perhaps if we had a big name
(Ticketmaster?) we could get the ball rolling on such a thing..


-- 
Paul Lindner[EMAIL PROTECTED]   | | | | |  |  |  |   |   |

mod_perl Developer's Cookbook   http://www.modperlcookbook.org
 Human Rights Declaration   http://www.unhchr.ch/udhr/index.htm



Cross-site Scripting prevention with Apache::TaintRequest

2002-01-22 Thread Paul Lindner

Hi,

I thought it might be interesting to start a thread on cross-site
scripting attacks, since it seems that many people are not aware of
the risks involved.  Has anyone noticed attacks on their applications?
Do you religiously check all input you get from form-submissions?
What techniques do you use to insure that your application is not
vulnerable?

One technique that I've used is 'Tainting' input data (with
PerlTaintCheck) and using a subclass of the Apache module to insure
that tainted data is html-escaped.

As part of the CPANification of the code in the mod_perl Developer's
cookbook, I present Apache::TaintRequest, a module that helps prevent
cross-site scripting attacks by automatically html-escaping 'tainted'
text sent to a web browser..  Get it at
http://www.modperlcookbook.org/code.html

I'd be interested in hearing how others have dealt with the problem,
suggestions on how this module could be used further are most welcome.  


-- 
Paul Lindner[EMAIL PROTECTED]   | | | | |  |  |  |   |   |

mod_perl Developer's Cookbook   http://www.modperlcookbook.org
 Human Rights Declaration   http://www.unhchr.ch/udhr/index.htm



Re: Cross-site Scripting prevention with Apache::TaintRequest

2002-01-22 Thread Paul Lindner

On Tue, Jan 22, 2002 at 07:11:28PM +0100, Robin Berjon wrote:
 On Tuesday 22 January 2002 19:04, Perrin Harkins wrote:
  Of course I set the charset, but I didn't know that might not be enough.
  Does anyone know if Apache::Util::escape_html() and
  HTML::Entities::encode() are safe?
 
 A quick look (I could be wrong) at HTML::Entities seems to imply that it 
 should be safe, as it uses numeric encoding for characters that it doesn't 
 recognize. I don't know about Apache::Util.

BTW, if you don't html-escape and just search for tags you should make
sure to HTML::Entities::decode() the text before processing it.

I've seen cases where people disguised scripting code with numeric
entities.. jav...;script etc...

-- 
Paul Lindner[EMAIL PROTECTED]   | | | | |  |  |  |   |   |

mod_perl Developer's Cookbook   http://www.modperlcookbook.org
 Human Rights Declaration   http://www.unhchr.ch/udhr/index.htm



Re: Single login/sign-on for different web apps?

2002-01-16 Thread Paul Lindner

On Wed, Jan 16, 2002 at 06:56:37PM -0500, Vsevolod Ilyushchenko wrote:
  
   3) Perl-based applications can just use the module and the common key
  to decrypt the contents of the cookie to find the authenticated
  username.  If the cookie is not present redirect to the central
  authentication page, passing in the URL to return to after
  authentication.
 
 Hmmm... Can I do it securely without using Kerberos? I think so. Looks like
 if I use https instead of http, people won't be able to steal my (encoded)
 session information as it is transmitted. And I can also add the IP address
 to the cookie information.
 
 But the cookies file might be readable by other people! If they can steal
 that file and change the IP address of another machine to yours, they can
 pretend they are you!
 I wonder if there is a way out of this...

Yes, you use the timestamp.  Just reauthenticate the user when they
try to do 'sensitive' activities.

For example you might allow someone to view their bank balance if they
typed their password within the last 2 hours.  Transferring money
might require a valid password within the last 10 minutes..

Of course, the best authentication system for banking I've seen is
from UBS.  They send you a scratchlist of around 100 numbers.  Every
time you login you use one of the numbers and cross it off.  Very
slick.


-- 
Paul Lindner[EMAIL PROTECTED]   | | | | |  |  |  |   |   |

mod_perl Developer's Cookbook   http://www.modperlcookbook.org
 Human Rights Declaration   http://www.unhchr.ch/udhr/index.htm



mod_perl in the Open Directory (www.dmoz.org)

2002-01-10 Thread Paul Lindner

Hi,

I was recently accepted as the editor for the mod_perl category of the
Open Directory Project.  The ODP is an all volunteer effort to build a
directory of the web.  Check it out at http://dmoz.org or any number
of other services that use the underlying database (AOL, Google, etc.)
The mod_perl category is available at:

 http://dmoz.org/Computers/Software/Internet/Servers/WWW/Apache/Modules/Mod_Perl/

By expanding this category our community can do a lot to help promote
mod_perl.  The ODP is used by many search engines, and you'll notice
Google uses it for it's search results.  

I'm looking forward to building up the database of links.  I have a
number of my own favorites, but I'd like to hear from the rest of the
community.  If you have a mod_perl related site please submit it at:

   
http://dmoz.org/cgi-bin/add.cgi?where=Computers/Software/Internet/Servers/WWW/Apache/Modules/Mod_Perl

I'll edit through the submissions and craft a nice new structure
(probably similar to the way the PHP category is organized).  Proposed
categories are:

  Directories
  Documentation and FAQs
  Toolkits
  Modules

I may reorganize these based on the breadth of submissions offerred.

Thanks!

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

2002-01-08 Thread Paul Lindner

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: Error log executing scripts?

2002-01-04 Thread Paul Lindner

On Fri, Jan 04, 2002 at 01:13:37PM -, Matt Sergeant wrote:
   Hello,
   I was wondering if there is any way of making the error log 
  in Apache to
   execute a script when an error is occurred, perhaps instead 
  of writing the
   error directly to the log.

There is a way to redirect errors to your own code.  It's not pretty.

You can see some example code that does this at
http://www.modperlcookbook.org/code/ch16/

You can also download an example module that uses this code to
intercept error log entries and post them to an IRC channel.  Nothing
like real-time errors to keep you on your toes :)

You can now read that entire chapter (and two others) online at

  http://www.modperlcookbook.org/chapters.html

Enjoy!

   For example, if there is a image missing Apache excutes a 
  script that
   generates a replacement image?

In this case you're talking about a different type of error condition.
As Matt and Geoff mentioned you can use an ErrorDocument script that
runs whenever this condition exists.  This does not handle other output
that flows into your error_log.

  well, you can do just about anything you want :)
  
  however, althoughit is possible to intercept the actual errors Apache
  (and mod_perl) generates, it is rather complex, and really not the
  proper approach here.
 
 Really? I would have thought it could make an interesting caching technique
 - on a 404 you try and generate the file, and store in that slot in the
 filesystem. A cache cleanup daemon runs to clean out TTL'd files.

Check out Apache::CacheContent - it implements something similar,
available on CPAN or at http://www.modperlcookbook.org/code.html

 Warning: don't try and implement this in a commercial application - it's
 patented by vignette.

Hmmm, I implemented something like this in the early 90s...  Long
before vignette was even around..


-- 
Paul Lindner[EMAIL PROTECTED]   | | | | |  |  |  |   |   |

mod_perl Developer's Cookbook   http://www.modperlcookbook.org
 Human Rights Declaration   http://www.unhchr.ch/udhr/index.htm



Re: Anyone know of specific problems with the malloc in Sun's libc?

2001-12-31 Thread Paul Lindner

On Sun, Dec 30, 2001 at 02:12:47PM -0600, Steven Lembark wrote:
 
 W/ current apache and mod_perl, perl-5.6.1, Solaris-2.8.
 Been having problems with DBI dropping connections. One
 suggestion was to override the default of no and use
 the malloc that comes with perl-5.6.1.

 Anyone know of problems or any obvious symptoms?

I have not seen any problems with the Solaris malloc, in fact it seems
that the VM behavior of our systems improved when we switched over.

Consider setting the DBI_TRACE environment variable if you're having
problems such as this.  It will show you where your connections are
going up and down.  Does your DBD driver support pings?  If not you
should check out the Apache::DBI docs for info on how to roll your
own..


If you feel like recompiling perl on solaris you might want to review
the following options used to build perl with gcc 2.95.3.  Seems to
work well for us...

CFLAGS='-pipe -mcpu=ultrasparc -mtune=ultrasparc -m32 -Wa,-xarch=v8plusa -O3 
-ffast-math -fexpensive-optimizations'

Configure -O -Dcc=gcc \
   -Doptimize=@CFLAGS@ \
   -Dlocincpth=@prefix@/include \
   -Dloclibpth=@prefix@/lib \
   [EMAIL PROTECTED] \
   [EMAIL PROTECTED] \
   -Ud_bincompat5005 \
   -Ubincompat5005 \
   -Uusemymalloc \
   -Uinstallusrbinperl \
   -Dlibperl=libperl.so \
   -Duseshrplib=true \
   -Dstatic_ext=Data/Dumper Fcntl IO POSIX Socket Sys/Hostname \
   -Ui_db \
   -Ui_ndbm \
   -Ui_ndbm \
   -des



-- 
Paul Lindner[EMAIL PROTECTED]   | | | | |  |  |  |   |   |

mod_perl Developer's Cookbook   http://www.modperlcookbook.org
 Human Rights Declaration   http://www.unhchr.ch/udhr/index.htm



Re: mixing cgi-bin mod_perl

2001-12-20 Thread Paul Lindner

On Thu, Dec 20, 2001 at 09:41:31PM +0100, Miroslav Madzarevic wrote:
 The scenario:
 There are two folders
 /cgi-binwith plain perl cgi
 /mod-perl   with Apache::Registry scripts
 
 The application is being moved from cgi to mod_perl (Apache::Registry) one
 script at a time.
 My friend has a strange idea.
 He wants to mix cgi-bin  mod_perl by testing all of the scripts in
 cgi-bin and putting one cgi-script at a time into mod-perl folder.
 He wants to do this internaly in Apache, changing the request for
 a particular script so for example when you reference /cgi-bin/some_scr.pl
 you actually end with /mod-perl/some_scr.pl. He doesn't want to
 change the a href code from html files to stop pointing at /cgi-bin.
 By moving all of them one at a time all of the application will
 eventually end up working under mod_perl.
 
 How can he do that ?
 
 He thought of using mod_proxy or mod_rewrite.
 The scripts are badly written and have been developed for three years
 so far by various perl programmers.

I'd use mod_rewrite or, even better, use the power of the
PerlTransHandler..  Activate the following handler by adding

  PerlTransHandler Moo::my_trans_handler

to your httpd.conf.  In your example it will check for

  /usr/local/apache/cgi-bin/some_scr.pl_mod_perl_me

If that file exists we rewrite the URL to use the /mod-perl prefix
internally.


sub Moo::my_trans_handler {
  my $r = shift;
  my $uri = $r-uri;

  return DECLINED unless ($uri =~ s,^/cgi-bin/,,);
  
  if (-f /usr/local/apache/cgi-bin/${uri}_mod_perl_me) {
$uri = = /mod-perl/$uri
$r-uri(/mod-perl/$uri);
  }
  return DECLINED;
}
  

-- 
Paul Lindner[EMAIL PROTECTED]   | | | | |  |  |  |   |   |

mod_perl Developer's Cookbook   http://www.modperlcookbook.org
 Human Rights Declaration   http://www.unhchr.ch/udhr/index.htm



Re: mod_perl vs. C for high performance Apache modules

2001-12-17 Thread Paul Lindner

On Mon, Dec 17, 2001 at 10:32:58AM -0600, Matthew Kennedy wrote:
 On Fri, 2001-12-14 at 14:27, Thomas Moore wrote:
  I spoke to the technical lead at Yahoo who said mod_perl will not scale as
  well as c++ when you get to their level of traffic, but for a large
 
 Isn't that coming from a company using Python?
 
 I see that most of their URLs include a tell-tale .py. Of course,
 whether that's really Python or not

searching join.yahoo.com I notice 12 job descriptions contain the word
perl, and only 2 that contain the word python..

FWIW, the only place I notice the .py extension is maps.yahoo.com.

-- 
Paul Lindner   [EMAIL PROTECTED]| | | | |  |  |  |   |   |

mod_perl Developer's Cookbook   http://www.modperlcookbook.org
 Human Rights Declaration   http://www.unhchr.ch/udhr/index.htm



Re: Comparison of different caching schemes

2001-12-15 Thread Paul Lindner

On Sat, Dec 15, 2001 at 08:57:30PM -0500, Perrin Harkins wrote:
  One place that Rob and I still haven't found a good solution for
 profiling
  is trying to work out whether we should be focussing on optimising our
  mod_perl code, or our IMAP config, or our MySQL DB, or our SMTP setup,
 or
  our daemons' code, or...
 
 Assuming that the mod_perl app is the front-end for users and that
 you're trying to optimize for speed of responses, you should just use
 DProf to tell you which subroutines are using the most wall clock time.
 (I think it's dprofpp -t or something.  Check the man page.)  If the sub
 that uses IMAP is the slowest, then work on speeding up your IMAP server
 or the way you access it.

 CPU utilization may not be all that telling, since database stuff often
 takes the longest but doesn't burn much CPU.

I agree 100%, wall clock time is the best metric.  Consider that most
apps are not CPU bound, they are I/O or network bound.  Wall clock
time measures that exactly.

Another useful tool is truss/strace.  Start up your server single
process (-X) and then attach to it with strace.  The -c and -r flags
to strace are quite handy..  For example here's the cumulative stats
for 'ls'

% time seconds  usecs/call callserrors syscall
-- --- --- - - 
 52.290.004508 751 6   read
 19.480.001679 560 3   write
 12.930.001115  5620   close
  6.010.000518  2323   old_mmap
  5.450.000470  2122 2 open
  1.220.000105  21 5   munmap
  0.930.80  40 2   getdents64
  0.710.61   321   fstat64
  0.290.25   4 7   brk
  0.240.21  11 2   mprotect
  0.190.16   8 2   ioctl
  0.120.10  10 1   uname
  0.090.08   3 3 2 rt_sigaction
  0.060.05   5 1   fcntl64
-- --- --- - - 
100.000.008621   118 4 total

-- 
Paul Lindner   [EMAIL PROTECTED]| | | | |  |  |  |   |   |

mod_perl Developer's Cookbook   http://www.modperlcookbook.org
 Human Rights Declaration   http://www.unhchr.ch/udhr/index.htm



ANNOUNCE: Apache::CacheContent 0.12 available (1st CPAN release)

2001-12-13 Thread Paul Lindner

Since nobody obected to Apache::CacheContent I've uploaded it to CPAN.
The current version, 0.12, has a few small bug fixes, POD updates and
a new ToDo list.  (This version does not yet have the filename hash
generator code)  The complete README is reproduced below.

You can download the code from CPAN or from the Cookbook site at
http://www.modperlcookbook.org/

Thanks!


NAME
Apache::CacheContent - PerlFixupHandler class that caches dynamic
content

SYNOPSIS
* Make your method handler a subclass of Apache::CacheContent
* allow your web server process to write into portions of your document
root.
* Add a ttl() subroutine (optional)
* Add directives to your httpd.conf that are similar to these:
  PerlModule MyHandler

  # dynamic url
  Location /dynamic
SetHandler perl-script
PerlHandler MyHandler-handler
  /Location

  # cached URL
  Location /cached
SetHandler perl-script
PerlFixupHandler MyHandler-disk_cache
PerlSetVar CacheTTL 120   # in minutes...
  /Location

DESCRIPTION
Note:  This code is derived from the *Cookbook::CacheContent*
   module, available as part of The mod_perl Developer's
   Cookbook

The Apache::CacheContent module implements a PerlFixupHandler that helps
you to write handlers that can automatically cache generated web pages
to disk. This is a definite performance win for sites that end up
generating the exact same content for many users.

The module is written to use Apache's built-in file handling routines to
efficiently serve data to clients. This means that your code will not
need to worry about HTTP/1.X, byte ranges, if-modified-since, HEAD
requests, etc. It works by writing files into your DocumentRoot, so be
sure that your web server process can write there.

To use this you MUST use mod_perl method handlers. This means that your
version of mod_perl must support method handlers (the argument
EVERYTHING=1 to the mod_perl build will do this). Next you'll need to
have a content-generating mod_perl handler. If isn't a method handler
modify the *handler* subroutine to read:

  sub handler ($$) {
my ($class, $r) = @_;


Next, make your handler a subclass of *Apache::CacheContent* by adding
an ISA entry:

  @MyHandler::ISA = qw(Apache::CacheContent);

You may need to modify your handler code to only look at the *uri* of
the request. Remember, the cached content is independent of any query
string or form elements.

After this is done, you can activate your handler. To use your handler
in a fully dyamic way configure it as a PerlHandler in your httpd.conf,
like this:

  PerlModule MyHandler
  Location /dynamic
SetHandler perl-script
PerlHandler MyHandler-handler
  /Location

So requests to *http://localhost/dynamic/foo.html* will call your
handler method directly. This is great for debugging and testing the
module. To activate the caching mechanism configure httpd.conf as
follows:

  PerlModule MyHandler
  Location /cached
SetHandler perl-script
PerlFixupHandler MyHandler-disk_cache
PerlSetVar CacheTTL 120  # in minutes..
  /Location

Now when you access URLs like *http://localhost/cached/foo.html* the
content will be generated and stored in the file
*DocumentRoot*/cached/foo.html. Subsequent request for the same URL will
return the cached content, depending on the *CacheTTL* setting.

For further customization you can write your own *ttl* function that can
dynamically change the caching time based on the current request.

AUTHORS
Paul Lindner [EMAIL PROTECTED]

Geoffrey Young [EMAIL PROTECTED]

Randy Kobes [EMAIL PROTECTED]

COPYRIGHT
Copyright (c) 2001, Paul Lindner, Geoffrey Young, Randy Kobes.

All rights reserved.

This module is free software. It may be used, redistributed and/or
modified under the same terms as Perl itself.

SEE ALSO
The example mod_perl method handler `CacheWeather'.

The mod_perl Developer's Cookbook

HISTORY
This code is derived from the *Cookbook::CacheContent* module, available
as part of The mod_perl Developer's Cookbook.

For more information, visit

  http://www.modperlcookbook.org/



-- 
Paul Lindner   [EMAIL PROTECTED]| | | | |  |  |  |   |   |

mod_perl Developer's Cookbook   http://www.modperlcookbook.org
 Human Rights Declaration   http://www.unhchr.ch/udhr/index.htm



Re: [RFC] Apache::CacheContent - Caching PerlFixupHandler

2001-12-11 Thread Paul Lindner

On Tue, Dec 11, 2001 at 01:50:52AM -0800, Ask Bjoern Hansen wrote:
 On Thu, 6 Dec 2001, Paul Lindner wrote:
 
   BTW -- I think where the docs are cached should be configurable.  I don't
   like the idea of the document root writable by the web process.
  
  That's the price you pay for this functionality.  Because we use
  Apache's native file serving code we need a url-directory mapping
  somewhere.
 
 uh, why couldn't Apache::CacheContent just set 
 $r-filename(/where/we/put/the/cache/$file) ?

Simplicity really.  This was an example in our upcoming book so I
didn't want to add a filename generator to the code, instead we use
Apache's url-file mapping mechanism.  Also this code was derived from
a 404 error handler that I wrote ages ago :)

I assume (since you suggested it) that you can set $r-filename to any
file in any directory without adding a Directory config?  I'll have
to see how this interacts with the built-in access control logic .

 If you add Bill's suggestion about caching on args, headers and
 whatnot you would (on some filesystems) need something like that
 anyway to make a hashed directory tree.

Right.  A more elaborate Apache::CacheContent would have a filename
hash function, and a separate cache directory structure along the
lines of Cache::FileCache.

I suppose that one could put the whole uri-cachefile mapping into a
custom PerlTransHandler and leave Apache::CacheContent as-is..

-- 
Paul Lindner   [EMAIL PROTECTED]| | | | |  |  |  |   |   |

mod_perl Developer's Cookbook   http://www.modperlcookbook.org
 Human Rights Declaration   http://www.unhchr.ch/udhr/index.htm



Re: Perl-status shows 1 Mb for File::Find!

2001-12-10 Thread Paul Lindner

On Mon, Dec 10, 2001 at 06:27:07PM -0500, Vsevolod Ilyushchenko wrote:
 
 
 Perrin Harkins wrote:
  
   I looked at Memory Usage at my perl-status page and was horrified: the
   biggest modules are:
  
   File::Find   1205208 bytes |  2597 OPs
   Convert::ASN1::parser1058185 bytes |  3069 OPs
  
   However, if I go inside File::Find, I can't figure out what takes up so
   much space:
  
  It could be internal structures holding the state.  Are you pre-loading this
  module?  It probably doesn't really use 1MB in each process.
 
 Perrin,
 
 I do preload the module. How do I find out what it really uses?

Can you start your server without File::Find or Convert::ASN1::parser?
Assume that you have the following commented directive in your
httpd.conf file:

 #PerlModule File::Find

Start your httpd server and look at the memory usage.  In my case I
checked out /proc/PID/status on my linux box.  In this case it shows

  VmSize: 8036 kB

Next, uncomment out the directive line, restart and look at the memory
usage...  In my case it shows as:

  VmSize: 8380 kB

So, about 300k in this instance..  YMMV


-- 
Paul Lindner   [EMAIL PROTECTED]| | | | |  |  |  |   |   |

mod_perl Developer's Cookbook   http://www.modperlcookbook.org
 Human Rights Declaration   http://www.unhchr.ch/udhr/index.htm



[RFC] Apache::CacheContent - Caching PerlFixupHandler

2001-12-06 Thread Paul Lindner

Hi,

I would like to propose a new Apache module before I send it off to
CPAN.  The name chosen is Apache::CacheContent.

It's pretty generic code, and is intended to be subclassed.  It
handles the gory details of caching a page to disk and serving it up
until it expires.  

It's derived from work done on the mod_perl Developer's Cookbook, so
it's already been reviewed by a number of people.

I've attached a README below.  To download it go to
http://www.modperlcookbook.org/code.html




NAME
Apache::CacheContent - PerlFixupHandler class that caches dynamic
content

SYNOPSIS
* Make your method handler a subclass of Apache::CacheContent
* allow your web server process to write into portions of your document
root.
* Add a ttl() subroutine (optional)
* Add directives to your httpd.conf that are similar to these:
  PerlModule MyHandler

  # dynamic url
  Location /dynamic
SetHandler perl-script
PerlHandler MyHandler-handler
  /Location

  # cached URL
  Location /cached
SetHandler perl-script
PerlFixupHandler MyHandler-disk_cache
PerlSetVar CacheTTL 120   # in minutes...
  /Location

DESCRIPTION
Note:  This code is derived from the *Cookbook::CacheContent*
   module, available as part of The mod_perl Developer's
   Cookbook

The Apache::CacheContent module implements a PerlFixupHandler that helps
you to write handlers that can automatically cache generated web pages
to disk. This is a definite performance win for sites that end up
generating the exact same content for many users.

The module is written to use Apache's built-in file handling routines to
efficiently serve data to clients. This means that your code will not
need to worry about HTTP/1.X, byte ranges, if-modified-since, HEAD
requests, etc. It works by writing files into your DocumentRoot, so be
sure that your web server process can write there.

To use this you MUST use mod_perl method handlers. This means that your
version of mod_perl must support method handlers (the argument
EVERYTHING=1 to the mod_perl build will do this). Next you'll need to
have a content-generating mod_perl handler. If isn't a method handler
modify the *handler* subroutine to read:

  sub handler ($$) {
my ($class, $r) = @_;


Next, make your handler a subclass of *Apache::CacheContent* by adding
an ISA entry:

  @MyHandler::ISA = qw(Apache::CacheContent);

You may need to modify your handler code to only look at the *uri* of
the request. Remember, the cached content is independent of any query
string or form elements.

After this is done, you can activate your handler. To use your handler
in a fully dyamic way configure it as a PerlHandler in your httpd.conf,
like this:

  PerlModule MyHandler
  Location /dynamic
SetHandler perl-script
PerlHandler MyHandler-handler
  /Location

So requests to *http://localhost/dynamic/foo.html* will call your
handler method directly. This is great for debugging and testing the
module. To activate the caching mechanism configure httpd.conf as
follows:

  PerlModule MyHandler
  Location /cached
SetHandler perl-script
PerlFixupHandler MyHandler-disk_cache
PerlSetVar CacheTTL 120  # in minutes..
  /Location

Now when you access URLs like *http://localhost/cached/foo.html* the
content will be generated and stored in the file
*DocumentRoot*/cached/foo.html. Subsequent request for the same URL will
return the cached content, depending on the *CacheTTL* setting.

For further customization you can write your own *ttl* function that can
dynamically change the caching time based on the current request.

AUTHOR
Paul Lindner [EMAIL PROTECTED], Geoffrey Young, Randy Kobes

SEE ALSO
The example mod_perl method handler the CacheWeather manpage.

The mod_perl Developer's Cookbook





-- 
Paul Lindner   [EMAIL PROTECTED]| | | | |  |  |  |   |   |

mod_perl Developer's Cookbook   http://www.modperlcookbook.org
 Human Rights Declaration   http://www.unhchr.ch/udhr/index.htm



Re: have a memory leaking

2001-12-06 Thread Paul Lindner

On Thu, Dec 06, 2001 at 04:58:31PM +0300, alexis@kubic wrote:
 Hello All,
 
 I have a problem with configuring Apache from mod_perl.
 
 Descriptions of all virtual host i've got from MySQL DB.
 
 And in cycle wrote:

[snip]
 
 And all well (all works!), but when rebooting an apache (apachectl restart) size,
 occupied by each process, increases (as a rule on 2Mb).
 
 Where rake, but?
 
 Platform - FreeBSD 4.3-RELEASE
 Apache/1.3.20 (Unix) mod_perl/1.26 mod_ssl/2.8.4 OpenSSL/0.9.6 PHP/4.0.6 rus/PL30.5

This memory leak on restart is common when Apache is compiled as a
DSO.

I suggest stopping and starting the server.  This command has worked
for me in the past.

   apachectl stop; sleep 1; apachectl start


-- 
Paul Lindner   [EMAIL PROTECTED]| | | | |  |  |  |   |   |

mod_perl Developer's Cookbook   http://www.modperlcookbook.org
 Human Rights Declaration   http://www.unhchr.ch/udhr/index.htm



Re: [RFC] Apache::CacheContent - Caching PerlFixupHandler

2001-12-06 Thread Paul Lindner

On Thu, Dec 06, 2001 at 10:47:35AM -0800, Bill Moseley wrote:
  Ok, hit me over the head.  Why wouldn't you want to use a caching proxy?
 
 Apache::CacheContent gives you more control over the caching process
 and keeps the expiration headers from leaking to the browser.
 
 Ok, I see.
 
 Or maybe you want to dynamically control the TTL?
 
 Would you still use it with a front-end lightweight server?  Even with
 caching, a mod_perl server is still used to send the cached file (possibly
 over 56K modem), right?

You definitely want a proxy-cache in front of your mod_perl server.

One thing that I like about this module is that you can control the
server-side caching of content separate from the client/browser cache.

So, on to the RFC.  Is the name acceptable for Apache::*

I will endeavor to add any functionality that makes it worthy :)

For example, I think adding a virtual method that generates the
filename might be useful.

-- 
Paul Lindner   [EMAIL PROTECTED]| | | | |  |  |  |   |   |

mod_perl Developer's Cookbook   http://www.modperlcookbook.org
 Human Rights Declaration   http://www.unhchr.ch/udhr/index.htm



Re: [RFC] Apache::CacheContent - Caching PerlFixupHandler

2001-12-06 Thread Paul Lindner

On Thu, Dec 06, 2001 at 12:55:25PM -0800, Andrew Ho wrote:
 Hello,
 
 PLThat's the price you pay for this functionality.  Because we use
 PLApache's native file serving code we need a url-directory mapping
 PLsomewhere.
 PL
 PLOf course you don't need to make the entire docroot writable, just the
 PLdirectory corresponding to your script.
 
 Apologies if this is obvious--I haven't downloaded and tried this module
 yet. But would it not be possible to specify a separate directory
 altogether and make it serveable (Directory ... ... Allow from all ...)?
 If so perhaps it'd be easy to add this as a configurable parameter.

Yes, you can do this using the regular Apache directives:

# mkdir /var/cache/www/mydir
# chown apache /var/cache/www/mydir
# vi /etc/httpd/conf/httpd.conf


Directory /var/cache/www/mydir
AllowOverride None
Order allow,deny
Allow from all
/Directory

Alias /mydir/ /var/cache/www/mydir/

 In general it is a fine idea to not make the DocumentRoot writeable by the
 web user. In fact, I believe it is a good policy that the web user should
 be able to write only to a small subset of controlled locations.

Yes, I agree totally!  I'll add some warning to the docs to make sure
that people do not inadvertently misconfigure their servers..

-- 
Paul Lindner   [EMAIL PROTECTED]| | | | |  |  |  |   |   |

mod_perl Developer's Cookbook   http://www.modperlcookbook.org
 Human Rights Declaration   http://www.unhchr.ch/udhr/index.htm



Re: PerlWarn and syslog

2001-12-06 Thread Paul Lindner

On Thu, Dec 06, 2001 at 02:11:28PM -0800, Lance Uyehara wrote:
 I am using apache+mod_perl and have:
 
 ErrorLog syslog
 PerlWarn On
 
 However the warning don't come out. If I change to ErrorLog
 /var/log/logfile or something similar then the warning start appearing. How
 do I get the warnings when syslog is used?

I've seen various problems with Apache's built in syslog under
mod_perl.  The solution that I've been using lately is:

ErrorLog | logger -p local3.debug


If you just print to STDERR you might want to look at Apage::LogSTDERR
on CPAN.

-- 
Paul Lindner   [EMAIL PROTECTED]| | | | |  |  |  |   |   |

mod_perl Developer's Cookbook   http://www.modperlcookbook.org
 Human Rights Declaration   http://www.unhchr.ch/udhr/index.htm



Re: Install mod_perl on Solaris 2.7

2001-06-18 Thread Paul Lindner

On Mon, Jun 18, 2001 at 11:03:10AM +0100, Paul Reynolds wrote:
 What versoin of mod_perl are you using? I tend to stay away from 1.25. Try
 installing a version between 1.17 and 1.25, excluding 1.25.

The attached script works for our project.  Just replace the @x@
values with stuff that you use on your own site..  It assumes that you
have the following directory layout:

  ./perl
  ./http/apache
  ./http/mod_perl

We use Apache 1.3.20, mod_perl 1.25, and perl 5.6.1, all built with
gcc 2.95.3 on solaris 2.6 or 2.8..

First off, some optimization flags:

CC=gcc CXX=g++ CFLAGS='-pipe -mcpu=ultrasparc -mtune=ultrasparc -m32 
-Wa,-xarch=v8plusa -Os'


Then, the perl args for use on Solaris, followed by some make rules to
build perl..


PERL_OPTS=-O -Dprefix=@prefix@ \
   -Dcc=@CC@ \
   -Doptimize=@CFLAGS@ \
   -Dlocincpth=@prefix@/include \
   -Dloclibpth=@prefix@/lib \
   [EMAIL PROTECTED] \
   [EMAIL PROTECTED] \
   -Ud_bincompat5005 \
   -Ubincompat5005 \
   -Uusemymalloc \
   -Uinstallusrbinperl \
   -Dlibperl=libperl.so \
   -Duseshrplib=true \
   -Dldflags=-L@prefix@/lib\
   -Duse64bitint \
   -des

PERL_CCEOPTS=-Dccflags='-DPERL_EMERGENCY_SBRK -DTWO_POT_OPTIMIZE -DPACK_MALLOC'

@prefix@/bin/perl: @srcdir@/perl/perl @srcdir@/perl/Makefile
$(MAKE) -C @srcdir@/perl install.perl
cd /usr/include; @prefix@/bin/h2ph * sys/*; \

@srcdir@/perl/perl: @srcdir@/perl/Makefile @prefix@/lib/libgdbm.so
@$(MAKE) -C @srcdir@/perl -j2 $(DEVARGS)

@srcdir@/perl/Makefile: @srcdir@/perl/Configure
(cd perl; env CCEOPTS=$(PERL_CCEOPTS) sh Configure $(PERL_OPTS))




And finally the apaci args used to build mod_perl+apache..


HTTPDENV=
PERLFLAGS=

APACI_ARGS=--enable-module=status --enable-module=proxy --prefix=@prefix@ 
--includedir=@prefix@/include/apache --disable-module=so --disable-module=asis 
--disable-module=imap --disable-module=cgi --disable-module=userdir 
--disable-module=autoindex --disable-module=include --disable-rule=EXPAT 
--disable-rule=WANTHSREGEX

echo ..configuring mod_perl+apache;\
cd @srcdir@/http/mod_perl;\
env CFLAGS=@CFLAGS@ -DDYNAMIC_MODULE_LIMIT=0 
-DSINGLE_LISTEN_UNSERIALIZED_ACCEPT $(PERL) $(PERLFLAGS) Makefile.PL $(HTTPDENV)\
USE_APACI=1 APACI_ARGS=$(APACI_ARGS) \
EVERYTHING=1 PERL_STASH_POST_DATA=1 \
DO_HTTPD=1 APACHE_SRC=../apache/src \
PERL_USELARGEFILES=0\
PERL_MARK_WHERE=1 PERL_SECTIONS_SELF_BOOT=1


Hope this helps others using solaris...  It seems to work well for us.
I can't wait to try gcc 3.0 now that it's been released, this should
allow for even greater optimization of the code base...




 - Original Message -
 From: Joseph Francois
 To: [EMAIL PROTECTED]
 Sent: Monday, June 18, 2001 10:09 AM
 Subject: Install mod_perl on Solaris 2.7
 
 
 
 Hello,
 I've been trying to install Mod_perl as APACI on solaris 2.7. but after
 the build i get  httpd: Cannot find ELF. I make mod_perl install apache
 for me. when I install apache without mod_perl, apache works fine. Please
 help
 
 thank you

-- 
Paul Lindner
[EMAIL PROTECTED]



Re: Real Widgets and Template Languages

2001-05-24 Thread Paul Lindner

On Thu, May 24, 2001 at 09:59:36AM -0400, Chip Turner wrote:
 darren chamberlain [EMAIL PROTECTED] writes:
 
 The nice thing about closures is they could hide any interface at all
 behind them; all that is required is that the function that generates
 the closure follow the very simple convention of return the formvar
 of the name starting with the first parameter you're called with.
 There is absolutely no reliance upon the underlying object structure.
 What you're suggesting is equivalent to assuming the object is derived
 from some kind of base class that supports the param() method though
 without actually having to be ISA of that class.  That's naughty OO
 programming :)  Just because perl lets you be typeless doesn't mean
 it's always in the best interest of clean design to do so.

I don't find a problem with passing an object that has a certain set
of method signatures.  This is functionally loosely equivalent to a
Java Interface..  Any perl object can implement a particular interface
just by implementing the methods..  No base class required..

But I agree, closure are very cool, and allow for an additional layer
of abstraction between the objects, without having to create a proxy
class..

 Closures are excellent in hiding implementation details of simple
 operations, and I think in this case they fit quite well.  The system
 can even be written to work just fine without the user using closures
 if they're using CGI.pm, as in my previous example.

-- 
Paul Lindner
[EMAIL PROTECTED]



Re: Re: installating mod_perl-1.25/apache_1.3.19/perl 5.005_02/solaris 5.6

2001-05-10 Thread Paul Lindner

On Thu, May 10, 2001 at 07:51:05PM +0100, G.W. Haywood wrote:
 Hi there,
 
 On 10 May 2001, qazi Ahmed wrote:
 
  I dont have any idea regarding the clock skew detected error.
 
 In this case it just means that 'make' has noticed something odd about
 the various dates and times in your system.  It is very important for
 several reasons that you keep the computer clock as accurate as you
 can.  There are free utilities such as 'ntpd' to help you to do that.

Another source of trouble is compiling on an NFS mounted partition
where.  If the time or timezone on the server does not agree with the
time on the client you will end up with these problems.

I had to deal with this all the time when I used a NetApp Filer with
an old firmware that didn't support ntp..

-- 
Paul Lindner
[EMAIL PROTECTED]



Re: Exception modules

2001-04-30 Thread Paul Lindner

On Mon, Apr 30, 2001 at 05:47:03PM -0700, brian moseley wrote:
 On Mon, 30 Apr 2001, Jeffrey W. Baker wrote:
 
  type of exception.  Right now I cannot in fact think of
  any program I have written that branches on the type of
  exception.  Java encourages this with multiple catch
 
 in CP Web Mail, the underlying libraries throw typed
 exceptions so that the application layer can display the
 correct error notification to the user. for instance, if the
 library throws CP::InvalidMailboxNameException, Web Mail can
 display 'the mailbox name you suggested contains an illegal
 character. it must correspond to the format thus-and-such.
 try again.', whereas if the library throws CP::Exception
 (the generic exception), Web Mail will handle it as a
 service problem and display that godawful WM page.

On a related note, does anyone anywhere still use
Experimental::Exception?

Has anyone compared the performance and features of the various
exception packages?  I'd like to move to something that is a bit
better supported than Experimental::Exception, and don't feel like
converting thousands of lines of try {} catch {} to eval {}; if 

Thanks.

-- 
Paul Lindner
[EMAIL PROTECTED]



Cutting down on the DEBUG bloat...

2001-04-10 Thread Paul Lindner

Hi,

As part of my ongoing effort to streamline my mod_perl apps, I've come
to discover the joy of constant subroutines and perl's ability to
inline or eliminate code at compile time.  I have a solution that
works, but would be interested in seeing if others had better
syntactic sugar..  Anyway:

We have a module CP::Util, with this begin block:

  BEGIN {
$ENV{CP_DEBUG} ||= 0;
if ($ENV{CP_DEBUG} == 1) {
  *{CP::Util::DBG} = sub () {1;};
} else {
  *{CP::Util::DBG} = sub () {0;};
}
  }
  @EXPORT_OK = qw(DBG);


Then, in another module I do:

  use CP::Util qw(DBG);

  DBG  debug('whoa there boy');


The end result is, when CP_DEBUG=1, the code is in there.  When
CP_DEBUG=0, the code is trimmed out at compile time (because DBG is a
constant subroutine, see perldoc perlsub for more info)

This is a real win compared to our old way of using a subroutine
called debug that did a no-op.  Consider:

   debug 'whoa there' . $foo . join(keys(%bar));

The args to debug are still computed, passed on the stack, etc..

Now, my question is: Is there some trick I could use to retain the simple syntax:

  debug "foo bar";


In any case I hope the above exercise opens up everyone's eyes.  Just
goes to show that your debug statements might actually be slowing your
mod_perl application.

Cheers.

-- 
Paul Lindner
[EMAIL PROTECTED]



Re: Error reporting mod_perl 1.25 + apache 1.3.17

2001-02-05 Thread Paul Lindner

On Mon, Feb 05, 2001 at 06:41:00PM +, G.W. Haywood wrote:
 Hi there,
 
 On Mon, 5 Feb 2001, Matisse Enzer wrote:
 
  I compiled perl 5.6 and Apache 1.3.17 using gcc egcs-2.91.66
  on a RH Linux 6.1 system.
  
  If I compile Apache without modperl it run OK. If i compile it with 
  mod_perl 1.25 I also get the segmentation fault on startup.
  
  I looked in ../mod_perl/SUPPORT  and didn't see anything obvious 
  about this problem.
 
 The SUPPORT document is intended to help you to provide information
 which will be helpful to those trying to help you...
 
 I hope that's clear. :)
 
 I'm sure there must be people on this List who have successfully built
 mod_perl systems using exactly the packages you have mentioned.
 
 Anyone care to confirm that?

I've seen some strange segementation fault problems with mod_perl
1.25.  I have not had the time to document these.

Environment is similar to others: mod_perl 1.25, apache 1.3.17, perl
5.00503, solaris 2.6...

-- 
Paul Lindner
[EMAIL PROTECTED]



Re: Form Fillin with Apache::ASP

2001-01-12 Thread Paul Lindner

Nice.

I look forward to your next release...

On Fri, Jan 12, 2001 at 12:38:12PM -0800, Joshua Chamas wrote:
 "T.J. Mather" wrote:
  
  There is an easy way of doing auto form fillin with Apache::ASP using
  HTML::FillInForm - for details see (credit goes to Paul Lindner)
  
 
 I have integrated HTML::FillInForm functionality into Apache::ASP.
 It will be activated with 
 
   PerlSetVar FormFill 1
   $Response-{FormFill} = 1
 
 This will be in v2.09, please let me know if you would 
 like an early release of the module.  Its use is documented
 in "perldoc Apache::ASP" and ./site/eg/formfill.asp
 
 Its very lightweight, and for filling the 700+ byte form 
 at ./site/eg/formfill.asp, it takes some .0046 seconds
 additional time on my Linux 450 PIII out of .032 seconds 
 total for the request.
 
 --Josh
 
 _
 Joshua Chamas Chamas Enterprises Inc.
 NodeWorks  free web link monitoring Huntington Beach, CA  USA 
 http://www.nodeworks.com1-714-625-4051

-- 
Paul Lindner
[EMAIL PROTECTED]
Red Hat Inc.



mod_perl related work at Red Hat in Raleigh/Durham NC

2001-01-03 Thread Paul Lindner

Hi there,

First off, I want to thank everyone who's applied for redhat.com jobs
in the Bay Area.  The people on this list are the best!

Today, however, I am looking for skilled candidates for positions
located in the Raleigh/Durham area in North Carolina.  Relocation
assistance may be provided for exceptional candidates.  Sorry, no
telecommuting.   This position involves working on Red Hat's new web
offering 'Red Hat Network' (http://www.redhat.com/network/)

The generic job description follows.  

Contact me at [EMAIL PROTECTED] for more info about these
positions.

Regards..



Job Description

Job Title: Web Engineers
Department: Engineering
Reports To: Manager, Web Development

Red Hat wants you!

Red Hat is looking for some skilled web engineers to design, enhance,
and implement applications on the Red Hat web site.  You will work on
a global team to create a best-of-breed web site and implement web
services that support Red Hat's Open Source products and services.

The ideal candidate will have the following characteristics:

  1. Ability to learn.  Candidate must show they can adapt to the rapidly
 changing technology landscape.

  2. Ability to communicate.  Candidate must show that they can express
 ideas with elegance and flair.

  3. Mature technical ability.  Candidate must understand how the web 
 works from a low to a high level.  Candidate must also understand
 how quality software is designed and constructed.  We want you 
 to think as much as you code.


Other required skills:

   Four year degree or equivalent industry experience.

   Previous experience developing web applications, 
   preferably for a high volume revenue based web site.

   Understanding and experience with object-oriented design and coding.

   Experience using Perl with Apache.

   Understanding of relational database concepts and SQL (prefer
   Oracle)

   Experience with HTML and HTML tools.

   Knowledge of basic Software Engineering concepts: development models,
   testing, and documentation.

Pluses:

   Knowledge of Red Hat's products and services.

   Expert Perl programming experience including: 
   Perl web applications under Apache and mod_perl, 
   Apache modules, 
   Perl modules, 
   Perl OOP extensions, 
   Apache::ASP

   Internet protocols and libraries.

   Languages: Java, Javascript, Python, PHP, C, C++

   Web Technology: XML, XSLT and XML-RPC; Internationalization;
Applications Servers (HTML::Mason, Embperl, Apache::ASP, Zope,
Zentropa, AxKit, Cocoon etc.); Search systems and concepts.

   Oracle Applications (ERP, CRM) Experience.


Benefits

   Red Hat has a comprehensive benefits package.



-- 
Paul Lindner
[EMAIL PROTECTED]
Red Hat Inc.



Re: 2 servers based on .htaccess authentication

2000-11-29 Thread Paul Lindner

If you are using shared repositories for the front-end and heavy
server you can modify the filename used for .htaccess in the apache
config file.  (See the AccessFileName entry)

So, you could put the config for the heavy server in .htaccess_heavy
and the front-end config in .htaccess.

On Wed, Nov 29, 2000 at 12:05:14PM -0500, [EMAIL PROTECTED] wrote:
 
   We are finally planning to "do the right thing" and have a light weight and
 heavy weight server. Our problem is that our (immediate) users set up
 the protections for each directory with .htaccess files - and they use
 PerlAuthzHandler and PerlAuthenHandlers - so to decide if a file can be
 delivered requires modperl.
 
So the solution I have come up with is to proxyPass any request 
 requiring authentication to the modperl server.  Any existing solution
 is welcome!  The approach I am trying though is:
- write an authentication module (in C) to add to the light weight
  server.  All it does is bunce the request to the heavy server. This
  is figuring if apache invokes this module authentication is being
  attemtped.
 
   Problem: something is still seeing and complaining about the
 PerlAuthenHandler stuff.  I have pulled (I believe) all the other
 authentation and authorization modules - why and which apache aspect 
 might be doing this???
 
  
   A concern: in my module I do a REDIRECT to the heavy weight.  Doesn't this
 go back to the browser?  How do I do a proxyPass in C like the rewrite setup
 does so well??
 
   THanks,  Bob Waldstein  [EMAIL PROTECTED]
 
 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]

-- 
Paul Lindner
[EMAIL PROTECTED]
Red Hat Inc.

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: New Module Idea: MLDBM::Sync

2000-11-22 Thread Paul Lindner

On Wed, Nov 22, 2000 at 10:58:43AM +, Tim Bunce wrote:
 On Tue, Nov 21, 2000 at 03:00:01PM -0800, Perrin Harkins wrote:
  On Fri, 17 Nov 2000, Joshua Chamas wrote:
   I'm working on a new module to be used for mod_perl style 
   caching.  I'm calling it MLDBM::Sync because its a subclass 
   of MLDBM that makes sure concurrent access is serialized with 
   flock() and i/o flushing between reads and writes.
  
  I looked through the code and couldn't see how you are doing i/o
  flushing.  This is more of an issue with Berkeley DB than SDBM I think,
  since Berkeley DB will cache things in memory.  Can you point to me it?
 
 I'm puzzled why people wouldn't just use version 3 of Berkeley DB (via
 DB_File.pm or BerkeleyDB.pm) which supports multiple readers and
 writers through a shared memory cache.  No open/close/flush required
 per-write and very very much faster.
 
 Is there a reason I'm missing?

Might MLDBM::Sync work over an NFS mounted partition?  That's one
reason I've not used the BerkeleyDB stuff yet..

-- 
Paul Lindner
[EMAIL PROTECTED]
Red Hat Inc.

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: Why Does restart/gracefull makes httpd grow ?

2000-10-19 Thread Paul Lindner

On Thu, Oct 19, 2000 at 01:55:50PM -0400, Philippe M. Chiasson wrote:
 Hi, I recently upgraded our servers to mod_perl 1.24.1 so I decided to
 give DSO mod_perl a try.  And it now works perfectly, even with our perl
 modules implementing core httpd configuration directives (Wich was broken
 under DSO until 24.1)
 
 So, I decided to start playing with restart/graceful too, thinking that DSO might 
solve
 the problems of cleanly restarting a mod_perl server without loss of service...
 
 Here is a bit of top while restarting my server a few times :

[]

I've found that mod_so combined with Perl's dynamic loading causes this memory 
leakage.  

I ended up compiling apache without mod_so (i.e. all modules compiled in static, no 
DSO) and
I do not see this memory leakage at all.

 And everything apparently behaves fine and keeps on working, but my main question is 
where is the 12Mb that adds to
 each process on restart comes from ? What is hapenning ?
 
 I know these issues have been brought before in the case of statically compiled-in 
mod_perl, but doesn't restarting the
 server freeing libperl.so and re-loading it freshly ?
 
 Any information would be more than welcome ...
 
 ## My version info is :
 Redhat 6.2 running on a i386 Linux 2.2.17
 
 Server version: Apache/1.3.14 (Unix)
 Server built:   Oct 18 2000 14:00:36
 
 perl5 (5.0 patchlevel 5 subversion 3)
 
 mod_perl 1.24.1
 
 /usr/local/apache/bin/httpd  -l
 Compiled-in modules:
   http_core.c
   mod_so.c
 
 
 -- 
 +---+
 | Philippe M. Chiasson  [EMAIL PROTECTED] |
 | SmartWorker http://www.smartworker.org|
 | IM : gozerhbe  ICQ : gozer/18279998   |
 +---+
 /*   * Hash table gook..   */ 
   -- Linux2.4.0-test2
   /usr/src/linux/fs/buffer.c
 
 perl -e '$$=\${gozer};{$_=unpack(P26,pack(L,$$));/^Just Another Perl 
Hacker!\n$/print||$$++redo}'



-- 
Paul Lindner
[EMAIL PROTECTED]
Red Hat Inc.



Re: Compiling apache staticly with mod_perl.

2000-10-10 Thread Paul Lindner

On Tue, Oct 10, 2000 at 02:43:36PM -0400, Geoffrey Young wrote:
 
 
  -Original Message-
  From: Peter Gebauer [mailto:[EMAIL PROTECTED]]
  Sent: Tuesday, October 10, 2000 8:20 AM
  To: [EMAIL PROTECTED]
  Subject: Compiling apache staticly with mod_perl.
  
 [snip]
  
  Did anybody compile Apache + mod_perl + other modules or have
  documentation that is written for this specific purpouse (since the
  INSTALL file that comes with mod_perl is totally insufficient)?
 
 http://perl.apache.org/guide/install.html
 
 in general, the guide full of lots of good information for mod_perl users...

Also see the following URLs

http://people.redhat.com/plindner/apache/apache-heavy-1.3.12-3.i386.rpm
http://people.redhat.com/plindner/apache/apache-heavy-1.3.12-3.src.rpm

For a statically linked RPM.

-- 
Paul Lindner
[EMAIL PROTECTED]
Red Hat Inc.



Re: Compilation recommendations.

2000-09-26 Thread Paul Lindner

See http://people.redhat.com/plindner/apache/ for a static mod_perl
that runs well on redhat.

I am putting src and i386 rpms there..

Note that this is incomplete.  You'll need to roll your own conf files...

This also includes some oracle and php code too.  Thus it is blessed
'apache-heavy'

I would love to hear feedback on how to improve this distribution.

Thanks.


On Tue, Sep 26, 2000 at 02:45:10PM -0400, darren chamberlain wrote:
 Lord Vorp ([EMAIL PROTECTED]) said something to this effect:
  Is there an easier/cleaner way to do this???
 
 
 Yes:
 
 # cat  ~/build_mod_perl
 perl Makefile.PL APACHE_SRC=../apache-1.3.9/src \
 DO_HTTPD=1 \
 USE_APACI=1 \
 EVERYTHING=1 \
 APACI_ARGS='--prefix=/usr \
--with-layout=RedHat --add-module=/usr/src/redhat/SOURCES/mod_bandwidth.c \
--add-module=/usr/src/redhat/SOURCES/mod_put.c --enable-module=all \
--enable-shared=max --disable-rule=WANTHSREGEX --disable-module=auth_dbm \
--with-perl=/usr/bin/perl --enable-suexec --suexec-docroot=/home/httpd/html \
--suexec-caller=nobody --disable-shared=perl'
 
 cd mod_perl-#.##
 make
 make install
 cd ../apache-#.#.#
 make install
 ^D
 
 # cd /usr/local/src
 # sh ~/build_mod_perl
 #
 
 If you think this is hard, try it without make.
 
 (darren)
 
 -- 
 Blind faith in anything, even your leaders, will get you killed.
   -- Bruce Springsteen

-- 
Paul Lindner
[EMAIL PROTECTED]
Red Hat Inc.



Re: Finding Consultants on adding Perl Modules

2000-09-21 Thread Paul Lindner

On Thu, Sep 21, 2000 at 10:19:55AM -0700, Byron Stephen Lee wrote:
 Hi:
 
 Do you have a list of consultants who have experience in adding Perl Modules
 to Apache?  We have a business need for some modules, such as Storable, and
 would be willing to contract for them.  Is there some mechanism in general
 for finding Apache consultants?  There are other areas we could use some
 help in, but as you know, many people put Apache on their resume if they
 have even read your web site!
 
 I'd appreciate any help you could give on this.
 

perhaps you could try posting your requirements on sourcexchange?

-- 
Paul Lindner
[EMAIL PROTECTED]
Red Hat Inc.



Re: Static mod_perl+modules

2000-09-15 Thread Paul Lindner

On Fri, Sep 15, 2000 at 01:50:40PM +0300, Antti Linno wrote:
 Hallo.
  As I was having problems with mod_perl as module and mysql+dbi, I was
 told to install mod_perl statically to apache and php as a module. I
 looked at install instructions and found static install or module install.
 But with static install how and when do I install PHP as a module.
 Any instructions, examples would help.
 Thanking in advance,

We have what we call the apache-heavy src RPM.  It's 1.3.12 + php
4.0.2 + mod_perl 1.24 + oracle, all static.  If anyone is interested I
can put it up for ftp..

-- 
Paul Lindner
[EMAIL PROTECTED]
Red Hat Inc.



Re: Static mod_perl+modules

2000-09-15 Thread Paul Lindner

On Fri, Sep 15, 2000 at 06:35:00AM -0700, Paul Lindner wrote:
 On Fri, Sep 15, 2000 at 01:50:40PM +0300, Antti Linno wrote:
  Hallo.
   As I was having problems with mod_perl as module and mysql+dbi, I was
  told to install mod_perl statically to apache and php as a module. I
  looked at install instructions and found static install or module install.
  But with static install how and when do I install PHP as a module.
  Any instructions, examples would help.
  Thanking in advance,
 
 We have what we call the apache-heavy src RPM.  It's 1.3.12 + php
 4.0.2 + mod_perl 1.24 + oracle, all static.  If anyone is interested I
 can put it up for ftp..

Okay, since there is interest out there, see 

  http://people.redhat.com/plindner/apache-heavy-1.3.12-1.src.rpm

Cheers.

Then install it; you might want to play around with the spec file, I
have a few defines in there to turn on/off some options in PHP etc...

I can say that it's been working pretty well for our site.  We haven't
pushed the PHP end to it's limit though.

-- 
Paul Lindner
[EMAIL PROTECTED]
Red Hat Inc.



Re: multilanguage site

2000-09-05 Thread Paul Lindner

On Fri, Sep 01, 2000 at 10:44:10PM -0400, Greg Stark wrote:
 
   can someone suggest me the best way to build a multilanguage web site
   (english, french, ..).
   I'm using Apache + mod_perl + Apache::asp (for applications)
 
 I'm really interested in what other people are doing here. We've just released
 our first cut at i18n and it's going fairly well. But so far we haven't dealt
 with the big bugaboo, character encoding. 

 One major problem I anticipate is what to do when individual include files are
 not available in the local language. For iso-8859-1 encoded languages that's
 not a major hurdle as we can simply use the english text until it's
 translated. But for other encodings does it make sense to include english
 text? 

 If we use UTF-8 all the ascii characters would display properly, but do most
 browsers support UTF-8 now? Or do people still use BIG5, EUS, etc? 

 As far as I can tell there's no way in html to indicate to the browser that a
 chunk of content is in some other encoding other than what was specified in
 the headers or meta tag. There's no span charset=... attribute or anything
 like that. This seems to make truly multilingual pages really awkward. You
 basically must use an encoding like UTF-8 which can reach the entire unicode
 character set or else you cannot mix languages.

It's a mess, but you're just going to have to assume multiple
character sets for the forseeable future.  We try to use all utf8 data
sources.  XML defaults to this. Oracle can be easily set up this way,
and you can use utf8 in your html sources too.  You just have to be
careful, for example in our message catalogs we source translations
into utf8.

Anyway, here's what's in my global.asa to take care of this character
set conversion mess..  Full details available to those that are
interested..


In Script_OnStart we convert submitted data to utf8

  ...
  #set $Apps::Param to form data or querystring.

  # decide on character set based on submitted form data element
  # 'asp_charset', or based on user's language.

  my $charset = $Apps::Param-{'asp_charset'};
  $charset = 'x-euc-jp' if (!$charset  $Session-{"Lang"} eq 'ja');

  $charset ||= 'iso-8859-1';

  # Convert japanese to UTF8
  ... messy Jcode stuff removed..
  # convert utf8 
   ; # no-op
  # convert iso8859-1 to utf8
  ... messy Unicode::String code..

  $Response-{Charset} = $charset;


In Script_OnFlush we convert the internal utf8 data to the target charset

  my $charset = $Response-{Charset};

  # do character set conversion..
  if ($charset eq 'x-euc-jp') {
... messy Jcode stuff
  } elsif ($charset eq 'iso-8859-1') {
... unicode::string stuff here.
  }

  # here's the tricky part:
  # Automatically add hidden charset fields to forms?
  $$data =~ s,(form.*/form),formfixer($1),sige;


Here's the formfixer thing, it adds hidden charset values to the form:

sub formfixer {
my $form = shift;
return($form) if ($form =~ /action="?http/);
$form =~ s,/form,input type="hidden" name="asp_charset" 
value="$Response-{Charset}"/form,si;
return($form);
}



-- 
Paul Lindner
[EMAIL PROTECTED]
Red Hat Inc.



Re: XML::XPath in APache::ASP - doesn't work

2000-08-28 Thread Paul Lindner

On Mon, Aug 28, 2000 at 07:11:17AM -0700, Dmitry Beransky wrote:
  I don't know why its working on the command line and not in your web
  page. Seems very odd to me. Have you tried setting $XML::XPath::Debug=1
  and seeing if that shows anything suspect (expect LOTS of stuff to come
  out). Also note that XML::XPath doesn't work with Perl 5.6 yet. I'm
  uploading XML::XPath 0.99 today to fix that.
 
 I'm still using good ol' 5.005 :)  I just tried your Debug=1 suggestion
 (BTW, it doesn't appear to be documented in XML::XPath) and the output
 seems identical for both the ASP and the "offline" versions of the
 script.  I guess I'll have to dive into XPath internals and place a few
 trace statements of my own...
 

You might try intentionally placing a syntax error in your asp script
so you can analyze the parsed output.  It's possible the parser is
doing something unexpected to your code.

-- 
Paul Lindner
[EMAIL PROTECTED]
Red Hat Inc.



Sticky forms for Apache::ASP

2000-08-16 Thread Paul Lindner

Hi,

We've worked out a solution to get sticky form fields inside Apache::ASP

We use HTML::FillinForm and a custom tag to get the desired behaviour.
Put this is in global.asa:


 sub fillin {
   my $args = shift;
   my $html = shift;
   my $fif = new HTML::FillInForm;
   my $output = $fif-fill(
   scalarref = \$html,
   fdat  = $Apps::Param,
   );
   $Response-Write($output);
 }

Note $Apps::Param is set to either the querystring or form data.
Replace with $Request-QueryString or $Request-Form if you wish.

Then put something like this in your apache configuration:

  XMLSubsMatch fillin

Finally, surround your forms like this:

  fillin
form
  input name="myfield"
/form
  /fillin


And voila, instant filled in forms..

Note that a small variation to this technique allows for ASP3.0 style
evaluation of forms.

Instead use a 'form' function

 sub form {
  ...
 }

Then check the args to see if the param 'runat' is set to 'server'.

If so, do the funky stuff, if not, just spit it out...




-- 
Paul Lindner
[EMAIL PROTECTED]
Red Hat Inc.



Re: Apache::ASP and Application_OnEnd

2000-08-01 Thread Paul Lindner

On Tue, Aug 01, 2000 at 02:23:50PM +0300, Alex Shnitman wrote:
 Hi,
 
 Is the Application_OnEnd called when the web server is shut down? (It
 doesn't look to me that way, but maybe it's a bug..) If it isn't, how
 can I schedule code to be called on server shutdown? (I need it in
 order to delete SysV IPC shared memory that I use via IPC::ShareLite
 in the Apache::ASP application.)

Application_OnEnd is called when the last active session is disposed
of.  So no, it does not get run on server shutdown.

-- 
Paul Lindner
[EMAIL PROTECTED]
Red Hat Inc.



Re: Apache::ASP+

2000-07-20 Thread Paul Lindner

On Thu, Jul 20, 2000 at 03:10:15PM +0800, Kenneth Lee wrote:
 Hi all!
 
 Any one started to make one? It seems a good idea. Of coz it's not simple 
 to build the whole complex platform (NGWS), but the concept of server-side 
 object and the event driven model is too interesting to me.

Actually I think that Apache::ASP is coming right along with it's
support of XML and the underlying behaviors.

I'm not well versed in Microsoft's Next Generation Windows System
(NGWS) but would appreciate hearing more about how it differs from
some of the latest Apache::ASP enhancements.

-- 
Paul Lindner
[EMAIL PROTECTED]
Red Hat Inc.



Re: Apache::ASP and HEAD

2000-07-05 Thread Paul Lindner

On Wed, Jul 05, 2000 at 12:51:07PM -0700, Dmitry Beransky wrote:
 Hi,
 
 I remember seen the answer to this some time ago (I may have even asked 
 this myself), but I couldn't find it in the archives.  Can anyone remind me 
 why Apache::ASP includes a message body in reply to a HEAD request?

Probably because it is just running your script.  You need to check
the REQUEST_METHOD variable and branch accordingly.

Same goes for the If-Modified header.

I find the resources at http://www.web-caching.com/ a must read for
anyone doing CGI applications.

-- 
Paul Lindner
[EMAIL PROTECTED]
Red Hat Inc.



Re: Coldfusion vs. apache/mod_perl

2000-07-05 Thread Paul Lindner

On Wed, Jul 05, 2000 at 04:30:01PM -0500, [EMAIL PROTECTED] wrote:
 I just left a company that used either mod_perl or coldfusion for our intranet
 development. I never did any coldfusion development but I did have to deal with
 maintaing the coldfusion server and apps. 
 
 coldfusion crashed several times in the three or four months I was involved
 with it. We never could determine what the problem was. 
 
 coldfusion (like Apache/mod_perl) eats memory. Our coldfusion processes usually
 used a total of 200MB of memory.
 
 coldfusion does not play well on unix (at least solaris). Allaire's site
 recommended changing some kernel parameters to get the best performance out of
 cold fusion. That was something we weren't willing to do on a box that had much
 more than CF running on it.
 
 To my knowledge, CF does not give you the power to mess with the web servers
 API like mod_perl does. You may or may not need this ability.
 
 IMHO, mod_perl applications easily out-performed our CF apps.
 
 One plus for coldfusion, there seems to be more CF developers out there (at
 least in Austin, TX) but that may be a sign that very few people are using CF.
 
 My opinion: stick to mod_perl, it won't let you down.

I've been toying with using the Apache::ASP custom tag feature to
support cold-fusion like applications.  I don't think it will be too
hard; reading the spec it appears you need to make a list of named
queries and then use cfoutput tags with #fieldname# entries.

This is absurdly simple with Joshua's new Apache::ASP.  Just define
cfoutput as a custom tag, and write a small handler for it.

I'll have to look up the other tags they support, but they shouldn't
be too hard to implement...

Has anyone else out there wrote their own cold-fusion routines?

-- 
Paul Lindner
[EMAIL PROTECTED]
Red Hat Inc.



Re: Coldfusion vs. apache/mod_perl

2000-07-05 Thread Paul Lindner

On Wed, Jul 05, 2000 at 04:09:06PM -0700, Joshua Chamas wrote:
 Paul Lindner wrote:
  
   IMHO, mod_perl applications easily out-performed our CF apps.
  
   One plus for coldfusion, there seems to be more CF developers out there (at
   least in Austin, TX) but that may be a sign that very few people are using CF.
  
   My opinion: stick to mod_perl, it won't let you down.
  
  I've been toying with using the Apache::ASP custom tag feature to
  support cold-fusion like applications.  I don't think it will be too
  hard; reading the spec it appears you need to make a list of named
  queries and then use cfoutput tags with #fieldname# entries.
  
  This is absurdly simple with Joshua's new Apache::ASP.  Just define
  cfoutput as a custom tag, and write a small handler for it.
  
  I'll have to look up the other tags they support, but they shouldn't
  be too hard to implement...
  
  Has anyone else out there wrote their own cold-fusion routines?
  
 
 Hey Paul,
 
 I think you will have a problem with cold fusion templating
 logic like if/else constructs.  For these, I would recommend
 having something like a ColdFusionCompat config setting, and we 
 could rip out some of these are parse time and convert them into the 
 ASP style constructs.

One idea is to have a separate class of tags that are used in the
parse stage.:

  CodeTags (cfif|cfelse|cfend)

  sub cfend {
return('}');
  }

  sub cfelse {
return('} else {');
  }

  sub cfif {
. # heavy lifting here..
return('if (..) {');
  }


 I am planning to use this approach for support of XSP logic
 for XML/XSLT integration, and can't see how to use the custom 
 tags for full logic implementations of other environments,
 particularly the if/else contructs.  Might there be some
 way to extend the XMLSubsMatch technology to coordinate 
 between multiple tags?
 
 I think what we need to is something like a Script_OnParse
 that one could use to grab the script data and parse it
 before the ASP to perl compiler gets to it.  This would 
 allow for some experimentation out of the code base before
 merging in something big like XSP or ColdFusion support.

That would definitely do the trick too.  Though instead I'd use
various regular expressions to convert tags into ASP syntax..

-- 
Paul Lindner
[EMAIL PROTECTED]
Red Hat Inc.



Re: [JOB] mod_perl engineers (all levels) at Red Hat - SF Bay Area

2000-06-22 Thread Paul Lindner

On Thu, Jun 22, 2000 at 05:01:41PM +0100, Matt Sergeant wrote:
 On Thu, 22 Jun 2000, Paul Lindner wrote:
 
 Web Technology: XML, XSLT and XML-RPC; Internationalization;
  Applications Servers (HTML::Mason, Embperl, Apache::ASP, Zope,
  Zentropa, Cocoon etc.); Search systems and concepts.
 
 Bah! You're missing AxKit from that list ;-)

You mean you're not happy with being lumped into 'etc..'  :-)

I'll make sure my next post has AxKit mentioned.  After all it is
really quite neat...


-- 
Paul Lindner
[EMAIL PROTECTED]
Red Hat Inc.



Re: stripping CRLF on the way out?

2000-06-22 Thread Paul Lindner

Try running HTML::Clean on your template, instead of using CPU for
every request to strip output.

I've done this with some success on a few projects..

Also, Apache::ASP users can activate HTML::Clean to post-process all
HTML output, which can result in 20-40% savings.

I read somewhere that 5 bytes is equivalent to 1ms on a 28.8
connection, so these types of optimizations are generally worth the
effort.

  -Original Message-
  From: Dave DeMaagd [mailto:[EMAIL PROTECTED]]
  Sent: Thursday, June 22, 2000 11:15 AM
  To: [EMAIL PROTECTED]
  Subject: stripping CRLF on the way out?
  
  
  Have an application that generates nicely formatted HTML (from
  templates, so that they can be easily edited), but since there's a
  awful lot of extra line breaks (and other things, like comments) that
  we'd like to strip out (save bandwidth), is there an easy way to do
  this via mod_perl, something like a PerlOutputHandler???  
  
  Something like this would be a far sight easier than having to rewrite
  all of the scripts to do this themselves...  
  
  Any advice would help greatly! 
  
  -- 
  Dave DeMaagd - [EMAIL PROTECTED] - http://www.spinynorm.net
  I don't have a solution, but I admire your problem.
  SysAdmin/Programmer - TheImageGroup - ===|:=P
  

-- 
Paul Lindner
[EMAIL PROTECTED]
Red Hat Inc.



Re: Apache::ASP on Unix

2000-06-14 Thread Paul Lindner

On Wed, Jun 14, 2000 at 02:36:44PM -0300, Marcelo Souza wrote:
 Hi,
 
   Does anyone is using this module?

Many are..

   Is it full compatible with IIS for asp pages?

No.  It does not use visual basic.  It uses Perl.  Otherwise, all of
the same concepts are there: Application, Session, Request and
Response objects, etc.

   And what about security, is there any issue?

What issues?

-- 
Paul Lindner
[EMAIL PROTECTED]
Red Hat Inc.



Re: DBD::Oracle Apache::DBI

2000-05-22 Thread Paul Lindner

We had some strange connection problems like this before.  Our most
common error was about the 'hostdef extension not found'..

We found that we could get around this by using fully qualified oracle
database connection identifiers, instead of using the entry that
appears in tnsnames.ora, for example:

  dbi:Oracle:web  becomes something like this
  dbi:Oracle:(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=.. )))

It's worked like a champ since then...  I'm not sure why it works,
probably because I've removed a few layers of indirection..  Either
that or some environment variable is getting corrupted..


On Mon, May 22, 2000 at 06:36:54PM -0700, Ian Kallen wrote:
 
 I've done everything I can think of to shore up any DB connection
 flakiness but I'm still plagued by errors such as these:
 DBD::Oracle::db selectcol_arrayref failed: ORA-12571: TNS:packet writer
 failure 
 ...this is only a problem under mod_perl, outside of the
 mod_perl/Apache::DBI environment everything seems fine.  Once the db
 connection is in this state, it's useless until the server gets a restart.
 
 My connect strings look good and agree, I put Stas' ping method in the
 DBD::Oracle::db package, set a low timeout,  called Oracle (they don't
 want to hear about it).  Everything is the latest versions of
 mod_perl/Apache/DBI/DBD::Oracle connecting to an Oracle 8.1.5 db on
 Solaris.  Is Apache::DBI not up to it?  (it looks simple enough)
 
 Maybe there's a better persistent connection method I should be looking
 at?
 
 --
 Salon Internethttp://www.salon.com/
   Manager, Software and Systems "Livin' La Vida Unix!"
 Ian Kallen [EMAIL PROTECTED] / AIM: iankallen / Fax: (415) 354-3326 

-- 
Paul Lindner
[EMAIL PROTECTED]
Red Hat Inc.
San Francisco, USA




Re: Session management moudle suggestions?

2000-05-08 Thread Paul Lindner

On Mon, May 08, 2000 at 11:41:39AM -0700, Stephen Zander wrote:
 
 I've avoided session management like the plague until now (intranets
 let you get away with that sort of thing :)) but rolling out web-based
 LDAP is forcing session management upon me.
 
 Other than Apache::Session what are my choices?  How well do any of
 these play with templating (Embperl, Mason et al)?

Apache::ASP has very nice session management capabilities.  IMHO The
best feature is the Session_OnEnd handler (you can define code that is
executed when the Session finishes.)  And it's templating is superb.

-- 
Paul Lindner
[EMAIL PROTECTED]
Red Hat Inc.



Re: Memory usage on reload and graceful -- still broken?

2000-04-21 Thread Paul Lindner

On Fri, Apr 21, 2000 at 11:28:18AM -0700, Joshua Chamas wrote:
 Doug MacEachern wrote:
  
   I have a static Solaris compilation, and have the same problems
   where the parent seems to grow by 1M each HUP.
  
  that's strange, do you have PerlFreshRestart On or some Perl sections?
  otherwise, kill -HUP with a static modperl is a noop.
 
 You got me!  I have Perl sections ... but I didn't know
 it was such a crime.  Pretty bizarre behavior if you ask me.

We don't have perl sections and it does still occur.  I will try
with a static version and see if that fixes the problem.

-- 
Paul Lindner
[EMAIL PROTECTED]
Red Hat Inc.