V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
lin
V2EX  ›  Project Babel

Project Babel 2.5.0-dev notifications页面出错

  •  
  •   lin · 2011-07-22 10:39:37 +08:00 · 5942 次点击
    这是一个创建于 4675 天前的主题,其中的信息可能已经有所发展或是发生改变。
    Traceback (most recent call last):
    File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/ext/webapp/__init__.py", line 700, in __call__
    handler.get(*groups)
    File "/Users/linzhizhao/Develop/v2ex/notifications.py", line 46, in get
    self.member.private_token = hashlib.sha256(str(self.member.num) + ';' + config.site_key).hexdigest()
    AttributeError: 'module' object has no attribute 'site_key'

    在本地测试的情况下:虽然注释掉 46 行可以打开,但是,notifications feed就取不了值。
    6 条回复    1970-01-01 08:00:00 +08:00
    capthy
        1
    capthy  
       2011-08-10 20:15:37 +08:00
    在config.py里加个site_key的配置嘛
    Livid
        2
    Livid  
    MOD
       2011-08-10 22:33:20 +08:00 via iPhone
    Exactly.
    bjhyyc
        3
    bjhyyc  
       2011-08-10 23:16:38 +08:00
    @Livid 新版位面显示错误
    dimlau
        4
    dimlau  
       2011-08-11 01:09:38 +08:00
    @bjhyyc 在本地测试没问题,上传之后提示:main.py", line 252, in get
    self.values['page_title'] = str(self.site.title.decode('utf-8')) + u' › ' + str(self.l10n.planes.decode('utf-8'))
    File "/base/python_runtime/python_dist/lib/python2.5/encodings/utf_8.py", line 16, in decode
    return codecs.utf_8_decode(input, errors, True)
    UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-3: ordinal not in range(128)

    你也是这样吧?
    dimlau
        5
    dimlau  
       2011-08-11 01:10:51 +08:00
    不好意思,上边那段我动过,应该是:

    main.py, line 252, in get
    self.values['page_title'] = self.site.title.decode('utf-8') + u' › ' + self.l10n.planes.decode('utf-8')
    File "/base/python_runtime/python_dist/lib/python2.5/encodings/utf_8.py", line 16, in decode
    return codecs.utf_8_decode(input, errors, True)
    UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-3: ordinal not in range(128)
    mimzy
        6
    mimzy  
       2012-11-30 14:29:04 +08:00
    @dimlau 这是一个困扰我许久的坟……昨天看了点中文编码的知识大概才懂,可能你已经解决了,这里还是分享一下。

    解决方法是,main.py 大约 250 行处,把

    self.values['page_title'] = self.site.title.decode('utf-8') + u' › ' + self.l10n.planes.decode('utf-8')

    前面那个 .decode('utf-8') 删除,就可以使用中文站点标题并且点击「位面」不会出错了。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5523 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 08:00 · PVG 16:00 · LAX 01:00 · JFK 04:00
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.