Mailing List Archive

Catalyst::Request is missing a function for initial/previous URI
When using a Catalyst action as ErrorDocument handler in Apache-mod_perl,
$c->req->uri does not give the URI the user typed in, but the one registered
as handler. This makes it impossible to for example use a 404 handler as
search shortcut.

The attached patch adds an "initial_uri" accessor to Catalyst::Request to give
access to that information. Please review and apply if everything's ok.

--
Markus Zimmermann
Re: Catalyst::Request is missing a function for initial/previous URI [ In reply to ]
On 17 Jul 2008, at 14:25, Markus Zimmermann wrote:

> When using a Catalyst action as ErrorDocument handler in Apache-
> mod_perl,
> $c->req->uri does not give the URI the user typed in, but the one
> registered
> as handler. This makes it impossible to for example use a 404
> handler as
> search shortcut.
>
> The attached patch adds an "initial_uri" accessor to
> Catalyst::Request to give
> access to that information. Please review and apply if everything's
> ok.

This looks reasonably sane to me, however:

1) There are no tests..
2) Shouldn't you do *something* with initial_uri in engines other
than Apache? Surely it should return something sane no matter what
engine you are using.. Otherwise you're not going to be able to
develop / test your application other than under Apache..

Cheers
t0m


_______________________________________________
Catalyst-dev mailing list
Catalyst-dev@lists.scsys.co.uk
http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst-dev
Re: Catalyst::Request is missing a function for initial/previous URI [ In reply to ]
On Thu, Jul 17, 2008 at 03:25:38PM +0200, Markus Zimmermann wrote:
> When using a Catalyst action as ErrorDocument handler in Apache-mod_perl,
> $c->req->uri does not give the URI the user typed in, but the one registered
> as handler. This makes it impossible to for example use a 404 handler as
> search shortcut.

What is the difference? Are you using a rewrite where a <Location> or
similar would have been better?

--
Matt S Trout Need help with your Catalyst or DBIx::Class project?
Technical Director http://www.shadowcat.co.uk/catalyst/
Shadowcat Systems Ltd. Want a managed development or deployment platform?
http://chainsawblues.vox.com/ http://www.shadowcat.co.uk/servers/

_______________________________________________
Catalyst-dev mailing list
Catalyst-dev@lists.scsys.co.uk
http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst-dev
Re: Catalyst::Request is missing a function for initial/previous URI [ In reply to ]
Am Sonntag, 20. Juli 2008 03:52:38 schrieb Matt S Trout:
> On Thu, Jul 17, 2008 at 03:25:38PM +0200, Markus Zimmermann wrote:
> > When using a Catalyst action as ErrorDocument handler in Apache-mod_perl,
> > $c->req->uri does not give the URI the user typed in, but the one
> > registered as handler. This makes it impossible to for example use a 404
> > handler as search shortcut.
>
> What is the difference? Are you using a rewrite where a <Location> or
> similar would have been better?

We are using something like this:

<LocationMatch ^/my/project.+$>
   ErrorDocument 404 /my/project/search
</LocationMatch>

If you make a request for "http://my.server.domain.com/my/project/projectname"
the search function should use "projectname" as search string.

--
Markus Zimmermann

_______________________________________________
Catalyst-dev mailing list
Catalyst-dev@lists.scsys.co.uk
http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst-dev
Re: Catalyst::Request is missing a function for initial/previous URI [ In reply to ]
On Mon, Jul 28, 2008 at 02:19:41PM +0200, Markus Zimmermann wrote:
> Am Sonntag, 20. Juli 2008 03:52:38 schrieb Matt S Trout:
> > On Thu, Jul 17, 2008 at 03:25:38PM +0200, Markus Zimmermann wrote:
> > > When using a Catalyst action as ErrorDocument handler in Apache-mod_perl,
> > > $c->req->uri does not give the URI the user typed in, but the one
> > > registered as handler. This makes it impossible to for example use a 404
> > > handler as search shortcut.
> >
> > What is the difference? Are you using a rewrite where a <Location> or
> > similar would have been better?
>
> We are using something like this:
>
> <LocationMatch ^/my/project.+$>
>    ErrorDocument 404 /my/project/search
> </LocationMatch>
>
> If you make a request for "http://my.server.domain.com/my/project/projectname"
> the search function should use "projectname" as search string.

Ok. So now I can see the need for the feature.

But obviously your patch can't be applied since it pollutes Catalyst::Request
with a mod_perl specific feature; if you can come up with a better API for
it and a patch with tests that only affects Catalys::Engine::Apache then
I'm sure andyg would be happy to review it and either apply or give feedback.

--
Matt S Trout Need help with your Catalyst or DBIx::Class project?
Technical Director http://www.shadowcat.co.uk/catalyst/
Shadowcat Systems Ltd. Want a managed development or deployment platform?
http://chainsawblues.vox.com/ http://www.shadowcat.co.uk/servers/

_______________________________________________
Catalyst-dev mailing list
Catalyst-dev@lists.scsys.co.uk
http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst-dev
Re: Catalyst::Request is missing a function for initial/previous URI [ In reply to ]
* Markus Zimmermann <markus.zimmermann@atikon.com> [2008-07-17 15:25]:
> + if ($self->apache->prev) {
> + my $prev = $self->apache->prev;

As an aside, this is much more nicely written like this:

if (my $prev = $self->apache->prev) {

--
*AUTOLOAD=*_;sub _{s/(.*)::(.*)/print$2,(",$\/"," ")[defined wantarray]/e;$1}
&Just->another->Perl->hack;
#Aristotle Pagaltzis // <http://plasmasturm.org/>

_______________________________________________
Catalyst-dev mailing list
Catalyst-dev@lists.scsys.co.uk
http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst-dev