As reported in the Spanish group, the example under section 7.2.6
Links to Referencing Records, calling the list_records action with a
query var, e.g.:

http://127.0.0.1:8000/test/test/list_records/person?query=person.id>0


Traceback (most recent call last):
  File "C:\w2p\web2py_1.99.4_src\gluon\restricted.py", line 204, in
restricted
    exec ccode in environment
  File "C:/w2p/web2py_1.99.4_src/applications/test/controllers/
test.py", line 34, in <module>
  File "C:\w2p\web2py_1.99.4_src\gluon\globals.py", line 172, in
<lambda>
    self._caller = lambda f: f()
  File "C:/w2p/web2py_1.99.4_src/applications/test/controllers/
test.py", line 30, in list_records
    records = db(query).select(db[table])
  File "C:\w2p\web2py_1.99.4_src\gluon\dal.py", line 6333, in select
    return self.db._adapter.select(self.query,fields,attributes)
  File "C:\w2p\web2py_1.99.4_src\gluon\dal.py", line 1274, in select
    sql = self._select(query, fields, attributes)
  File "C:\w2p\web2py_1.99.4_src\gluon\dal.py", line 1672, in _select
    sql = super(SQLiteAdapter, self)._select(query, fields,
attributes)
  File "C:\w2p\web2py_1.99.4_src\gluon\dal.py", line 1155, in _select
    if query and not query.ignore_common_filters:
AttributeError: 'str' object has no attribute 'ignore_common_filters'

The code to reproduce is (excerpts from the book):

Model

db.define_table('person',
    Field('name','string'),
    Field('surname','string'),
    Field('image_filename'),
    Field('image', 'upload'))

db.define_table('dog',
    Field('owner', db.person),
    Field('name', requires=IS_NOT_EMPTY()))

Controller

def display_form():
    record = db.person(request.args(0))
    url = URL('download')
    link = URL('list_records')
    form = SQLFORM(db.person, record, deletable=True, upload=url,
linkto=link)
    if form.process().accepted:
        response.flash = 'form accepted'
    elif form.errors:
       response.flash = 'form has errors'
    return dict(form=form)

def download():
    return response.download(request, db)

def list_records():
    table = request.args(0)
    query = request.vars.query
    records = db(query).select(db[table])
    return dict(records=records,table=table,query=query)

Views

display_form.html

{{extend 'layout.html'}}
<h5>Display Form</h5>
{{=form}}

list_records.html

{{extend 'layout.html'}}
Tabla: {{=table}}</br>
Query: {{=query}}</br>
{{=records}}

Obviously this happens because the query is not a Query object but
then the example in the book is wrong.

Reply via email to