On 20 Jul 2012, at 12:19 PM, Alec Taylor wrote:
>
> On Sat, Jul 21, 2012 at 5:15 AM, Jonathan Lundell <[email protected]> wrote:
>> On 20 Jul 2012, at 12:11 PM, Alec Taylor wrote:
>>>
>>> Thanks, but I'm a little uncertain how to get the list of groups, I
>>> tried `if request.controller in
>>> db(db.group_of_events).select(orderby=db.group_of_events.group_name)`,
>>> but that didn't work.
>>
>> You need to specify a field in the select, before the orderby.
>>
>> But that's a lot of overhead to incur on every request. Better to check for
>> known controllers instead.
>
> Your probably right. Also, I seem to be getting error after error
> after choosing `ALL`.
>
> I'll try your method tomorrow (it's past 5AM here).
>
> Would you be able to elaborate on your method, perhaps referencing
> documentation? - I was having trouble finding documentation before Mr
> Rocha suggested his technique... would you be able to present a small
> code sample otherwise?
Have a look at router.example.py; there's also some explanatory material in the
book. If that's not clear, I can help you create a router.
I use the model-based scheme myself for some purposes, and it's fairly simple.
If you want all three of your controllers, you'd want to do something like:
if request.controller in ('profile', 'default', 'appadmin', 'group', 'event'):
handle the known controllers
elif request.function == 'index': # if the incoming URL had no
'function', and web2py filled in the default function
request.args[0] = request.controller
request.controller = 'group'
else
request.args[0] = request.controller
request.args[1] = request.function
request.controller = 'event'
>
> Thanks for your patience,
--