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 3802114
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T14:09:25+00:00 2026-05-19T14:09:25+00:00

I have a question similar to my previous question . In the same app

  • 0

I have a question similar to my previous question.

In the same app I have the VoteHandler that adds +1 when users click on the up arrow and then redirects to the same page.

Now that I added the url parameters to the pages and urls look like this

/dir?type=tshirt

I need to be able to redirect to the correct page.

And as mentioned here by Nick Johnson referrer is not a good way of redirecting.

I would appreciate help about how to fix VoteHandler so that it redirects to the correct page.

Thanks!

class VoteHandler(webapp.RequestHandler):
    def get(self, id):
        id = int(id)
        item = Item.get_by_id(id)

        user = users.get_current_user()

        if user:
            greeting = ("%s (<a href='%s'>sign out</a>)" %
                           (user.nickname(), users.create_logout_url(self.request.uri)))

            #--check if user voted on this item before--#
            query  = SiteUser.all()
            query.filter("liked_items =", (str(item.key().id())))
            already_voted = query.get()

            if already_voted:
                self.redirect("/onevote")
            else:
                query = SiteUser.all()          
                query.filter("site_user =", users.get_current_user())

                data = query.get()

                data.total_votes += 1
                data.liked_items = str(item.key().id())
                data.site_user = users.get_current_user()

                db.put(data)

                item.points += 1
                item.put()            

                if self.request.referrer == 'http://localhost:8083//newest':
                    self.redirect('/newest')
                elif self.request.referrer == 'http://localhost:8083/hot':
                    self.redirect('/hot')
                #How do I fix this line to get the correct url parameter?
                elif self.request.referrer == 'http://localhost:8083/dir?type=tshirt':
                    self.redirect('/dir/tshirt')    
                else:     
                    self.redirect("/")                       
        else:            
            greeting = ("<a href='%s'>Sign in with your Google account or register</a>." %
                           cgi.escape(users.create_login_url(self.request.uri)))

UPDATE

The answer by systempuntoout works great but I had to change the vote link in Directory from

/vote/%s

to

/vote/%s?type=%s

so that I could get the merchandise_type in VoteHandler:

self.response.out.write("<ol>")
for item in items:
    self.response.out.write("""<li>
                                   <a href="/vote/%s?type=%s"> ^ </a><a href="%s">%s</a> <span id='Small'>(%s)</span><br /> 
                                   <div id='Small'> 
                                     %s points %s by %s <a href="/item/%s"></a> | 
                                     <a href="/item/%s#disqus_thread"></a>
                                   </div>
                               </li><br /> """ % 
                                    (str(item.key().id()), merchandise_type, item.url, item.title, urlparse(item.url).netloc,
                                    item.points, item.date.strftime("%B %d, %Y %I:%M%p"), item.user_who_liked_this_item, str(item.key().id()), str(item.key().id())))                               

self.response.out.write("</ol>")
  • 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-19T14:09:26+00:00Added an answer on May 19, 2026 at 2:09 pm

    I would use the type parameter in this way:

    class VoteHandler(webapp.RequestHandler):
        def get(self, id):
            id = int(id)
            item = Item.get_by_id(id)
            merchandise_type = self.request.get("type", "")
            ..
            self.redirect('/%s' % merchandise_type)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This question is similar to my previous question but not the same ... please
That's a question really similar to this previous post of mine. I need to
This question is based on a previous similar question. I have the following equation
I have a similar question to my previous one ( Drupal 7 views filter
I am trying to do something very similar to that previous question but I
I have a question similar to this: how to manually assign imagefield in Django
I have a question involving the Replace Method. I saw a question similar to
I have asked a question similar to this in the past but this is
I have a similar question to the one I just asked. I'm trying to
I have a similar question to this one However, I have a less strict

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.