def efetch(req, id): logger.info("Asked to fetch Id: %s", id) session = entrez.EntrezSession(library_root()) abspath = session.fetch_id(id) path = getrelpath(abspath) try: parsing.initial(abspath) except: messages.error(req, "There was a problem loading file '%s', " "please try again or try a different record." % path) return re_search(req) path = getrelpath(abspath) remaining_args = dict(req.REQUEST.items()) action = remaining_args.pop('action', 'run') if action in ['run', 'config']: return HttpResponseRedirect( reverse(action, args=[path]) + dict_to_querystring(remaining_args)) else: logger.error("Unknown action %r", action) messages.error(req, "Unknown action.") return re_search(req)
def view(req): action = None if req.method == 'POST': path = None startform = StartForm(req.POST, req.FILES) action = req.POST.get('action') if startform.is_valid(): logger.info("Form is valid; action is %r", action) kwargs = startform.cleaned_data path = kwargs.pop('path') if action == 'run': return HttpResponseRedirect( reverse(action, args=[path]) + dict_to_querystring(kwargs)) else: logger.error("Unknown action %r", action) messages.error(req, "Unknown action.") else: startform = StartForm() email = startform['email'].value() or req.GET.get('email') return render_to_response( 'start.html', {'form': startform, 'action': action, 'email': email}, context_instance=RequestContext(req))