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)
评论列表
文章目录