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

Project Babel 2.5.0-dev notifications页面出错

  •  
  •   lin · 2011 年 7 月 22 日 · 6478 次点击
    这是一个创建于 5287 天前的主题,其中的信息可能已经有所发展或是发生改变。
    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 年 8 月 10 日
    在config.py里加个site_key的配置嘛
    Livid
        2
    Livid  
    MOD
    PRO
       2011 年 8 月 10 日 via iPhone
    Exactly.
    bjhyyc
        3
    bjhyyc  
       2011 年 8 月 10 日
    @Livid 新版位面显示错误
    dimlau
        4
    dimlau  
       2011 年 8 月 11 日
    @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 年 8 月 11 日
    不好意思,上边那段我动过,应该是:

    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 日
    @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   ·   Solana   ·   5140 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 35ms · UTC 01:27 · PVG 09:27 · LAX 17:27 · JFK 20:27
    ♥ Do have faith in what you're doing.