Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7911631
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T13:19:14+00:00 2026-06-03T13:19:14+00:00

The original code looks like this,it works. def my_index(request): global account if request.session.get(‘account’,False): account=request.session[‘account’]

  • 0

The original code looks like this,it works.

def my_index(request):
    global account
    if request.session.get('account',False):
        account=request.session['account']
    else:
        return HttpResponseRedirect("http://login.passport.com/");
    print "login check pass"
    ...

when I try to put the checking lines into a method, it goes wrong.

The terminal prints Pos:A and Pos:B,but the page did’t redirect to login.passport.com

It goes on to print “login check pass”

I’ve tried pdb.set_trace(),it goes through the HttpResponseRedirect,but I still can’t find anything wrong.

Somebody give me a clue?

def login_check(request):
    global account
    if request.session.get('account',False):
        account=request.session['account']
    else:
        print "Pos:A"
        return HttpResponseRedirect("http://login.passport.com/");
        print "Pos:B"

def my_index(request):
    global account
    login_check(request)
    print "login check pass"
    ...
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T13:19:18+00:00Added an answer on June 3, 2026 at 1:19 pm

    You don’t do anything with the result of login_check within my_index. You need to return it from there too.

    Two other points: print Pos:B will never be reached; more seriously, you should never use global variables to store per-request state in Django. A process may last for many requests, so it’s dangerous to keep variables that only relate to the information in a single request.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

from this code will show in original color how can i change it to
I have data that always looks something like this: alt text http://michaelfogleman.com/static/images/chart.png I need
I'm having difficulty testing controllers. Original my controller for testing looked something like this:
I'm working on upgrading a library that looks something like this (in coffeescript for
after_photo_post_process :post_process_photo def post_process_photo img = EXIFR::JPEG.new(photo.queued_for_write[:original].path) # error on this line return unless
Using this code (tweaked a little) i can't get a constant Y value. it
The original code: public List<Contact> GetContactListEntityCompiledLINQ() { if (entities == null) entities = new
Here is the original code of Visual C++ which I have been trying to
here is the original code: public static int getInt () { Scanner in =
I've got a webapp whose original code base was developed with a hand crafted

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.