Hi, I have the same problem.
I defined the following tables:

db.define_table('t_questions',
    Field('f_question', type='text', label=T('Question')),
    Field('f_question_number', type='integer', label=T('Question number')),
    Field('f_lecture', type='reference t_activities', label=T('Lecture')),
    auth.signature, format='%(f_question)s',
    plural="Questions",
    migrate=settings.migrate)

db.define_table('t_answers',
    Field('f_question', type='reference t_questions', label=T('Question')),
    Field('f_option', type='string', label=T('Option')),
    Field('f_points', type='integer', label=T('Points')),
    Field('f_iscorrect', type='boolean', label=T('Is Correct')),
    auth.signature, format='%(f_option)s',
    plural="Answers",
    migrate=settings.migrate)

and then defined the smartgrid:

questions = SQLFORM.smartgrid(db.t_questions, linked_tables=['t_answers'],
    fields = dict(t_questions =(db.t_questions.f_question_number, 
db.t_questions.f_lecture, db.t_questions.f_question)),
    field_id = (db.t_questions.id),
    orderby = dict(t_questions = 
[db.t_questions.f_lecture|db.t_questions.f_question_number]),#|db.t_questions.f_question_number,
    csv = False,
    deletable = True,
    editable = True,
    create = True,
    paginate=100 
    )

When the smartgrid is displayed I click on edit a question, then in the 
edit page I click on "Answers", it shows the anwers for that question and 
when I click in "View "Edit" or "Delete" it gives me an error: 

AttributeError: 'Row' object has no attribute 'f_option'


That's because those buttons make reference to: 
https://mysite/app/controller/questions/t_questions/t_answers.f_question/6/view/
t_questions/14?_signature=c93a35518f7922dd8e85a6b1dace5b797eb5a394

which is wrong as it must be "t_answers/14"

Any idea?

Thank you very much.
Regards






On Wednesday, May 15, 2013 10:47:53 PM UTC+2, bapster wrote:
>
> *Running on latest web2py v2.4.6 from trunk (but also occurs in Version 
> 2.4.6-stable+timestamp.2013.04.06.17.37.38).*
>
> When traversing linked tables with a smartgrid, the breadcrumbs code in 
> sqlhtml.py is causing an error, due to a mixup of the table/record 
> association.
>
> The problem is easily duplicated by creating a new app with the wizard:
>
>    1. Define table: car_type
>       - Field: desc string
>    2. Define table: car
>       - Field: name string
>       - Field: car_type_id *reference* car_type
>    3. Run the application.
>    4. Click the "Car Type" menu link, which invokes SQLFORM.smartgrid for 
>    the car_type table.
>    5. In the car_type grid, on one of the records, click the "T cars" 
>    link. This pulls up a grid for the cars table, filtered for the selected 
>    car_type.
>    6. In the car grid, click one of the "Car Type Id" links.
>       - This will result in the error: <type 'exceptions.AttributeError'> 
>       'Row' object has no attribute 'f_name'
>    
> Causing this error is a call to format() in the breadcrumbs code of 
> sqlhtml.py, line 2662. The table argument being referenced for the format 
> string is *car*, but the row argument is a *car_type* record.
>
> Note that I've been working around this issue by specifying my 
> define_table format argument like this (hack):
>     format=lambda r: r.get('f_name') or ('#' + str(r.id))
>

-- 

--- 
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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to