<type 'exceptions.AttributeError'> 'Row' object has no attribute 'unknown'
Version web2py™ Version 2.7.4-stable+timestamp.2013.10.14.15.16.29
Traceback
Traceback (most recent call last):
File "/home/eduardo/PycharmProjects/gblog/web2py/gluon/restricted.py", line
217, in restricted
exec ccode in environment
File
"/home/eduardo/PycharmProjects/gblog/web2py/applications/gblog/controllers/admin.py"
<http://127.0.0.1:8000/admin/default/edit/gblog/controllers/admin.py>, line
19, in <module>
File "/home/eduardo/PycharmProjects/gblog/web2py/gluon/globals.py", line 372,
in <lambda>
self._caller = lambda f: f()
File
"/home/eduardo/PycharmProjects/gblog/web2py/applications/gblog/controllers/admin.py"
<http://127.0.0.1:8000/admin/default/edit/gblog/controllers/admin.py>, line
13, in posts
grid = SQLFORM.grid(db.Post)
File "/home/eduardo/PycharmProjects/gblog/web2py/gluon/sqlhtml.py", line
2374, in grid
value = row[str(field)]
File "/home/eduardo/PycharmProjects/gblog/web2py/gluon/dal.py", line 7062, in
__getitem__
raise ae
AttributeError: 'Row' object has no attribute 'unknown'
it only fails with sqlgrid, Im using that field in another view and works
flawlessly.
db.y
timestamp = db.Table(db, 'timestamp',
Field('created_on', 'datetime', default=request.now,writable
=False, readable=False),
Field('created_by', db.auth_user,
default=auth.user_id,writable
=False, readable=False),
Field('updated_on', 'datetime', update=request.now,writable
=False, readable=False),
Field('updated_by', db.auth_user,
update=auth.user_id,writable
=False, readable=False))
db.define_table("Post",
Field("title", label="Title"),
Field("body", "text", label="Content"),
timestamp
)
db.define_table("Comment",
Field("author", default="anonymous", label="Author"),
Field("body", label="Content"),
Field("post_id", "reference Post", writable=False, readable=
False),
timestamp
)
db.define_table("Category",
Field("title", label="Title"),
Field("parent_id", "reference Category", default=None),
timestamp
)
db.define_table("Post_in_category",
Field("post_id", "reference Post"),
Field("category_id", "reference Category"),
timestamp
)
def get_category_list(post_id):
category_id_list = db(db.Post_in_category.post_id == post_id).select(db
.Post_in_category.category_id)
category_list = []
for category_id in category_id_list:
category_list.append(db.Category[category_id["category_id"]])
return category_list
db.Post.category_list = Field.Virtual(
lambda row: get_category_list(row.Post.id)
)
On Friday, November 22, 2013 12:37:18 AM UTC-4, Tim Richardson wrote:
>
>
>
> On Thursday, November 21, 2013 11:29:36 PM UTC+11, Eduardo Cruz wrote:
>>
>> I does not work, sadly.
>>
>
> Where does it fail?
>
> is the id passed to the function ok?
>
>
>
>
>> On Wednesday, November 20, 2013 6:52:56 PM UTC-4, Tim Richardson wrote:
>>>
>>> Also, my experience with virtual fields is limited to returning
>>> non-iterable types, not lists.
>>>
>>> On Thursday, November 21, 2013 9:48:57 AM UTC+11, Tim Richardson wrote:
>>>>
>>>> I can't see what's wrong.
>>>> Why don't you simply pass the id
>>>> (ie lambda row: get_category_list(row.Post.id)
>>>>
>>>>>
>>>>
>>>> and then use breakpoints to see if that is working as you expect
>>>>
>>>
--
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/groups/opt_out.