I am learning web2py. In db.py I activate/create auth_user tables. But
it seemed that web2py failed to generate needed tables.
Here is my db.py
if request.env.web2py_runtime_gae: # if running on Google App Engine
from gluon.contrib.gql import *
### connect to Google BigTable
db = GQLDB()
## and store sessions and tickets there
session.connect(request, response, db=db)
### or use the following lines to store sessions in Memcache
# from gluon.contrib.memdb import MEMDB
# from google.appengine.api.memcache import Client
# session.connect(request, response, db=MEMDB(Client()))
else: # else use a normal relational database
# if not, use SQLite or other DB
#db = SQLDB('sqlite://storage.sqlite')
db = SQLDB('mysql://user:userpasswd@localhost/happo', pool_size=0)
from gluon.tools import *
auth=Auth(globals(),db) # authentication/authorization
auth.define_tables() # creates all needed tables
crud=Crud(globals(),db) # for CRUD helpers using auth
service=Service(globals()) # for json, xml, jsonrpc, xmlrpc, amfrpc
## uncomment as necessary or consult docs for more options
crud.settings.auth=auth # (optional) enforces authorization on crud
mail=Mail() # mailer
mail.settings.server='smtp.gmail.com:587' # your SMTP server
mail.settings.sender='mico.s...@gmail.com' # your email
mail.settings.login='mico.siahaan:gmaipass' # your credentials
auth.settings.mailer=mail # for user email verification
auth.settings.registration_requires_verification = False
auth.settings.registration_requires_approval = True
auth.messages.verify_email = \
'Click on the link
http://127.0.0.1:8000/customer/default/user/verify_email/%(key)s to
verify your email'
and here is the error:
Traceback (most recent call last):
File "C:\Users\mico\Documents\PERSONAL\Project\happo\src\trunk\web2py\gluon\restricted.py",
line 107, in restricted
exec ccode in environment
File "C:/Users/mico/Documents/PERSONAL/Project/happo/src/trunk/web2py/applications/customer/controllers/appadmin.py",
line 255, in <module>
File "C:\Users\mico\Documents\PERSONAL\Project\happo\src\trunk\web2py\gluon\globals.py",
line 100, in <lambda>
self._caller = lambda f: f()
File "C:/Users/mico/Documents/PERSONAL/Project/happo/src/trunk/web2py/applications/customer/controllers/appadmin.py",
line 104, in insert
if form.accepts(request.vars, session):
File "C:\Users\mico\Documents\PERSONAL\Project\happo\src\trunk\web2py\gluon\sqlhtml.py",
line 709, in accepts
onvalidation,
File "C:\Users\mico\Documents\PERSONAL\Project\happo\src\trunk\web2py\gluon\html.py",
line 1122, in accepts
status = self._traverse(status)
File "C:\Users\mico\Documents\PERSONAL\Project\happo\src\trunk\web2py\gluon\html.py",
line 439, in _traverse
newstatus = c._traverse(status) and newstatus
File "C:\Users\mico\Documents\PERSONAL\Project\happo\src\trunk\web2py\gluon\html.py",
line 439, in _traverse
newstatus = c._traverse(status) and newstatus
File "C:\Users\mico\Documents\PERSONAL\Project\happo\src\trunk\web2py\gluon\html.py",
line 439, in _traverse
newstatus = c._traverse(status) and newstatus
File "C:\Users\mico\Documents\PERSONAL\Project\happo\src\trunk\web2py\gluon\html.py",
line 439, in _traverse
newstatus = c._traverse(status) and newstatus
File "C:\Users\mico\Documents\PERSONAL\Project\happo\src\trunk\web2py\gluon\html.py",
line 446, in _traverse
newstatus = self._validate()
File "C:\Users\mico\Documents\PERSONAL\Project\happo\src\trunk\web2py\gluon\html.py",
line 935, in _validate
(value, errors) = validator(value)
File "C:\Users\mico\Documents\PERSONAL\Project\happo\src\trunk\web2py\gluon\validators.py",
line 305, in __call__
rows = self.dbset(field == value).select(limitby=(0, 1))
File "C:\Users\mico\Documents\PERSONAL\Project\happo\src\trunk\web2py\gluon\sql.py",
line 2120, in select
r = response(query)
File "C:\Users\mico\Documents\PERSONAL\Project\happo\src\trunk\web2py\gluon\sql.py",
line 2115, in response
self._db._execute(query)
File "C:\Users\mico\Documents\PERSONAL\Project\happo\src\trunk\web2py\gluon\sql.py",
line 730, in <lambda>
self._execute = lambda *a, **b: self._cursor.execute(*a, **b)
File "C:\Python25\Lib\site-packages\MySQLdb\cursors.py", line 166, in execute
self.errorhandler(self, exc, value)
File "C:\Python25\Lib\site-packages\MySQLdb\connections.py", line
35, in defaulterrorhandler
raise errorclass, errorvalue
ProgrammingError: (1146, "Table 'happo.auth_user' doesn't exist")
Is it a bug in 1.65.0?
--
Mico Siahaan
---
Email: Mico.S...@gmail.com
I will try as details as I could :).
1. This is my first try with web2py, basically I just want to make
sample app. It will be a website that member can login and update his
status so other member can know the update
2. For development, I am using win vista business and xampp for
windows (it has apache and mysql)
3. So from xampp control panel I start mysql
4. Then using phpmyadmin I create user, and create database happo.
Give permission for that user to create and modify all tables in happo
database
5. Then I start web2py
6. Create new application
7. Edit db.py. I uncommented lines of auth settings.
8. After that I access index method of appadmin.py controller.
9. Got error tickets
File "C:\Python25\Lib\site-packages\MySQLdb\cursors.py", line 166, in execute
self.errorhandler(self, exc, value)
File "C:\Python25\Lib\site-packages\MySQLdb\connections.py", line
35, in defaulterrorhandler
raise errorclass, errorvalue
ProgrammingError: (1146, "Table 'happo.auth_user' doesn't exist")
while my db.py (full, as requested by massimo)
if request.env.web2py_runtime_gae: # if running on Google App Engine
from gluon.contrib.gql import *
### connect to Google BigTable
db = GQLDB()
## and store sessions and tickets there
session.connect(request, response, db=db)
### or use the following lines to store sessions in Memcache
# from gluon.contrib.memdb import MEMDB
# from google.appengine.api.memcache import Client
# session.connect(request, response, db=MEMDB(Client()))
else: # else use a normal relational database
# if not, use SQLite or other DB
#db = SQLDB('sqlite://storage.sqlite')
db = SQLDB('mysql://my_user:my_passwd@localhost/happo', pool_size=0)
from gluon.tools import *
auth=Auth(globals(),db) # authentication/authorization
auth.define_tables() # creates all needed tables
crud=Crud(globals(),db) # for CRUD helpers using auth
service=Service(globals()) # for json, xml, jsonrpc, xmlrpc, amfrpc
## uncomment as necessary or consult docs for more options
crud.settings.auth=auth # (optional) enforces authorization on crud
mail=Mail() # mailer
mail.settings.server='smtp.gmail.com:587' # your SMTP server
mail.settings.sender='mico.s...@gmail.com' # your email
mail.settings.login='mico.siahaan:gmaipass' # your credentials
auth.settings.mailer=mail # for user email verification
auth.settings.registration_requires_verification = False
auth.settings.registration_requires_approval = True
auth.messages.verify_email = \
'Click on the link
http://127.0.0.1:8000/customer/default/user/verify_email/%(key)s to
verify your email'
so basically I have not done much :)
--
Mico Siahaan
---
Email: Mico.S...@gmail.com
regards,
--
Mico Siahaan
---
Email: Mico.S...@gmail.com