def init_zoneinfo():
"""
Add each zone info to the datastore. This will overwrite existing zones.
This must be called before the AppengineTimezoneLoader will work.
"""
import os, logging
from zipfile import ZipFile
zoneobjs = []
zoneinfo_path = os.path.abspath(os.path.join(os.path.dirname(__file__),
'zoneinfo.zip'))
with ZipFile(zoneinfo_path) as zf:
for zfi in zf.filelist:
key = ndb.Key('Zoneinfo', zfi.filename, namespace=NDB_NAMESPACE)
zobj = Zoneinfo(key=key, data=zf.read(zfi))
zoneobjs.append(zobj)
logging.info("Adding %d timezones to the pytz-appengine database" %
len(zoneobjs)
)
ndb.put_multi(zoneobjs)
评论列表
文章目录