You are very close. Try this:
class index(app.page):
path = '/'
def GET(self):
user = users.get_current_user()
if user:
greeting = ("Welcome, %s! (<a href=\"%s\">sign out</a>)" %
(user.nickname(), users.create_logout_url("/")))
else:
greeting = ("<a href=\"%s\">Sign in or register</a>."
%users.create_login_url("/"))
return greeting
On Aug 20, 9:10 am, Andrew <[email protected]> wrote:
> Hi,
>
> I'm trying to teach myself some python / web.py and one of the first
> things I thought I'd tackle was a simple app on GAE.
>
> I was trying to user the google user service however I"m not sure how
> to do this in web.py
>
> I've tried something like:
>
> class login:
> def get(self):
> user = users.get_current_user()
>
> if user:
> self.response.out.write(
> 'Hello %s <a href="%s">Sign out</a><br>Is
> administrator: %s' %
> (user.nickname(), users.create_logout_url("/"),
> users.is_current_user_admin())
> )
> else:
> return
> web.seeother(users.create_login_url(self.request.uri))
>
> But self.request.uri seems to be invalid. I am also not certain the
> web.seeother will work when calling a url that isn't mapped in the
> "urls"?
>
> Does anyone have a working example of how to use the google login
> service with web.py?
>
> I'm a complete newbie to python (and web.py) so please be patient with
> me if this doesn't make a lot of sense. :-)
>
> Best regards,
> Andrew.
--
You received this message because you are subscribed to the Google Groups
"web.py" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/webpy?hl=en.