On 12/29/06, Felix Schwarz <[EMAIL PROTECTED]> wrote:
I have a function which creates a new user account. Of course, I do some input validation in a validation schema. If there are any errors, my error_handler will be called.But there is a possibility that an error occurs in the message (after validation). In this case, I like to proceed as if there were errors during validation. For example, I can test if a user name exists before creating a new user. But this opens the door to a race condition when two requests arrive in parallel. Request A Request B | | validation | | validation create user | | create user (-> exception!) <proceed> (show error form?) Therefore I have to call commit manually and catch some selected exceptions (like duplicate key). In these cases, I like to show the error form as if the user account existed when request b gets the exception. Is there any way to do this?
Well one way would be to create the user record in the validator, so you'd get the exception in time for the error handler to be invoked. That might work but would be ugly. If it were me, I'd probably just keep the code simple and take the one-in-a-million Code 500 if this race is hit. Anyone else have a better way to handle this? -- Andy --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "TurboGears" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/turbogears?hl=en -~----------~----~----~----~------~----~------~--~---

