Hi Anthony,
I've done more tests on my machine, and it appears that the first issue
does *not* lie with
auth.settings.create_user_groups = False
, but rather with the interaction between Web2py and PostgreSQL in general.
It seems to me that Web2py behaves inconsistently with respect to
auth.define_tables()
, in that I sometimes get all those (renamed) Auth tables created but other
times not.
The way I setup my database is as follows.
Use PostgreSQL command line (with username: cyan) to create the db:
createdb mydb
, and create the db object in the account.py model file:
db = DAL("postgres://cyan:123456@localhost:5432/mydb")
After these two steps and before starting Web2py, I check on the PostgreSQL
server running on the localhost and make sure that an empty 'mydb' indeed
exists. Then I start Web2py server, and navigate
to http://127.0.0.1:8000/myapp/account/register, where I type in email,
pwds, and hit 'register' button, upon which if Web2py fails to create those
Auth tables by executing
auth.define_tables()
in the model file 'account.py', I will get an error saying that the table
'user_login' (effectively 'auth_user') does not exist. But strangely
enough, sometimes tables do get created and this go through.
Regarding the second problem, I did the test you suggested above in Web2py
shell while my application is running, and I have no problem with sending
an email using
mail.send(to='[email protected]', message='test')
, however, it simply fails to send anything when I test it in the browser
(obviously, only when Web2py somehow creates all the necessary Auth
tables). Again, after I hit the 'register' button, I get re-directed to the
desired next page and a new record is created in 'user_login' ('auth_user')
table, but no email is sent. Thus I suspect that something might went wrong
with the code that is affected by
auth.settings.registration_requires_verification = True
, rather than the the code which actually handles sending the email. Or, in
fact, could it be related to the code which sets the content of the
verification email in the model file 'account.py':
## set the content of the verification email
auth.messages.verify_email = 'Please click on the link: http://' + \
request.env.http_host + \
URL(r=request,c='account',f='verify_email') + \
'/%(key)s to verify your email address'
Any suggestion from you would be extremely welcome. Thanks!