modperl-modperl_strategy_inspired_by_the_cookbook

This is part of The Pile, a partial archive of some open source mailing lists and newsgroups.



Date: Tue, 19 Feb 2002 00:04:07 +0100
From: c.hauser@itassistance.ch
To: modperl@apache.org
Subject: mod_perl cookbook ... next steps

Yep! Thanks for the book, it just arrived Friday. So now I'm sitting
on something what I wanted to do since a long time:

Splitting all my logic in the PerlHandler into PerlInitHandler, PerlTransHandler,
PerlAuthzHandler, PerlHandler and PerlCleanupHandler.

I would catch user sessions in PerlInitHandler/PerlTransHandler,
store/check them in PerlAuthzHandler, where I would also set the
cookie, and close or refresh them in PerlCleanupHandler.

The content would be created by PerlHandler, where I use HTML::Mason.

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?

Question: Is this approach ok, to be said, normal?


BR Christian

===

Date: Mon, 18 Feb 2002 15:16:21 -0800
From: Paul Lindner <lindner@inuus.com>
To: Issac Goldstand <margol@beamartyr.net>
Cc: c.hauser@itassistance.ch, modperl@apache.org
Subject: Re: mod_perl cookbook ... next steps

On Thu, Feb 21, 2002 at 01:17:02AM +0200, Issac Goldstand wrote:
> c.hauser@itassistance.ch 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..

===

Date: Mon, 18 Feb 2002 17:41:57 -0600
From: Stephen Clouse <stephenc@theiqgroup.com>
To: IEEE Consulting <consulting@ieee.org>
Cc: modperl@apache.org
Subject: Re: mod_perl cookbook ... Where?

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Mon, Feb 18, 2002 at 06:31:15PM -0500, IEEE Consulting wrote:
> Where's the mod_perl Cookbook?

Grep your favorite bookstore for ISBN# 0672322404.

===
Date: Mon, 18 Feb 2002 19:20:50 -0500
From: Geoffrey Young <geoff@modperlcookbook.org>
To: IEEE Consulting <consulting@ieee.org>
Subject: Re: mod_perl cookbook ... Where?



IEEE Consulting wrote:

> Where's the mod_perl Cookbook?


you can find all types of information about the cookbook at

http://www.modperlcookbook.org/

including places to purchase it and the source code from the entire book.

===

Date: Mon, 18 Feb 2002 19:00:47 -0500
To: modperl@apache.org
From: Todd Finney <tfinney@boygenius.com>
Subject: Re: mod_perl cookbook ... next steps

At 06:04 PM 2/18/02, c.hauser@itassistance.ch wrote:
>I would catch user sessions in PerlInitHandler/PerlTransHandler,
>store/check them in PerlAuthzHandler, where I would also set the
>cookie, and close or refresh them in PerlCleanupHandler.

We do something similar, but we've segmented the process a little 
differently.

There's a PerlHeaderParserHandler that does most of the work.  It 
manages all the session stuff (using Apache::Session), and puts 
information from the session into pnotes, where the other handlers can 
get to it.

I'm not looking at it right now, but iirc it puts the userid, a list of 
groups of which the user is a member, an "is authenticated" flag, and a 
reference to the session handle into pnotes.   Then, the other handlers 
look at the bits that apply to them - the Auth handler just looks at 
the authenticated flag, the AuthZ  handler looks at the groups list, 
etc.  It's all configured via httpd.conf.

We use it behind a bunch of sites, and it seems to work just fine.   I 
like it because none of the handlers are more than a screen long.

Is there any demand for something like this?  I could put a package 
together if people are interested.

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

If you just want to be able to get at the session further down the 
chain, do something like this

          $r->pnotes('SESSION_HANDLE' => \%session );

somewhere early on.  It'll be there throughout the request.

I don't know if that's any more efficient just hitting the session 
whenever you need it, but it makes our lives slightly easier.

===



the rest of The Pile (a partial mailing list archive)

doom@kzsu.stanford.edu