[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [cgiapp] a question about urls mapping to the project directory layout


Thilo Planz wrote:
Having said that, if you wanted to "redirect" to a new $webapp object, something like this could work:

    $self->header_type('none');
    my $app = new AdminWebApp( QUERY => $self->query );
    $app->run;
    return '';

But I really think, this (dispatching between functionality) is what run modes are for.
Is anyone doing this?

This is basically what CGI::Application::Dispatch does. It looks at the PATH_INFO, creates the object and then run()'s it. It does provide a hook so that you can customize the PATH_INFO to module name translation before the dispatch. If you wanted to, I bet that would be an easy place to do what punkish is asking for.

I know you didn't want to use C::A::Dispatch just yet, but here's how you might go about that for this case...

+ create your own dispatch class using C::A::Dispatch as your base
+ override the get_module_name() method
+ if the path_info translates into Module::Name look to see if they are
   a public/admin, etc (using a cookie, etc)
+ change the module name to be Public::Module::Name or
  Admin::Module::Name, etc


The benefits of doing it like this are that you can still encapsulate the functionality for one type of user into a module, but you url's would be the same. And you would only need it one place and it would work under vanilla cgi or mod_perl.

Just some more ideas.

--
Michael Peters
Developer
Plus Three, LP


---------------------------------------------------------------------
Web Archive:  http://www.mail-archive.com/suppressed/
             http://marc.theaimsgroup.com/?l=cgiapp&r=1&w=2
To unsubscribe, e-mail: suppressed
For additional commands, e-mail: suppressed


Mail converted by mhonarc 2.6.15
This archive provided courtesy of JSW4.NET, Internet Hosting Services for Small Business.