Ello,

On 29 May 2002, Randal L. Schwartz wrote:

> >>>>> "Rafiq" == Rafiq Ismail (ADMIN) <[EMAIL PROTECTED]>
writes:
> Rafiq> Is there a neat way of dynamically loading in the appropriate
control
> Rafiq> subclass?  Something proven and widely used.
>
> Load the file with a require, and then just call the appropriate
> constructor using an indirect call:
>
>         require "My/Prefix/$type"; # presuming $type has no colons
>         $myClass = "My::Prefix::$type";
>         my $handler = $myClass->new(@parms);
>
> This works even in "use strict".

Thanks.  This is pretty much the handler which I'd previously written,
with the the exception of s/use/require/.  I'll probably either go with
Apache::Dispatch, using the DispatchRequire option, or write something
custom.


On Wed, 29 May 2002, Perrin Harkins wrote:
> So, you're asking how to map URLs to perl modules?  Is there some reason
> you aren't simply using httpd.conf or Apache::Dispatch?  In my last MVC

I just took a look at Apache::Dispatch and I get he impression that if I
were to use it then I would have to either PerlModule 'all' my subclasses
beforehand, or alternateively use the DispatchRequire option anyway.  I'm
already using StatINC so I'm going to have to do a toss between code which
I've already written and converging to the Apache::Dispatch interface.

I'm not so keen on loading all the inheriting classes into memory
beforehand, nor setting up multiple handlers for each location.  It's a
fairly large site and my main concern was to do with how I should store
the correspondence from uri to object.


> design, we had all of our controllers inherit from one base controller
> that held all of the common code.

I could just map from URLs to the specific control subclasses and then use
Dispatch to require them - I'd already started on writing a mapping from
path names to relative namespaces.  I was still 'eval/use'ing the
Modules though.

How does StatINC behave with 'required' packages?

Hmm.. it's "make your mind up time. ;)


Thanks for the tips.
Cheers,

Fiq

__
"__  __           _                 __  __
|  \/  | ___   __| | ___ _ __ _ __ |  \/  | __ _ _ __
| |\/| |/ _ \ / _` |/ _ \ '__| '_ \| |\/| |/ _` | '_ \
| |  | | (_) | (_| |  __/ |  | | | | |  | | (_| | | | |
|_|  |_|\___/ \__,_|\___|_|  |_| |_|_|  |_|\__,_|_| |_|
        a pathetic example of his organic heritage"
                - Bad Religion

Reply via email to