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?
Thanks for your patience,
Alec Taylor
>>
>> Here's an extremely simplified version of my tables (if that's of help):
>>
>> db.define_table(
>> 'group_of_events',
>> Field('group_name', notnull=True, requires=[IS_NOT_IN_DB(db,
>> 'group_of_events.group_name'), IS_SLUG()]),
>> format='%(group_name)s'
>> )
>>
>> db.define_table(
>> 'event',
>> Field('event_name', notnull=True),
>> Field('group_id', 'reference db.group_of_events', notnull=True,
>> requires=IS_IN_DB(db, db.group_of_events, '%(group_name)s')),
>> format='%(event_name)s'
>> )
>>
>>
>> On Sat, Jul 21, 2012 at 5:03 AM, Bruno Rocha <[email protected]> wrote:
>>> I dont know if it is a bug or feature (but I like it), you can do it in
>>> models!
>>>
>>> models/0_routing.py
>>>
>>> if request.controller in MYLISTOFGROUPS:
>>> groupslug = str(request.controller) # here you can use deep copy or just
>>> str()
>>> request.controller = 'group'
>>> request.function = 'show'
>>> request.args[0] = groupslug
>>>
>>>
>>> controllers/group.py
>>>
>>> def show()
>>> group = db(db.groups.slug==request.args(0)).select()
>>> return dict(group=group)
>>>
>>
>
>
> --
>
>
>
--