I don't understand why the variable "CodeInDB" == False.
Controller:
def VcodeToDbAndMail():
form = SQLFORM(db_app.post)
if form.accepts(request, formname=None):
email=request.vars.email.strip()
validCode = random.randint(1000000,9999999)
CodeInDB = True
try:
db_xml.abit_validation_codes.insert(A_EMAIL=email,V_CODE=validCode)
db_xml.commit()
except Exception:
CodeInDB = False
return XML("<div>"+str(CodeInDB)+"</div>")
elif form.errors:
return TABLE(*[TR(k, v) for k, v in form.errors.items()])
>> False
In DataBase I saw new record with my email and code.
If I do it witout "try ... except ...", I have error: "An error occured,
please reload the page".
--
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 the Google Groups
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.