mod_perl module documentation

2002-06-18 Thread Rich Bowen

It has long frustrated me that there was no mod_perl module
documentation, in the style of the standard Apache module documentation.
I don't mean to bash the docs that are there - clearly, they are of
exceptional quality. But I wanted something like the standard module
docs.

So, rather than complaining, which would seem to be, at best, in poor
taste, given the quantity of stuff that folks like Stas have already
written, I've started on a mod_perl module doc, based on the Apache 2.0
module documentation XML template. You can see the first cut at
http://www.apacheadmin.com/mod_perl.html

I know, it is gravely lacking, and needs help. And I intend to do
something about that. But I have a few questions before I burn a lot of
time on that.

Where, if anywhere, should such a document go? Yeah, it can stay
where it is, but I would not think that anyone would think to look
there.

Has someone already done this, and I'm just missing it? I know that
there is similar information at
http://www.apacheref.com/ref/mod_perl.html but I was hesitant to steal
that wholesale. Besides, everyone should buy Ralf's book, and I don't
want to dilute that in any way. ;-)

Is there currently, or are there any plans for, a mod_perl
documentation cvs repository, where something like this could live?

Anyways, tell me what you think. I have the original XML, which is
vastly more useful than the HTML output, and would be glad to give that
to anyone that wants it.

-- 
CooperMcGregor, Inc.
Apache, Perl, and mod_perl
More #! for your $




Re: File upload example

2002-03-13 Thread Rich Bowen

On Wed, 13 Mar 2002, John Saylor wrote:

> Hi
>
> > On Tue, 12 Mar 2002, John Saylor wrote:
> > > I have found that some browsers put the file in the value matching
> > > the parameter name instead of putting a file upload object there.
>
> ( 02.03.12 18:36 -0500 ) Rich Bowen:
> > That's not really necessary, as Apache::Request does that for you.
>
> Maybe I was using an earlier version, but Apache::Request was NOT doing
> it for me, so that is why I needed to do this extra stuff.

OK. Nasty. I will check into this more carefully.

-- 
Rich Bowen
http://www.apacheadmin.com/
Apache Support and Training




Re: File upload example

2002-03-12 Thread Rich Bowen

On Tue, 12 Mar 2002, John Saylor wrote:

> Hi
>
> ( 02.03.12 06:57 -0500 ) Rich Bowen:
> > Comments welcome, YMMV, Caveat Emptor, and all that.
>
> I have found that some browsers put the file in the value matching the
> parameter name instead of putting a file upload object there. So your
> code should check the value to see if it is a path AND a one liner
> BEFORE trying to create the file upload object.

That's not really necessary, as Apache::Request does that for you. If
the upload method fails, then you won't get anything in the UPLOAD key.
The generic form handler does not know what field(s) in your form were
file upload forms, and so this method just lets you check the one key
(UPLOAD) and, if it is defined, then you know you got something.

Hopefully, *all* browsers put the file name in the parameter, since that
is the defined behavior. However, regardless of this, the file upload
object contains all the necessary information to reconstruct the file,
so you don't even have to look in that field.

-- 
Rich Bowen
Apache Administrators Handbook
ApacheAdmin.com




Re: File upload example

2002-03-12 Thread Rich Bowen

On Tue, 12 Mar 2002, Stas Bekman wrote:

> Rich Bowen wrote:
> > I am sure that this is a FAQ, but I had a very hard time finding
> > examples of code for doing file upload. I wanted to post this here in
> > order to have it in the permanent record so that other folks don't have
> > to spend days figuring this out.
>
> Great Rich! I think we can do better than just keeping it in the
> archive. How about adding it here?
> http://perl.apache.org/guide/snippets.html
> If you like the idea, can you please make it a complete section and send
> it to list/me and I'll add it to the guide? Thanks!

Absolutely. I will try to do that later this week.

-- 
http://www.CooperMcGregor.com/
Apache Support and Training




File upload example

2002-03-12 Thread Rich Bowen

I am sure that this is a FAQ, but I had a very hard time finding
examples of code for doing file upload. I wanted to post this here in
order to have it in the permanent record so that other folks don't have
to spend days figuring this out.

I have a generic form method which looks like:


sub form {
use Apache::Request;
my $r = Apache->request();
my $apr = Apache::Request->new($r);
my @keys = $apr->param;

my %form;
foreach my $key(@keys) {

my @value = $apr->param($key);
next unless scalar @value;

if ( @value > 1 ) {
$form{$key} = \@value;
  } else {
$form{$key} = $value[0];
}
}

my $upload = $apr->upload;
if ($upload) {
$form{UPLOAD} = $upload;
}

   return \%form;
}

And the explanation is thus. This function returns a hashref. The keys
of the hash are the names in your form. The values in the hash are the
values entered in those fields, with the exception that a multiple
select list with multiple things selected will return a listref. This is
the way that CGI_Lite, for example, handles things, and that is what I
was trying to be compatible with for my own legacy code. You can of
course change that if you have different conventions.

*If* your form contained a file upload element, (Don't forget to make
your form encoding="multiplar/form-data"  I always forget that.)
then $form{UPLOAD} will contain a file upload object, which you can
make calls back into.

For example:

my $form = Your::Class::form(); # Wherever you put this function
if (my $file = $form->{UPLOAD}) {
my $filename = $file->filename; # If you need the name

# And, if you want to save the file at $filelocation ...
open F, ">$filelocation";
my $filehandle = $file->fh;
while (my $d = <$filehandle>) {
print F $d;
}
close F;
}

That should give you the general idea of how this works. This lets you
have a generic form handler that does "normal" forms as well as file
upload forms, in mod_perl, without having to mess with CGI.pm (which I
saw a lot of people doing, and did not really understand very well) and
without having to do custom things when you have a file upload.

Comments welcome, YMMV, Caveat Emptor, and all that.

-- 
Rich Bowen
Apache Administrators Handbook
ApacheAdmin.com




Re: mod_perl training companies?

2002-03-12 Thread Rich Bowen

On Sat, 9 Mar 2002, Gabor Szabo wrote:

>
> On 2002.03.06 04:05 Stas Bekman wrote:
> > >
> > >>I'm compiling a list of companies giving mod_perl training for our new
> > >>mod_perl site. Currently I have only:
>
> Stats and others,
>
> I am keping a list of companies providing Perl training at
> http://www.perltraining.org/ organized based on the home country of
> the company. I'd be glad to add more companies and to mark those
> that provide mod_perl training.
>
> Rich,
> I have already added CooperMcGregor but I can add more description
> if you give me.

Cooper McGregor is located in Central Kentucky, and offers training in
Apache and mod_perl. In addition to our Ky. location, we also do on-site
training if desired. http://www.CooperMcGregor.com/

> Specifically we also do provide mod_perl training
> and we are based in Israel: http://www.pti.co.il/
>
> regards
> -- Gabor Szabo
>

-- 
Rich Bowen
CTO, Cooper McGregor




Re: mod_perl training companies?

2002-03-07 Thread Rich Bowen

On Wed, 6 Mar 2002, Stas Bekman wrote:

> Rich Bowen wrote:
> > On Tue, 5 Mar 2002, Stas Bekman wrote:
> >
> >
> >>I'm compiling a list of companies giving mod_perl training for our new
> >>mod_perl site. Currently I have only:
> >>
> >>http://training.gbdirect.co.uk/courses/linux/customized_and_bespoke.html
> >>
> >>If you know of other companies please send me the URL of the page
> >>advertising the mod_perl courses.
> >>
> >
> > My company, Cooper McGregor does a mod_perl training course. Our
> > training page is located at http://coopermcgregor.com/training/  The
> > course outline for the mod_perl course should be put up there today,
> > since, for some reason, the web site guy did not have a copy of it
> > before.
>
> Thanks Rich!
> I also forgot to ask you to tell me the covered regions. e.g. London
> only, UK only, Europe, World Wide... to help potential customers
> minimize their research efforts.

At the moment, it is mainly just me doing the training. I will, however
travel anywhere, so I suppose I would say that I am primarily based in
the US, but will do training world wide.

Our training facility is in central Kentucky, but we also do on-site at
customer locations.

-- 
http://www.CooperMcGregor.com/
Apache Support and Training




Re: mod_perl training companies?

2002-03-05 Thread Rich Bowen

On Tue, 5 Mar 2002, Stas Bekman wrote:

> I'm compiling a list of companies giving mod_perl training for our new
> mod_perl site. Currently I have only:
>
> http://training.gbdirect.co.uk/courses/linux/customized_and_bespoke.html
>
> If you know of other companies please send me the URL of the page
> advertising the mod_perl courses.

My company, Cooper McGregor does a mod_perl training course. Our
training page is located at http://coopermcgregor.com/training/  The
course outline for the mod_perl course should be put up there today,
since, for some reason, the web site guy did not have a copy of it
before.

-- 
http://www.CooperMcGregor.com/
Apache Support and Training