Hi Sean,

Thanks for writing this up! This kind of posting is good for showing
off our strengths and weaknesses here...

On 11/5/05, Sean Cazzell <[EMAIL PROTECTED]> wrote:
> URL Mapping
>
> This one has to go to Django.  The regexp-based url mapping makes it
> easy to have beautiful, clean URLs in your app and to map them to any
> arbitrary function. Things like:
>
> http://www.example.com/blog/my_slug_here/
>
> You can do this sort of thing in TurboGears, it just isn't as easy.
> TurboGears uses CherryPy for a front end which really prefers options to
> be specified in get variables like
>
> http://www.example.com/blog?slug=my_slug_here

People don't realize this, but CherryPy's system is a lot more
flexible than people give it credit for, and I like how CP does not
require a separate configuration for URLs. Your example here can be
handled fairly simply:

class Blog:
    @turbogears.expose()
    def default(self, slug):
        ...do something...

class Root(controllers.Root):
    blog = Blog()

Also, CP 2.2 is going to add back positional parameters handling for
methods. There's a ticket open to do this in TurboGears, and I may
just do that as an interim measure until CP 2.2 is out. So, that adds
this option:

class Root(controllers.Root):
    @turbogears.expose()
    def blog(self, slug):
        ...do something...

This would actually allow either of these URLs to work:
/blog/slug

/blog?slug=slug

Kevin

Reply via email to