views:

43

answers:

2

What is the difference between the two lines:

A. loginURL = users.create_login_url(os.environ['PATH_INFO'])

B. loginURL = users.create_login_url(self.request.uri)

For my app engine project I want a user to make customized maps. But if he is not logged in, before he can start a new map project, I want to redirect him to login, and then right after he logs in I would like him to see the "make new project page".

+3  A: 

To quote the selected answer to this SO Question,

You should generally be doing everything within some sort of RequestHandler or the equivalent in your non-WebApp framework. However, if you really insist on being stuck in the early 1990s and writing plain CGI scripts, the environment variables SERVER_NAME and PATH_INFO may be what you want; see a CGI reference for more info.

IOW, live in the 21st century: use self.request.uri!-)

Alex Martelli
A: 

http://code.google.com/appengine/docs/python/gettingstarted/usingusers.html

class MainPage(webapp.RequestHandler): def get(self): user = users.get_current_user()

    if user:
        self.response.headers['Content-Type'] = 'text/plain'
        self.response.out.write('Hello, ' + user.nickname())
    else:
        self.redirect(users.create_login_url(self.request.uri))
indiehacker