On Wed, Feb 1, 2012 at 6:04 AM, Benjamin Hepp
<[email protected]> wrote:
> Thanks for this, that was exactly what I needed.
>
> If anyone is interested, I put it on PYPI even though it's not much:
> http://pypi.python.org/pypi/pyramid_rewrite/0.1
>
> I find it especially useful to deal with the favicon issue (I find it quite
> weird to write an extra view for some static content).
That's nifty. It solves the biggest problem in static_view. it would
also be useful in older apps that undergo URL reorganization.
>
> Cheers,
> Benjamin
>
>
>
> On 02/01/2012 02:05 PM, Chris McDonough wrote:
>
> On Wed, 2012-02-01 at 14:00 +0100, Benjamin Hepp wrote:
>
> Hi,
>
> as I already wrote I'm interested in being able to rewrite URLs before
> the resource lookup starts. I thought about doing this as a tween. From
> looking at the code I think it should be enough to change the path
> attribute of the request (I'm also changing url and path_qs and
> path_url). Now I realized that I can't overwrite the values of path (and
> url, path_qs etc.). What would be the proper way to do this? Configure a
> request factory overwriting these attributes? Or create a new request
> within the tween cloning from the original request? How would you do
> this in a clean way?
>
> Any help or advice is very appreciated :)
>
> If this needs to happen on every request, a NewRequest event subscriber
> is probably the way to go. And you can either just change
> request.path_info and/or request.script_name or you can use
> request.path_info_pop/request.path_info_peek to help you do that. Once
> you change path_info and script_name, path_qs, path_url, and url should
> be derived from your changed values. Traversal uses path_info
> exclusively to do resource lookup, FWIW.
>
> - C
>
>
> Cheers,
> Benjamin
>
> On 01/25/2012 11:25 AM, benjamin.hepp wrote:
>
> Hi,
>
> I have a traversal based application with users and galleries etc. A
> typical URL would be
> /<username>/gallery/<category>
>
> Now I would also like to serve some content of a default user under
> /gallery/<category>
>
> I was wondering wether this is possible with combining traversal and
> URL dispatch but I think it is not. I also don't want to change my
> resource tree.
>
> So is there a possibility to achieve this without using a special URL
> dispatch route and redirecting with HTTPFound (I somehow feel that
> it's a waste of resources to just redirect all the time).
>
> If there is no good way to achieve this I thought about writing an
> extension to provide some "URL-rewrite" mechanism like this
>
> config.add_rewrite_rule('gallery/*rest',
> '<default_username>/gallery/%(rest)s')
>
> or so.
>
> Cheers,
> Benjamin
>
>
>
--
Mike Orr <[email protected]>
--
You received this message because you are subscribed to the Google Groups
"pylons-discuss" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/pylons-discuss?hl=en.