I use the ipn_handling from Paypal to check the database. As I do not know
why the update_record fails, I am not certain that several fails could not
happen in a row. It only happens rarely so I cannot log it. If things go
wrong punters turn up to the jazz club having paid and not having a seat,
which is clearly unsatisfactory.

What I have decided to do is to get the system to send me an email when the
ipn_handling first detects a failure. In this way I can manually check that
at least the problem gets dealt with properly by the update_record in the
ipn_handler.

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.

Peter



On Mon, Jun 1, 2015 at 7:06 PM, Anthony <abasta...@gmail.com> wrote:

> 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 spinjazzticke...@gmail.com so we have a
>> record of bookings in case  of a database meltdown.
>>
>>
>>
>> def paypal_complete_a():
>>     import datetime
>>     from paypal import PayPal
>>     paypal = PayPal()
>>     resp=paypal.GetExpressCheckoutDetails(request.vars.token)
>>     mail.send(to=['me_for_debugg...@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=['spinjazzticke...@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)
>>                   )
>>      return
>>
>>
>> Thanks
>> Peter
>>
>  --
> 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+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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.

Reply via email to