Hi,

Sorry for asking but how exactly you decided that those `global` variables was 
not updated?

Regards,
C

> On Jan 23, 2018, at 6:47 AM, Максим Королёв <[email protected]> wrote:
> 
> Hi there.
> Could someone explain what happens. I had a little project on Python 2.7 and 
> decided to move it on 3.6. Everything has gone by perfectly. The project 
> works well as before but there is one exception noticed by me: the global 
> statement works not always. The code below doesn't update the global variable 
> zip_file_name and I can't grasp why. Any suggestions.
> 
> zip_file_name = os.path.join(MEDIA_ROOT, 'wb`s.zip')
> file_list = []
> 
> 
> @permission_required("wb_search.change_wbsearch", login_url='access_denied')
> @csrf_exempt
> def input_data_form(request):
>     global zip_file_name, file_list
>     if request.method == 'POST':
>         form = WbSearchForm(request.POST)
>         if form.is_valid():
>             text = request.POST['wbs_nums']
>             picked = form.cleaned_data.get('category')
>             try:
>                 wb_nums = process_input(text, LENGTH_OF_STR_TO_PROCESS)
>                 zip_file_name, file_list = get_wb_pdf_as_zip(wb_nums, picked)
>                 m = SearchHistory(user=str(request.user), 
> curr_date=datetime.now(), list_desired_docs=', '.join([str(rec[0]) for rec in 
> file_list]))
>                 m.save()
>                 return HttpResponseRedirect('/wb_search/search_finished/')
>             except NoDataToSearch:
>                 return 
> HttpResponseRedirect('/wb_search/wb_search_incorrect_data/')
>         else:
>             return 
> HttpResponseRedirect('/wb_search/wb_search_incorrect_data/')
>     else:
>         form = WbSearchForm()
>     # context = context.update(csrf(request))
>     return render_to_response('wb_search_input_data_form.html',
>                               {'form': form, 'title': 'Номера для поиска',
>                                'header': 'Поиск PDF файлов вэйбилов',
>                                'text': 'Вставте в это поле номера вэйбилов 
> PDF файлы которых необходимо найти.',
>                                'textarea_title': 'Вставте в это поле номера 
> вэйбилов PDF файлы которых необходимо '
>                                                  'найти.',
>                                'submit_title': 'Начать поиск',
>                                'element_id': 'find_button', 'element_method': 
> 'click',
>                                'spinner_message': 'Ожидайте окончания 
> поиска...', },
>                               RequestContext(request))
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected] 
> <mailto:[email protected]>.
> To post to this group, send email to [email protected] 
> <mailto:[email protected]>.
> Visit this group at https://groups.google.com/group/django-users 
> <https://groups.google.com/group/django-users>.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/e833541c-0b75-486c-a06e-5aa8ccb5d446%40googlegroups.com
>  
> <https://groups.google.com/d/msgid/django-users/e833541c-0b75-486c-a06e-5aa8ccb5d446%40googlegroups.com?utm_medium=email&utm_source=footer>.
> For more options, visit https://groups.google.com/d/optout 
> <https://groups.google.com/d/optout>.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/3DB54166-0F6B-4F44-9DB1-05BFE47D578F%40gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to