Trying to use Field.represent for 'blob' type in SQLFORM.grid (works in appadmin?)

82 views
Skip to first unread message

Jordan Myers

unread,
Mar 20, 2017, 2:52:53 PM3/20/17
to web2py-users
Hello,

I am trying to display a Field that has type 'blob' in a SQLFORM.grid. The data is NOT user-uploaded, thus I cannot use the typical uploadfield + request.download pattern. I am using blob because I need to store important algorithm-generated data that is too large to fit in the 'text' field type. I would like it to display a link to a handler.

I tried a simple test case model

db.define_table('blob_test',
Field('blob_field', 'blob', readable=True,
represent=lambda value, row: A('link', _href=URL('handler', args=[row.id]))
)
)

#and in the controller:
def blob_grid():
response.view = 'generic.html'
grid = SQLFORM.grid(db.blob_test.id > 0)
return dict(grid=grid)

The result is that the controller does not display the link, and indeed the entire column is overtaken by the default view/edit/delete buttons provided by grid.


Interestingly, the appadmin display of the table does have the represent link as intended. 




How can I have this representation work for SQLFORM.grid? Thanks.

Massimo Di Pierro

unread,
Mar 20, 2017, 5:16:41 PM3/20/17
to web2py-users
It is a bug in grid. I just pushed a new version on github that allows you to do SQLFORM.grid(...,showblob=True)

Jordan Myers

unread,
Mar 21, 2017, 3:17:41 PM3/21/17
to web...@googlegroups.com
Thanks for the quick fix! Do you know when the next scheduled release will be for web2py? If it's not soon, what is the best practice for cloning the repository into an existing web2py source-download?

--
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/1bO8XUIo0eU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to web2py+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Massimo Di Pierro

unread,
Mar 21, 2017, 3:49:46 PM3/21/17
to web2py-users
You should be able to donwload the zip version and unzip over the existing one (assuming you are running from source). I plan a new release within less then 1 month. It is long overdue.

Jordan Myers

unread,
Mar 22, 2017, 1:02:53 PM3/22/17
to web...@googlegroups.com
I have done as you suggested, but web2py server will no longer start (tried with rocket server). Traceback:

Traceback (most recent call last):
  File "web2py.py", line 21, in <module>
    import gluon.widget
  File "/home/veda/acre/gluon/widget.py", line 26, in <module>
    from gluon import main, newcron
  File "/home/veda/acre/gluon/main.py", line 120, in <module>
    load_routes()
  File "/home/veda/acre/gluon/rewrite.py", line 380, in load
    load(routes, appname)
  File "/home/veda/acre/gluon/rewrite.py", line 320, in load
    exec(data, symbols)
  File "<string>", line 21, in <module>
ImportError: cannot import name abspath

Inspecting the code at that point, it seems the issue is that there is a syntax error in my routes.py file, and indeed removing this file allows web2py to run. However I have been using this file successfully before, and trying to remake it using the parametric example results in the error again. In fact, even the default routes.py file without changes also results in the error. Did the syntax or API for routes change?

Jordan Myers

unread,
Mar 22, 2017, 4:56:56 PM3/22/17
to web...@googlegroups.com
Also, attempting to access appadmin for any table yields:
Traceback (most recent call last
):
File "/home/veda/acre/gluon/restricted.py", line 216, in restricted
exec(ccode, environment)
File "<string>", line 192, in <module>
File "/home/veda/acre/gluon/sqlhtml.py", line 3314, in __init__
fieldmap = dict(zip(sqlrows.colnames, sqlrows.fields))
AttributeError: 'Rows' object has no attribute 'fields'
I think I'll just wait until the next stable release is done.

Dave S

unread,
Mar 22, 2017, 6:28:45 PM3/22/17
to web2py-users


On Wednesday, March 22, 2017 at 1:56:56 PM UTC-7, Jordan Myers wrote:
Also, attempting to access appadmin for any table yields:
Traceback (most recent call last):
File "/home/veda/acre/gluon/restricted.py", line 216, in restricted
exec(ccode, environment)
File "<string>", line 192, in <module>
File "/home/veda/acre/gluon/sqlhtml.py", line 3314, in __init__
fieldmap = dict(zip(sqlrows.colnames, sqlrows.fields))
AttributeError: 'Rows' object has no attribute 'fields'
I think I'll just wait until the next stable release is done.


Perhaps you have a mis-match on DAL versions.  Look in gluon/packages/dal/CHANGES.

/dps

 
To unsubscribe from this group and all its topics, send an email to web2py+un...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
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/1bO8XUIo0eU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to web2py+un...@googlegroups.com.

mweissen

unread,
Feb 18, 2018, 7:05:37 AM2/18/18
to web2py-users
I have tried

form = SQLFORM.grid(db.qr_info,
         showblob=True,        
    )

and I got:

<type 'exceptions.TypeError'> grid() got an unexpected keyword argument 'showblob'


What is wrong?

Version

2.16.1-stable+timestamp.2017.11.14.05.54.25
(läuft auf nginx/1.10.0, Python 2.7.12)

Anthony

unread,
Feb 18, 2018, 8:24:36 AM2/18/18
to web2py-users
On Sunday, February 18, 2018 at 7:05:37 AM UTC-5, mweissen wrote:
I have tried

form = SQLFORM.grid(db.qr_info,
         showblob=True,        
    )

and I got:

<type 'exceptions.TypeError'> grid() got an unexpected keyword argument 'showblob'


What is wrong?

The argument is actually showblobs.

Anthony
Reply all
Reply to author
Forward
0 new messages