1

我的 FB 应用程序代码在 Facebook 2012 年 10 月的重大更改后发生故障,并通过以下建议修复:使用与朋友一起运行的图片属性格式 fb 应用程序

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

这是错误:

C:\Program Files\Google\google_appengine\google\appengine\ext\webapp\util.py 在 run_bare_wsgi_app(application=)

    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))

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

4

0 回答 0