__init__.py 文件源码

python
阅读 17 收藏 0 点赞 0 评论 0

项目:start 作者: argeweb 项目源码 文件源码
def open_resource(name):
    """Load the object from the datastore"""
    import logging
    from cStringIO import StringIO
    try:
        data = ndb.Key('Zoneinfo', name, namespace=NDB_NAMESPACE).get().data
    except AttributeError:
        # Missing zone info; test for GMT
        # which would be there if the Zoneinfo has been initialized.
        if ndb.Key('Zoneinfo', 'GMT', namespace=NDB_NAMESPACE).get():
            # the user asked for a zone that doesn't seem to exist.
            logging.exception(
                "Requested zone '%s' is not in the database." % name)
            raise

        # we need to initialize the database
        init_zoneinfo()
        return open_resource(name)

    return StringIO(data)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号