Re: Advice needed on custom webapp framework

[prev] [thread] [next] [Date index for 2004/11/17]

From: Michael Schout
Subject: Re: Advice needed on custom webapp framework
Date: 17:11 on 17 Nov 2004
On Wed, 17 Nov 2004, jonathan vanasco wrote:

> Ideally, I would have the packages  in Website and WebAppFramework
> lookup the right DB for the Website

There are many ways to solve this problem.  I'll show you 2 ways.  I'll
focus just on the database part to keep this as short as possible, but
the same ideas apply to the user object...

One way is to put the databse in a separate package and access it
using static methods.

e.g.:

my $dbh = Website::Database->dbh;

You could even make this a method of WebAppFramework.  Then you are
simply left with the problem of getting the right database handle for
each website.  There are many ways to do that.  One way would be to just
have a hash or something in WebAppFramework that stores the database
handles for each partuclar website, and then have your dbh() (or
whatever you decide to call it) method figure out which handle to
retrieve.  The downside is that you have to modify WebAppFramework
everytime you create a new application (or, create methods for managing
the datbase hash, and call them from within your appliaction). If you
don't want to do it that way, another way would be to simply subclass
WebAppFramework for each site, and then have the individual appliactions
subclass it.  e.g.:

package WebAppFrameWork::SomeSite;

use base 'WebAppFrameWork';

sub dbh {
    # return database appropriate for "SomeSite"
}
...
__END__

package WebApp::SomeSite::SomeApp;

use base 'WebAppFrameWork::SomeSite';

# calling $self->dbh in here calls WebAppFrameWork::SomeSite->dbh
# plus you can call any methods provided by WebAppFrameWork
...

__END__

Regards,
Michael Schout

        -- 
        Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html

Advice needed on custom webapp framework
jonathan vanasco 14:15 on 17 Nov 2004

Re: Advice needed on custom webapp framework
Michael Schout 17:11 on 17 Nov 2004

Re: Advice needed on custom webapp framework
Jonathan Vanasco 18:07 on 17 Nov 2004

Re: Advice needed on custom webapp framework
Tom Schindl 19:26 on 17 Nov 2004

Re: Advice needed on custom webapp framework
Jonathan Vanasco 19:32 on 17 Nov 2004

Re: Advice needed on custom webapp framework
Tom Schindl 18:25 on 17 Nov 2004

Re: Advice needed on custom webapp framework
Jonathan Vanasco 18:39 on 17 Nov 2004

Generated at 11:26 on 21 Dec 2004 by mariachi v0.52