This is a web2py bug.
The expcolumns list contains all the table fields i.e including virtual
fields.
for eg: [field1, field2, ..,field_N, Virtual_field_1, Virtual_field2, ...,
Virtual_field_N]
selectable_columns list contain only the selectable fields. It actually
removes all the virtual fields of the table.
for eg: [ field1, field2, ... field_N]
Query is also executed without virtual_fields So rows object doesn't
contain virtual_fields.
But *expcolumns* [which contains virtual fields ] is assigned to
*rows.colnames*.
So It shows attribute error for virtual fields.
It should assign *selectable_columns* to *rows.colnames*
Can I create a issue for this and send the fix via pull request?
On Tuesday, January 20, 2015 at 7:36:00 PM UTC+5:30, Prasad Muley wrote:
>
> Hi All,
>
> I've some virtual fields defined in a table. These are displayed on
> grid using viewargs.
>
> I've provided Export to CSV But it fails because of virtual fields.
>
> It shows errors as '*Row'* *Object has no attribute 'virtual_field_name' *
>
>
> app settings as below:
>
> *controllers/default.py*
>
>
> def person_info():
>
> viewargs = viewargs = {'fields': [f for f in db.person.__dict__
> if isinstance(db.company[f],
> (Field, Field.Virtual))]}
> export_csv = True
> export_classes = dict(xml=False, html=False, json=False, tsv=False,
> tsv_with_hidden_cols=False,
> csv_with_hidden_cols=False)
> grid = SQLFORM.grid(query, create=False, deletable=False,
> editable=allow_edit, maxtextlengths=maxtextlengths,
> showbuttontext=False, csv=export_csv,
> exportclasses=export_classes, viewargs=viewargs)
>
>
> return dict(grid=grid)
>
>
> Is it web2py bug? or
> Am I missing anything?
>
>
--
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.