[web2py] Re: Virtual Field and sqlform.grid
I think, you need to delete the old session files of your application. I had the same problem. Am Mittwoch, 20. November 2013 19:26:23 UTC+1 schrieb Eduardo Cruz: Whe I use a table that has some a virtual field sqlform.grid does not works type 'exceptions.AttributeError' 'Row' object has no attribute 'unknown' and that happens only when the virtual field is uncommented def get_category_list(post): 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) ) what am I doing wrong? -- 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 web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: Virtual Field and sqlform.grid
Field.Virtual has a name attribute which has to be set: db.Post.category_list = Field.Virtual( 'category_list', lambda row: get_category_list(row.Post) ) Am Mittwoch, 20. November 2013 19:26:23 UTC+1 schrieb Eduardo Cruz: Whe I use a table that has some a virtual field sqlform.grid does not works type 'exceptions.AttributeError' 'Row' object has no attribute 'unknown' and that happens only when the virtual field is uncommented def get_category_list(post): 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) ) what am I doing wrong? -- 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 web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [web2py] Re: Virtual Field and sqlform.grid
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 web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [web2py] Re: Virtual Field and sqlform.grid
I does not work, sadly. 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 web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [web2py] Re: Virtual Field and sqlform.grid
What do you mean by does not work? Can you show a traceback? There should be no problem to returning lists. On Thursday, 21 November 2013 06:29:36 UTC-6, Eduardo Cruz wrote: I does not work, sadly. 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 web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [web2py] Re: Virtual Field and sqlform.grid
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 web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: Virtual Field and sqlform.grid
What version of web2py? On Thursday, November 21, 2013 5:26:23 AM UTC+11, Eduardo Cruz wrote: Whe I use a table that has some a virtual field sqlform.grid does not works type 'exceptions.AttributeError' 'Row' object has no attribute 'unknown' and that happens only when the virtual field is uncommented def get_category_list(post): 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) ) what am I doing wrong? -- 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 web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [web2py] Re: Virtual Field and sqlform.grid
Web2py Version 2.7.4-stable+timestamp.2013.10.14.15.16.29 On 20 November 2013 16:26, Tim Richardson t...@growthpath.com.au wrote: What version of web2py? On Thursday, November 21, 2013 5:26:23 AM UTC+11, Eduardo Cruz wrote: Whe I use a table that has some a virtual field sqlform.grid does not works type 'exceptions.AttributeError' 'Row' object has no attribute 'unknown' and that happens only when the virtual field is uncommented def get_category_list(post): 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) ) what am I doing wrong? -- 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 a topic in the Google Groups web2py-users group. To unsubscribe from this topic, visit https://groups.google.com/d/topic/web2py/tTWYuhhGr8I/unsubscribe. To unsubscribe from this group and all its topics, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- Eduardo Cruz - 829 775 4605 -- 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 web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [web2py] Re: Virtual Field and sqlform.grid
can you show how you make the grid? -- 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 web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [web2py] Re: Virtual Field and sqlform.grid
def posts(): grid = SQLFORM.grid(db.Post) return dict(grid=grid)Ingresar el código aquí... Sure. El miércoles, 20 de noviembre de 2013 17:49:33 UTC-4, Tim Richardson escribió: can you show how you make the grid? -- 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 web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [web2py] Re: Virtual Field and sqlform.grid
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 web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [web2py] Re: Virtual Field and sqlform.grid
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 web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.