示例FB app中的self.user.user_id抛出错误

时间:2012-08-05 10:43:03

标签: python facebook-apps

我的FB应用程序代码在Facebook October 2012 Breaking Change之后破了,并且通过遵循以下建议得到解决:Picture property format using run with friends fb app

但有趣的是,在修复它之后,我在同一个代码中遇到了另一个问题(我之前认为不存在)我已经搜索了Breaking Changes但这个问题似乎也没有在那里讨论过。它抱怨user_id不是此行中self.user的属性:u'userIdOnServer': self.user.user_id if self.user else None。我通过论坛等搜索过但无法找到线索。

这是错误:

在run_bare_wsgi_app(application =)中的

C:\ Program Files \ Google \ google_appengine \ google \ appengine \ ext \ webapp \ util.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示例应用程序):

def render(self, name, **data):
    """Render a template"""
    if not data:
        data = {}
    data[u'js_conf'] = json.dumps({
        u'appId': conf.FACEBOOK_APP_ID,
        u'canvasName': conf.FACEBOOK_CANVAS_NAME,
        u'userIdOnServer': self.user.user_id if self.user else None,
    })
    data[u'logged_in_user'] = self.user
    data[u'message'] = self.get_message()
    data[u'csrf_token'] = self.csrf_token
    data[u'canvas_name'] = conf.FACEBOOK_CANVAS_NAME
    self.response.out.write(template.render(
        os.path.join(
            os.path.dirname(__file__), 'templates', name + '.html'),
        data))

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

0 个答案:

没有答案