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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T01:47:54+00:00 2026-05-27T01:47:54+00:00

I have built a web app in Python for Google App Engine. It is

  • 0

I have built a web app in Python for Google App Engine. It is mature piece of code that I have run many times without any problems. However, when I was making some changes this morning, mysterious white space errors started popping up all over the place. I figured out what was going on and removed a few of them by hand before detabbing the whole text file (in TextWrangler) and changing my settings to auto-expand tabs. I think I have chased out all the bugs. When I run python -m tabnanny on my file, I get no reported errors.

However, a new bug has appeared in a previously solid chunk of code. I don’t know if the error is in the class or previous class it’s calling so I am including a big chunk of code below. The error message in GAE log is as follows:

<type 'exceptions.NameError'>: name 'self' is not defined
Traceback (most recent call last):
  File "/base/data/home/apps/lpflipstud/1.354982193405081399/example.py", line 99, in <module>
    class HomeHandler(BaseHandler):
  File "/base/data/home/apps/lpflipstud/1.354982193405081399/example.py", line 103, in HomeHandler
    logging.info(self.current_user)

Here is the code. It is a slightly modified version of sample code provided by facebook for Google App Engine interface with a facebook app:

class BaseHandler(webapp.RequestHandler):
#Provides access to the active Facebook user in self.current_user.
#The property is lazy-loaded on first access, using the cookie saved  
#by the Facebook JavaScript SDK to determine the user ID of the active
#user. See http://developers.facebook.com/docs/authentication/ for
#more information.
    @property
    def current_user(self):
        if not hasattr(self, "_current_user"):
            self._current_user = None
            cookie = facebook.get_user_from_cookie(
                self.request.cookies, FACEBOOK_APP_ID, FACEBOOK_APP_SECRET)
            if cookie:
                # Store a local instance of the user data so we don't need
                # a round-trip to Facebook on every request
                user = User.get_by_key_name(cookie["uid"])
                if not user:
                    graph = facebook.GraphAPI(cookie["access_token"])
                    profile = graph.get_object("me")
                    id=str(profile["id"])
                    at = cookie["access_token"]
                    user = User(key_name=str(profile["id"]),
                                id=str(profile["id"]),
                                name=profile["name"],
                                profile_url=profile["link"],
                                access_token=cookie["access_token"])
                    user.put()
                elif user.access_token != cookie["access_token"]:
                    user.access_token = cookie["access_token"]
                    user.put()
        #add list of friend ids
        tic = time.clock()
        url = "https://graph.facebook.com/"+user.id+"/friends?   access_token="+user.access_token
        response = urllib2.urlopen(url)
        fb_response = response.read()
        x = re.findall(r'"\d+"',fb_response)
        friend_list = [a.strip('"') for a in x]
        user.friends = friend_list
        toc = time.clock()
        t = toc - tic
        user.put()  
        self._current_user = user
        return self._current_user

class HomeHandler(BaseHandler):
    def get(self):
        path = os.path.join(os.path.dirname(__file__), "homepage.html")

    logging.info(self.current_user)
  • 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-27T01:47:55+00:00Added an answer on May 27, 2026 at 1:47 am

    logging.info(self.current_user) is outside of any scope that defines self (and would run when the class is being created, which is probably not what you want). You need to call it inside a method, e.g.

    def get(self):
        path = ...
        logging.info(self.current_user)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Python 2.6 web app built on Pylons 0.9.7. The code in
I have an asp.net mvc app that is built to run as standard web
I have a web app built in coldfusion that receives medical referral letters from
I have created a web application hosted on Google App Engine (Java). Now my
I have a web app built with iweb kit that looks great in Android
I am a broke college student. I have built a small web app in
I have built a web setup project in VS2008 which installs my ASP.NET/Silverlight app
I have a web app built against asp.net 2.0, but keep getting the following
I have a web app built on Java Servlet technology. I am thinking of
I have a simple web app built in asp.net webforms c# where and how

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.