AttributeError: 'DAL' object has no attribute

43 views
Skip to first unread message

goome

unread,
May 13, 2015, 1:14:30 PM5/13/15
to web...@googlegroups.com
hello , i have this action in defaul.py
"""
@auth.requires_login()
def lista_fornitori():
  fornitori = legacy_db().select(legacy_db.fornitori.ALL,orderby=legacy_db.fornitori.BrandName.upper())
  return dict(fornitori = fornitori)
""
and this work perfectly giving me the list of records in table 'fornitori'

Now in another action i need to retrieve the same list for creating a select,
but this time the same code
fornitori = legacy_db().select(legacy_db.fornitori.ALL)
fails with error
AttributeError: 'DAL' object has no attribute 'fornitori'

why in this action DAL does not find the table fornitori? What could be the problem.
The 2 actions are both in default.py

The beginning of thje second actions:
def sel_fornitore():
  fornitori = legacy_db(legacy_db.fornitori.ALL).select()

i also tried from shell with the same error.
What i am missing?

Paolo Valleri

unread,
May 13, 2015, 3:14:27 PM5/13/15
to web...@googlegroups.com
Which web2py version are you using?
Can you post a complete example that reproduces the issue?

Paolo

goome

unread,
May 14, 2015, 3:38:33 AM5/14/15
to web...@googlegroups.com
2.4.6 stable
No, i cannot reproduce because today when i open the browser it worked!
By the way, what is the correct way  load the models in the shell?
i open the shell with
python web2py -S myapplic
lanched from the dir of web2py, so that myapplic in under appilcations/

goome

unread,
May 14, 2015, 4:16:52 AM5/14/15
to web...@googlegroups.com
from the shell i tried

legacy_db = DAL('sqlite://rocketdb')
# it found the db
fornitori = legacy_db().select(legacy_db.fornitori.ALL,orderby=legacy_db.fornitori.BrandName.upper())

stille give error
AttributeError: 'DAL' object has no attribute 'fornitori'

but now this is working calles from the server ....
??

Paolo Valleri

unread,
May 14, 2015, 4:25:25 AM5/14/15
to web...@googlegroups.com
have you defined the table?
web2py 2.4.* is really old. I suggest upgrading to a newer version

 Paolo

--
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/B-Nqj2CKS-0/unsubscribe.
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.

goome

unread,
May 14, 2015, 4:56:10 AM5/14/15
to web...@googlegroups.com
Yes the table is defined and can see the list of  'prodotti' thrugh web access.
Thanks for your help

Anthony

unread,
May 14, 2015, 5:14:15 AM5/14/15
to web...@googlegroups.com, marc...@gmail.com
You have not defined the table in your shell code. To run the app's model files when starting the shell, you must add the -M flag to the command line call. In that case, no need to explicitly define the db in the shell session, as it will already be there by virtue of the model files being run.

Anthony
Reply all
Reply to author
Forward
0 new messages