Here is the routine.The emails both before and after get sent fine..The software sends an email to spinjazz...@gmail.com so we have a record of bookings in case of a database meltdown.def paypal_complete_a():import datetimefrom paypal import PayPalpaypal = PayPal()resp=paypal.GetExpressCheckoutDetails(request.vars.token)
mail.send(to=['me_for_debu...@gmail.com'],
subject="resp",message='A' if not request else 'a '+str(resp))transaction=db(db.transactions.token==request.vars.token).select().first()resp=paypal.DoExpressCheckoutPayment(request.vars.token, request.vars.PayerID, transaction.amount)if not resp['ACK']=='Success':redirect(URL('paypal_failure'))transaction.status='booked'transaction.update_record()event=db.events[transaction.event_id]get_tickets(event,transaction.quantity)scheduler.queue_task('save_sqlite')if transaction.quantity == '1':tickets=' ticket booked for 'else:tickets=' tickets booked for '
mail.send(to=['spinjazztickets...@gmail.com'],
And the problem only happens intermittently? If so, is it frequent enough that you could do some logging to figure out what is happening in the cases of failure? If you can do some logging, maybe check things like db._lastsql, transaction.update_record.colset, and transaction.update_record.id right before/after the update.
If you want to check for success, I suppose you could select the record again, though that will result in an extra database hit.
Anthony
On Monday, June 1, 2015 at 10:43:30 AM UTC-4, peter wrote:
Here is the routine.The emails both before and after get sent fine..The software sends an email to spinjazz...@gmail.com so we have a record of bookings in case of a database meltdown.def paypal_complete_a():import datetimefrom paypal import PayPalpaypal = PayPal()resp=paypal.GetExpressCheckoutDetails(request.vars.token)
mail.send(to=['me_for_d...@gmail.com'],
subject="resp",message='A' if not request else 'a '+str(resp))transaction=db(db.transactions.token==request.vars.token).select().first()resp=paypal.DoExpressCheckoutPayment(request.vars.token, request.vars.PayerID, transaction.amount)if not resp['ACK']=='Success':redirect(URL('paypal_failure'))transaction.status='booked'transaction.update_record()event=db.events[transaction.event_id]get_tickets(event,transaction.quantity)scheduler.queue_task('save_sqlite')if transaction.quantity == '1':tickets=' ticket booked for 'else:tickets=' tickets booked for '
mail.send(to=['spinjazz...@gmail.com'],
subject=event.band,message='{0}{1}{2} on {3} bought by {4} {5}'.format(transaction.quantity,tickets,event.band,show_date(event.date), auth.user.first_name,auth.user.last_name))mail.send(to=[auth.user.email],subject=event.band,message='{0} {1} you have {2}{3}{4} on {5}. Order number is {6}'.format(auth.user.first_name, auth.user.last_name, transaction.quantity,tickets,event.band,show_date(event.date),transaction.id))returnThanksPeter
--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 a topic in the Google Groups "web2py-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/web2py/hOHmp5B190Q/unsubscribe.
To unsubscribe from this group and all its topics, send an email to web2py+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
I am still bemused that update_record can not know that it has failed and return a result reflecting this. This is standard practice in computing. Maybe this is just a weakness of sqlite I do not know.
db(db.transactions.token == request.vars.token).update(status='booked')