[Chicago] Pylons/Groovie Routes Help

Ian Bicking ianb at colorstudy.com
Wed Apr 30 05:08:54 CEST 2008


Daniel Griffin wrote:
> Hi, 
> 
> I have been working on Pylons for a while now and have run into 1 
> serious issue. I cannot figure out Routes. Can someone help me figure 
> out routes for the following?
> 
> users pk - username
> - view(no key needed)
> - new/edit/delete(key needed)
> - find jobs for this user
> 
> jobs - pk is batch + job + date entered
> - view(no key needed)
> - new/edit/delete(key needed)
> - assorted other stuff
> 
> quickview 
>  - summary view(no key needed)
> 
> I dont really have a routes file to post since it is entirely broken, 
> the keys cannot be changed and eventually there will be many entries 
> needed. When I started and only had users the following worked
> 
>     map.connect(':controller/:action/:id')
>     map.connect(':controller/:action/:name', 
> controller='gecsuser',action='list')
>     map.connect(':name', controller='gecsuser', action='list', name='Dan')
> 
> when I added
> 
>   map.connect(':controller/:action/:jobnum/:batch/:submitted', 
> controller='gecsjob',action='index')
>     map.connect(':jobnum', controller='gecsjob', action='index', 
> jobnum='job')
>     map.connect(':batch', controller='gecsjob', action='index', batch='job')
>     map.connect(':submitted', controller='gecsjob', action='index', 
> submitted='9999-12-31 23:59:59')
> 
> everything broke. How do I make this work?

Those routes you setup are ambiguous, I think.  ":batch" is just a 
variable.  By doing batch="job" in that connection you'll just set the 
default for that variable -- but any (single-segment) URL will match 
that pattern and overwrite the default.  Since you have three 
connections like that, they all overlap.

Maybe you want to do:

   map.connect('/job', controller='gecsjob', actino='index', batch='job')

or something like that...?  I'm not sure what URL layout you want.

-- 
Ian Bicking : ianb at colorstudy.com : http://blog.ianbicking.org


More information about the Chicago mailing list