[DAL] AttributeError: 'Expression' object has no attribute 'tablename'

100 views
Skip to first unread message

lyn2py

unread,
Jul 20, 2017, 1:20:44 AM7/20/17
to web2py-users
How do I resolve this error? 

Traceback (most recent call last):
  File "/Users/web2py/web2py/gluon/restricted.py", line 219, in restricted
    exec(ccode, environment)
  File "<string>", line 83, in <module>
  File "/Users/web2py/web2py/gluon/globals.py", line 422, in write
    self.body.write(to_native(xmlescape(data)))
  File "/Users/web2py/web2py/gluon/html.py", line 125, in xmlescape
    return to_bytes(data.xml())
  File "/Users/web2py/web2py/gluon/html.py", line 960, in xml
    (fa, co) = self._xml()
  File "/Users/web2py/web2py/gluon/html.py", line 952, in _xml
    co = b''.join([xmlescape(component) for component in self.components])
  File "/Users/web2py/web2py/gluon/html.py", line 125, in xmlescape
    return to_bytes(data.xml())
  File "/Users/web2py/web2py/gluon/html.py", line 960, in xml
    (fa, co) = self._xml()
  File "/Users/web2py/web2py/gluon/html.py", line 952, in _xml
    co = b''.join([xmlescape(component) for component in self.components])
  File "/Users/web2py/web2py/gluon/html.py", line 125, in xmlescape
    return to_bytes(data.xml())
  File "/Users/web2py/web2py/gluon/html.py", line 960, in xml
    (fa, co) = self._xml()
  File "/Users/web2py/web2py/gluon/html.py", line 952, in _xml
    co = b''.join([xmlescape(component) for component in self.components])
  File "/Users/web2py/web2py/gluon/html.py", line 125, in xmlescape
    return to_bytes(data.xml())
  File "/Users/web2py/web2py/gluon/html.py", line 960, in xml
    (fa, co) = self._xml()
  File "/Users/web2py/web2py/gluon/html.py", line 952, in _xml
    co = b''.join([xmlescape(component) for component in self.components])
  File "/Users/web2py/web2py/gluon/html.py", line 125, in xmlescape
    return to_bytes(data.xml())
  File "/Users/web2py/web2py/gluon/html.py", line 960, in xml
    (fa, co) = self._xml()
  File "/Users/web2py/web2py/gluon/html.py", line 952, in _xml
    co = b''.join([xmlescape(component) for component in self.components])
  File "/Users/web2py/web2py/gluon/html.py", line 125, in xmlescape
    return to_bytes(data.xml())
  File "/Users/web2py/web2py/gluon/packages/dal/pydal/objects.py", line 2497, in xml
    rv = self.db.represent('rows_xml', self)
  File "/Users/web2py/web2py/gluon/packages/dal/pydal/base.py", line 834, in represent
    return self.representers[name](*args, **kwargs)
  File "/Users/web2py/web2py/gluon/sqlhtml.py", line 3322, in __init__
    tablemap = dict(((f.tablename, f.table) for f in fieldmap.values()))
  File "/Users/web2py/web2py/gluon/sqlhtml.py", line 3322, in <genexpr>
    tablemap = dict(((f.tablename, f.table) for f in fieldmap.values()))
AttributeError: 'Expression' object has no attribute 'tablename'

The code that throws this error:

def dbselect():
    only_after = 
    t = db[ 'unique_sites' ]
    h = db[ 'TABLE_of_sites' ]
    max = h.last_updated.max()
    q = h.type_id==1
    q&= h.last_updated>datetime.now()-timedelta(weeks=8)
    join = t.on(t.url==h.url)
    rows = db(q).select(t.ALL, max, groupby=t.ALL, join=join) # this produces the error above :(
    rows = db(q).select(t.ALL, max, groupby=t.ALL, join=join).as_list() #this doesn't throw the error :)
    return locals()


VERSION:

Version 2.15.2-stable+timestamp.2017.07.19.01.21.31

Postgresql 9.6 + psycopg2 adapter




Thank you!





Massimo Di Pierro

unread,
Jul 20, 2017, 6:12:19 PM7/20/17
to web2py-users
Please open a ticket about this. This is a serious bug with the DAL rewrite. We will fix it asap.
Reply all
Reply to author
Forward
0 new messages