Is that the exact code, because you didn't change to args=row.id, and your
second select is still missing the "id" field?
Anthony
On Friday, March 6, 2015 at 2:23:48 PM UTC-5, Oliver Holloway wrote:
>
> Added sessions.id to the select, same thing. Here's the table definition
> and the controller. The id does show up on the view page, but isn't passing
> as an arg.
>
> db.define_table('sessions',
> Field('program_name', 'string', requires=IS_IN_DB(db,
> db.programs.program_name)),
> Field('session_type', 'string',
> requires=IS_IN_SET(['practice', 'evaluation'], zero=None)),
> Field('session_number', 'integer', default=1), # this is
> the session number by program, using 0 for evaluations
> Field('coach', 'string'),
> Field('assistant', 'string'),
> Field('session_date_time', 'datetime'),
> Field('session_name', compute = lambda row:
> row.program_name + ', ' + row.session_type + ' ' + str(row.session_number))
> )
>
> db.sessions.session_name.represent = lambda session_name, row:
> A(row.session_name, _href=URL('demo', 'tests_for_this_eval', args=
> db.sessions.id))
>
> @auth.requires_membership('coach')
> def show_list_of_sessions():
> # get list of evaluations
> evaluations = SQLTABLE(db(db.sessions.session_type=='evaluation').select(
> db.sessions.id, db.sessions.session_name),
> headers=None, truncate=128
> )
>
> # get list of practices
> practices =
> SQLTABLE(db(db.sessions.session_type=='practice').select(db.sessions.session_name),
> headers=None, truncate=128
> )
>
> return dict(evaluations=evaluations, practices=practices)
>
>
>
> On Friday, March 6, 2015 at 2:16:27 PM UTC-5, Anthony wrote:
>>
>>
>>
>> On Friday, March 6, 2015 at 2:02:57 PM UTC-5, Leonel Câmara wrote:
>>>
>>> you need to write row.sessions.id
>>>
>>> You always need to be explicit in represents.
>>>
>>
>> You need to be explicit in virtual fields (i.e., include the table name),
>> but I don't think that is the case with represent. I think the problem here
>> is that in the select, the "id" field is not included, so therefore not
>> available when the represent function is called. Try changing it to:
>>
>> .select(db.sessions.id, db.sessions.session_name)
>>
>> Anthony
>>
>
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.