self.user.user_标识在示例FB应用程序抛出

2024-05-17 10:18:09 发布

您现在位置:Python中文网/ 问答频道 /正文

我的FB应用程序代码在Facebook October 2012 Breaking Change后坏了,按照下面的建议修复了它:Picture property format using run with friends fb app

有趣的是,我在前面的代码中没有讨论过这个问题。它抱怨用户不是自身用户在这一行:u'userIdOnServer': self.user.user_id if self.user else None。我已经在论坛上搜索过了,但是没有找到任何线索。在

错误如下:

C:\Program Files\Google\Google_appengine\Google\appengine\ext\webapp\实用程序.py运行中的应用程序(应用程序=)

    114   env["wsgi.multithread"] = False
    115   env["wsgi.multiprocess"] = False
=>  116   result = application(env, _start_response)
    117   if result is not None:
    118     for data in result:

result undefined, application = <google.appengine.ext.webapp._webapp25.WSGIApplication object>, env = {'APPENGINE_RUNTIME': 'python', 'APPLICATION_ID': 'dev~app', 'AUTH_DOMAIN': 'gmail.com', 'CONTENT_LENGTH': '-1', 'CONTENT_TYPE': 'application/x-www-form-urlencoded', 'CURRENT_VERSION_ID': '1.1', 'GATEWAY_INTERFACE': 'CGI/1.1', 'HTTP_ACCEPT': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', 'HTTP_ACCEPT_CHARSET': 'ISO-8859-1,utf-8;q=0.7,*;q=0.3', 'HTTP_ACCEPT_LANGUAGE': 'en-US,en;q=0.8', ...}, global _start_response = <function _start_response>
 C:\Program Files\Google\google_appengine\google\appengine\ext\webapp\_webapp25.py in __call__(self=<google.appengine.ext.webapp._webapp25.WSGIApplication object>, environ={'APPENGINE_RUNTIME': 'python', 'APPLICATION_ID': 'dev~app', 'AUTH_DOMAIN': 'gmail.com', 'CONTENT_LENGTH': '-1', 'CONTENT_TYPE': 'application/x-www-form-urlencoded', 'CURRENT_VERSION_ID': '1.1', 'GATEWAY_INTERFACE': 'CGI/1.1', 'HTTP_ACCEPT': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', 'HTTP_ACCEPT_CHARSET': 'ISO-8859-1,utf-8;q=0.7,*;q=0.3', 'HTTP_ACCEPT_LANGUAGE': 'en-US,en;q=0.8', ...}, start_response=<function _start_response>)

    715           handler.error(501)
    716       except Exception, e:
=>  717         handler.handle_exception(e, self.__debug)
    718     else:
    719       response.set_status(404)

handler = <__main__.RecentRunsHandler object>, handler.handle_exception = <bound method RecentRunsHandler.handle_exception of <__main__.RecentRunsHandler object>>, e = AttributeError("**'dict' object has no attribute 'friends'",)**, self = <google.appengine.ext.webapp._webapp25.WSGIApplication object>, self.__debug undefined
 C:\Program Files\Apache Software Foundation\Tomcat 7.0\webapps\ROOT\app\main.py in handle_exception(self=<__main__.RecentRunsHandler object>, ex=AttributeError("'dict' object has no attribute 'friends'",), debug_mode=True)
    228         self.log_exception(ex)
    229         self.render(u'error',
=>  230             trace=traceback.format_exc(), debug_mode=debug_mode)
    231 
    232     def log_exception(self, ex):

trace undefined, global traceback = <module 'traceback' from 'C:\Python27\lib\traceback.pyc'>, traceback.format_exc = <function format_exc>, debug_mode = True
 C:\Program Files\Apache Software Foundation\Tomcat 7.0\webapps\ROOT\app\main.py in render(self=<__main__.RecentRunsHandler object>, name=u'error', **data={'debug_mode': True, 'trace': 'Traceback (most recent call last):\n File "C:\\Pr...eError: \'dict\' object has no attribute \'friends\'\n'})
    265             u'appId': conf.FACEBOOK_APP_ID,
    266             u'canvasName': conf.FACEBOOK_CANVAS_NAME,
=>  267             u'userIdOnServer': self.user.user_id if self.user else None,
    268         })
    269         data[u'logged_in_user'] = self.user

self = <__main__.RecentRunsHandler object>, self.user = {u'id': u'100003906996287', u'name': u'Sudhir Jain'}, self.user.user_id undefined, builtin None = None
**<type 'exceptions.AttributeError'>: 'dict' object has no attribute 'user_id' 
      args = ("'dict' object has no attribute 'user_id'",) 
      message = "'dict' object has no attribute 'user_id'"**

下面是呈现代码(我是在runwithfriends示例应用程序的基础上构建的):

^{pr2}$

抱歉,如果我没有提供任何信息,但我很乐意提供您建议的其他信息/错误日志。提前谢谢。在


Tags: debugselfidhttpobjectapplicationmainresponse