> > 1. To address your concern about "an attempted duplicate entry will end > up raising an exception and returning a 500 response unless you catch and > handle the error.", we could probably add something like this snippet at > the (nearly) end of the "if form.accepts(...)" branch inside that > register() in tools.py: > > try: > db.commit() > except Exception as e: > db.rollback() > response.flash = "Something is wrong. %s" % e # It is better than > nothing >
We don't want to do explicit commits like this because that will commit any previous operations as well, which means those operations would not be rolled back in case there is a subsequent error (i.e., this violates the principle that each request should be wrapped in a single transaction). 2. Even without above snippet, in our context I would say a rare > 500-response-but-it-would-be-gone-if-you-simply-retry is (arguably?) still > better than, silently creating duplicated user accounts which clearly > violates the universal expectation of such a fundamental db scheme > assumption. > This doesn't seem to be a likely problem -- two different users would have to be trying to register with the same username/email within milliseconds of each other. On the other hand, I suppose this would make the 500 response in such a case equally rare (assuming we set unique=True in the table definition). Anthony -- 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 web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.