python global variable not working in apache

Posted by Suhail on Stack Overflow See other posts from Stack Overflow or by Suhail
Published on 2010-06-14T08:08:36Z Indexed on 2010/06/14 8:12 UTC
Read the original article Hit count: 244

Filed under:
|
|
|

I am facing issue with the global variable, when i run in the django development server it works fine, but in apache it doesn't work

here is the code below:

red= "/foodfolio3/test/"


def showAddRecipe(request):
    #global objc
    if "userid" in request.session:
        objc["ErrorMsgURL"]= ""
        try:
            urlList= request.POST
            URL= str(urlList['url'])
            URL= URL.strip('http://')
            URL= "http://" + URL

            recipe= __addRecipeUrl__(URL)

            if (recipe == 'FailToOpenURL') or (recipe == 'Invalid-website-URL'):
                #request.session["ErrorMsgURL"]= "Kindly check URL, Please enter a valid URL"
                objc["ErrorMsgURL"]= "Kindly check URL, Please enter a valid URL"
                print "here global_context =", objc
                arurl= HttpResponseRedirect("/foodfolio3/add/import/")
                arurl['ErrorMsgURL']= objc["ErrorMsgURL"]
                #return HttpResponseRedirect("/foodfolio3/add/import/")
                #return render_to_response('addRecipeUrl.html', objc, context_instance = RequestContext(request))
                return (arurl)
            else:
                objc["recipe"] = recipe
                return render_to_response('addRecipe.html',
                    objc,
                    context_instance = RequestContext(request))
        except:
            objc["recipe"] = ""
            return render_to_response('addRecipe.html',
                objc,
                context_instance = RequestContext(request))
    else:
        global red
        red= "/foodfolio3/add/"
        return HttpResponseRedirect("/foodfolio3/login")



def showAddRecipeUrl(request):
    if "userid" in request.session:
        return render_to_response('addRecipeUrl.html',
            objc, 
            context_instance = RequestContext(request))
    else:
        global red
        red= "/foodfolio3/add/import/"
        return HttpResponseRedirect("/foodfolio3/login")


def showLogin(request):
    obj = {}
    obj["error_message"] = ""
    obj["registered"] = ""

    if request.method == "POST":
        if (red == "/foodfolio3/test"):
            next= '/foodfolio3/recipes'
        else:
            next= red

        try:
            username = request.POST['username']
            password = request.POST['password']
            user = authenticate(username=username, password=password)
        except:
            user = authenticate(request=request)

        if user is not None:
            if user.is_active:
                login(request, user)
                request.session["userid"] = user.id

                # Redirect to a success page.
                return HttpResponseRedirect(next)

this code works fine in django development server, but in apache, the url is getting redirected to '/foodfolio3/recipes'

© Stack Overflow or respective owner

Related posts about python

Related posts about django