Re: model sends two requests

2012-07-11 Thread Jani Tiainen
In one public site we ended up doing both, server side re-submission checks
and client side javascript with timeout re-enable "hack".

We just store magic key to cache which is checked on every submission. If
magic key is missing submission is valid (first one) and key is set if
form was valid:

if request.method == 'POST':
if cache.get('%s.%s' % (request.session.session_key,
data['unique_id'])):
if form.is_valid():
cache.set(('%s.%s' % (request.session.session_key,
data['unique_id']), true) # Block subsequent requests
else:
pass # Output error messages about form
else:
# Key is in the cache, fail
return HttpResponseBadRequest()

On Tue, Jul 10, 2012 at 2:22 PM, jonas peters wrote:

> Thanks, helped me a lot.
>
>
>
> Em segunda-feira, 9 de julho de 2012 17h53min23s UTC-3, Dennis Lee Bieber
> escreveu:
>
>> On Mon, 9 Jul 2012 09:26:15 -0700 (PDT), jonas peters
>>  declaimed the following in
>> gmane.comp.python.django.user:
>>
>> > I have a model and use standard django administration, when a user
>> clicks
>> > the save button it sends the request, it takes time to respond and the
>> user
>> > clicks the save button again and then sends another request, and
>> creating
>> > two records. have some setting in django to avoid this problem? I
>> thought
>> > about locking the save button when it is clicked so the user does not
>> click
>> > more than once to complete the request.
>> >
>> In general (that is, not Django specific), my experience is that
>> potentially slow sites in which an extra submittal would cause problems
>> tend to include a warning message to only click once (the sites I've
>> seen this on tend to be online markets -- where the warning is that
>> double clicking could result in a second order charged to the credit
>> card.
>>
>> The other general solution would be to collect the data, send it
>> to
>> a separate worker thread/process and immediately return a "please wait"
>> type response -- this response should have an automatic redirect (using
>> a cookie to identify the worker) to a page that will either find the
>> worker thread has finished and can return the real next page -- or if
>> the worker is still busy resend the "please wait" page.
>>
>> More specific modes:
>> http://www.turnkeylinux.org/**blog/prevent-double-click-**form-submission
>> (general search: prevent double click form submit
>> http://www.google.com/#hl=en&**sclient=psy-ab=prevent+**
>> double+click+form+submit=**prevent+double+click+form+**
>> submit_l=serp.3..**0i30j0i5i30.8464.23704.0.**
>> 23926.28.25.2.1.1.6.503.4601.**0j21j3j5-1.25.0...0.0.c3W_**
>> 7yOZRzI=1=on.2,or.r_**gc.r_pw.r_qf
>> .,cf.osb=**9da4b66dc5fd8e9a=1044=**748
>> )
>>
>>
>>
>> > Sorry my english Thanks!
>> --
>> Wulfraed Dennis Lee Bieber AF6VN
>> wlfr...@ix.netcom.com
>> HTTP://wlfraed.home.netcom.**com/
>>
>>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/ZU-HtLFqcp4J.
>
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>



-- 
Jani Tiainen

- Well planned is half done, and a half done has been sufficient before...

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: model sends two requests

2012-07-10 Thread jonas peters
Thanks, helped me a lot.



Em segunda-feira, 9 de julho de 2012 17h53min23s UTC-3, Dennis Lee Bieber 
escreveu:
>
> On Mon, 9 Jul 2012 09:26:15 -0700 (PDT), jonas peters 
>  declaimed the following in 
> gmane.comp.python.django.user: 
>
> > I have a model and use standard django administration, when a user 
> clicks 
> > the save button it sends the request, it takes time to respond and the 
> user 
> > clicks the save button again and then sends another request, and 
> creating 
> > two records. have some setting in django to avoid this problem? I 
> thought 
> > about locking the save button when it is clicked so the user does not 
> click 
> > more than once to complete the request. 
> > 
> In general (that is, not Django specific), my experience is that 
> potentially slow sites in which an extra submittal would cause problems 
> tend to include a warning message to only click once (the sites I've 
> seen this on tend to be online markets -- where the warning is that 
> double clicking could result in a second order charged to the credit 
> card. 
>
> The other general solution would be to collect the data, send it 
> to 
> a separate worker thread/process and immediately return a "please wait" 
> type response -- this response should have an automatic redirect (using 
> a cookie to identify the worker) to a page that will either find the 
> worker thread has finished and can return the real next page -- or if 
> the worker is still busy resend the "please wait" page. 
>
> More specific modes: 
> http://www.turnkeylinux.org/blog/prevent-double-click-form-submission 
> (general search: prevent double click form submit 
>
> http://www.google.com/#hl=en=psy-ab=prevent+double+click+form+submit=prevent+double+click+form+submit_l=serp.3..0i30j0i5i30.8464.23704.0.23926.28.25.2.1.1.6.503.4601.0j21j3j5-1.25.0...0.0.c3W_7yOZRzI=1=on.2,or.r_gc.r_pw.r_qf.,cf.osb=9da4b66dc5fd8e9a=1044=748
>  
>
> ) 
>
>
>  
> > Sorry my english Thanks! 
> -- 
> Wulfraed Dennis Lee Bieber AF6VN 
> wlfr...@ix.netcom.comHTTP://wlfraed.home.netcom.com/ 
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/ZU-HtLFqcp4J.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



model sends two requests

2012-07-09 Thread jonas peters
hi!

I have a model and use standard django administration, when a user clicks 
the save button it sends the request, it takes time to respond and the user 
clicks the save button again and then sends another request, and creating 
two records. have some setting in django to avoid this problem? I thought 
about locking the save button when it is clicked so the user does not click 
more than once to complete the request.

Sorry my english Thanks!

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/n8a3j7qxJX0J.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.