[Twisted-web] Question about url rewriting

Christopher Armstrong radix at twistedmatrix.com
Fri Oct 13 14:33:16 CDT 2006

On 10/13/06, Gordon Scott <gscott2112 at gmail.com> wrote:
> An example might be
>  http://someserver.com/images/600x800/watermark/file_a.png
> where 600x800 and watermark are file parameters
> since obviously I won't have '600x800', 'watermark', and 'file_a.png' as
> resources I either need to stop processing with the 'image' resource,  or

Well, it's not *necessarily* a bad idea to make individual resources
for each of those segments. It can often make sense to make a resource
which only manages children.

However, if you do want to handle all of those parameters at once,
then override locateChild on your "images" resource. It will be passed
a context (probably soon to become a request) and segments. The
segments will be a tuple like ("600x800", "watermark", "file_a.png").
Then locateChild should "return imageResource, ()", where () means
"there should be no further processing of segments".

Christopher Armstrong
International Man of Twistery

More information about the Twisted-web mailing list