On 20 Jul 2012, at 11:45 AM, Alec Taylor wrote:
>
> On Sat, Jul 21, 2012 at 4:41 AM, Jonathan Lundell <[email protected]> wrote:
>> On 20 Jul 2012, at 11:38 AM, Alec Taylor wrote:
>>>
>>> I've got a system with users, groups and group-events.
>>>
>>> Preferably I would like the following routing schemes:
>>>
>>> localhost/groupSLUGhere/
>
> controllers/groups.py
>
>>> localhost/groupSLUGhere/eventIDhere
>
> controllers/events.py
>
>>> localhost/profile/usernameHere
>
> controllers/profile.py
>
>> Where do you want these URLs to route (in terms of controller/function)?
>
> Thanks for asking, please see above for inline reference.
One possibility. With the parametric router, combine groups and events into one
controller, and handle your first two cases in its default function. In that
case, the routed URL will be localhost/default/index/groupSLUG/eventID, where
the slug and ID would be in request.args. The default function would look at
request.args and dispatch to the appropriate internal functions. You'd need to
give the router a list of functions in the default controller.
For the profile URLs, either make profile a function in the default controller
(it'll be routed to localhost/default/profile/username, with username in
request.args), or if profile really needs to be a separate controller, provide
a list of its functions as well (in that case the functions item in the router
needs to be a dict).
The general idea is that the router needs to fill in a controller and function,
pushing your slugs &c to args.
>
>>>
>>> How would I go about setting this up?
>>>
>>> Currently the system is very fiddly, even for doing simple
>>> redirects... e.g.: I need to use `URL("", "groups")` rather than
>>> `URL("groups")`.
>>>
>>> Thanks for all suggestions,
>>>
>>> Alec Taylor
>>>
>>> FYI: I'll be open-sourcing this system following August 2
>
--