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

  • Home
  • SEARCH
  • 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 6353957
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T22:29:57+00:00 2026-05-24T22:29:57+00:00

I use the blobstoreuploadhandler and hence must return a self.redirect but I need to

  • 0

I use the blobstoreuploadhandler and hence must return a self.redirect but I need to pass values to my template. How can I do it? If I can’t use template values then I suppose I can use session variables and I’ve included the beaker session library but I can’t understand how to access the session variables in django template. Any idea how I should do it?

I use default builtin django with google app engine and I can access session variables with a request handler but I don’t understand how to do it in templates:

class Sessiontest(webapp.RequestHandler):
    def get(self):
        # Get the session object from the environ
        self.session = self.request.environ['beaker.session']

        # Check to see if a value is in the session
        if 'counter' in self.session:
            counter = self.session['counter'] + 1
            self.session['counter'] = counter

        else:
            self.session['counter'] = 1
            counter = 1
        self.session.save()
        self.response.out.write('counter: %d' % counter)

Thanks

Update/edit: My problem is almost exactly like this Accessing session variable in Django template with Google App Engine (Webapp) – Python but with the library beaker instead of gaeutilities

Update: Here’s some of the code. we see that using HTTP GET to pass the values won’t be very good since there’s an anti-spam test that should hide the values:

def post(self, view):
    message = ''
    challenge = self.request.get('recaptcha_challenge_field').encode('utf-8')
    response  = self.request.get('recaptcha_response_field').encode('utf-8')
    remoteip  = os.environ['REMOTE_ADDR']
    cResponse = captcha.submit(
                 challenge,
                 response,
                 CAPTCHA_PRV_KEY,
                 remoteip)
    if cResponse.is_valid:
        isHuman=True
    else:#failed anti-spam test and can try again
        isHuman=False
        #Reprint the form
        import util
        template_values = {'isHuman':isHuman,'user' : users.get_current_user(),}
        template_values.update(dict(current_user=self.current_user, facebook_app_id=FACEBOOK_APP_ID))
        template_values.update(dict(capture=captcha.displayhtml(public_key = CAPTCHA_PUB_KEY, use_ssl = False, error = None)))
        path = os.path.join(os.path.dirname(__file__), 'market', 'market_insert.html')
        self.redirect("/ai") # Here the values aren't passed on and I must make a redirect
  • 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-05-24T22:29:58+00:00Added an answer on May 24, 2026 at 10:29 pm

    If you are doing a redirect you might have to redirect with the variables that you wish to keep in the GET string. So you redirect from

    /myview/
    

    to

    /myview2/?variable1=value
    

    However, I think you should really look to see why you are doing redirects. I tend to do them after a POST to a form, and if the user needs to be logged on, I redirect to a login screen with

    /authentication/login/?next=/view/they/wanted/to/see
    

    Otherwise you could keep things in cookies but its not the best way to proceed.

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

Sidebar

Related Questions

Use of || (or) I got so many values which I need to compare
use this website a lot but first time posting. My program creates a number
Use: The user searches for a partial postcode such as 'RG20' which should then
Use case: we have some project meta-data files which we want tracked, but are
Use OPENXML to get dt element in MSSQL 2005. How can I get xmlns:dt
use level1\level2\level3; Can someone explain with a simple demo ?
use a reapeter to display data, but sometimes the data is to big to
Use new MediaPlayer by Yahoo. Content parse automatic - greate, but I use ajax
USE Kudler_FF INSERT INTO Job_Tbl (JobTitle, JobDescription, ExemptionStatus) VALUES ('Accounting clerk’, ‘Computes, classifies, records,
Use of rails 3 recaptcha. In view _form.html.erb insert <%= recaptcha_tags %> But when

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.