django - python global variable not working in apache -


I am facing a problem with global variables, when I run into the Digengo Development Server, it works fine Here's the code given below:

  red = "/ project3 / test /" def Showed recipes (request) : #global objc url = URL.strip ('http: //') url = "http: //." ErrorMsgURL "] =" "in the" userid "request: urlList = request.POST URL = str (UrlList ['url']) "+ URL recipe = __addRecipeUrl __ (URL) (recipe == 'FailToOpenU RL ') If (or the recipe ==' invalid-website URL '): # request.session ["ErrorMsgURL"] = "Please check url, please enter a valid URL" ObjC ["ErrorMsgURL"] = "Please check the URL Please enter the valid URL "print" here. Global_context = ", ObjC arurl = HttpResponseRedirect (" / project3 / import / "add) arurl ['ErrorMsgURL'] = ObjC [" Error MsgURL "] #return HttpResponseRedirect (" / Returning (arurl) and: ObjC ["method"] = recipe refunds render_to_response ('addRecipe.html', 'addRecipe.html', ObjC, context_instance = Leave RequestContext (request)) Obviously, it is possible to get back to HttpResponseRedirect ("/ project3 / login") and return it to the "RedRecovery.html" ("addRecipe.html", ObjC, context_instance = RequestContext (request)) and global red red = "/ project3 / ): ShowAddRecipeUrl (request) DEF: In the "user id" request.session: return render_to_response ('addRecipeUrl.html', ObjC, context_instance = RequestContext (request)) and: global red red = "/ project3 / add / import /" Return ("/ project3 / login") DEF showLogin (request): obj = {} obj ["ERROR_MESSAGE"] = "" obj ["registered"] = "" if request.method == "post": if ( Red == "/ project3 / test"): next = '/ project3 / v Users' left: Next = Red Try: User name = request.POST ['username'] password = request.POST ['password'] User = Certified (User Name = Username, Password = Password): User = Certify (request = request) if there is no: if user.is_active: login (request, user) request.session ["userid"] = user.id # Returns a successful page HttpResponseRedirect (next)  

This code works fine in Django Development Server, but in Apache, you P>

I think that you are going to be redirected to Apache Using CGI capabilities means that the script is resumed with each request. This means that global variables are started with each call.

In addition to this, it is not really a good idea that globals are identical to all users with session data (with one session, and thus state, per user), and sessions are per user, Which should do what you want (should)

The session data of which your case should probably be stored in some databases, when the Python interpreter is finished and the same page is provided E is in the form of will be over.


Comments

Popular posts from this blog

windows - Heroku throws SQLITE3 Read only exception -

lex - Building a lexical Analyzer in Java -

python - rename keys in a dictionary -