tag:blogger.com,1999:blog-2144470051777636547.post4972763754527016524..comments2023-10-19T20:19:36.170+09:00Comments on Moon blue diary: Using zipped pytz on GAEtmatsuohttp://www.blogger.com/profile/09975209669204600556noreply@blogger.comBlogger6125tag:blogger.com,1999:blog-2144470051777636547.post-87861615210153204422009-06-04T16:35:14.311+09:002009-06-04T16:35:14.311+09:00For a simpler uses (datetime conversion or timezon...For a simpler uses (datetime conversion or timezone correctness check), <br /><br />try: <br /><br /><a href="http://timezonetimezone.appspot.com" rel="nofollow">http://timezonetimezone.appspot.com</a> <br /><br />You can figure out how to use it in 5 mins.Junghwan Parkhttps://www.blogger.com/profile/13614767424342544034noreply@blogger.comtag:blogger.com,1999:blog-2144470051777636547.post-64298354889914981402009-06-04T16:34:53.236+09:002009-06-04T16:34:53.236+09:00This comment has been removed by the author.Junghwan Parkhttps://www.blogger.com/profile/13614767424342544034noreply@blogger.comtag:blogger.com,1999:blog-2144470051777636547.post-70584797622013532052009-03-06T08:43:00.000+09:002009-03-06T08:43:00.000+09:00This entry is obsolete. Please reffer to a newer o...This entry is obsolete. Please reffer to a <A HREF="http://takashi-matsuo.blogspot.com/2008/07/using-newest-zipped-pytz-on-gae.html" REL="nofollow">newer one</A>.tmatsuohttps://www.blogger.com/profile/09975209669204600556noreply@blogger.comtag:blogger.com,1999:blog-2144470051777636547.post-18977084182769392062009-01-09T02:30:00.000+09:002009-01-09T02:30:00.000+09:00When I set that up, it took about 10 seconds for p...When I set that up, it took about 10 seconds for pytz to import on my development server because it was loading the zip file repeatedly. Moving <BR/><BR/>zoneinfo = zipfile.ZipFile(os.path.join(os.path.dirname(__file__), 'zoneinfo.zip'))<BR/><BR/>outside the function fixed that though. Thanks for the info!Scotthttps://www.blogger.com/profile/11963778620604790960noreply@blogger.comtag:blogger.com,1999:blog-2144470051777636547.post-12760613357159397482008-07-13T21:07:00.000+09:002008-07-13T21:07:00.000+09:00Shame on me!I didn't know the existence of pytz ne...Shame on me!<BR/>I didn't know the existence of pytz newer version. Your suggestion really makes sense.<BR/><BR/>Thanks for your imformation Stefano!tmatsuohttps://www.blogger.com/profile/09975209669204600556noreply@blogger.comtag:blogger.com,1999:blog-2144470051777636547.post-66052822564188346342008-07-12T19:48:00.000+09:002008-07-12T19:48:00.000+09:00Unfortunately, zipping pytz does not work with rec...Unfortunately, zipping pytz does not work with recent versions of pytz, like <A HREF="http://pypi.python.org/pypi/pytz/" REL="nofollow">version 2008c available from PyPI</A>.<BR/><BR/>Pytz 2008c opens zoneinfo files using __file__, which breaks if the files are in a zip.<BR/><BR/>My solution at the moment is to zip only the zoneinfo directory inside pytz, and then replace the function open_resource inside pytz/__init__.py with the following:<BR/><BR/>import zipfile<BR/>from cStringIO import StringIO<BR/><BR/>def open_resource(name):<BR/> """Open a resource from the zoneinfo subdir for reading.<BR/> """<BR/> name_parts = name.lstrip('/').split('/')<BR/> for part in name_parts:<BR/> if part == os.path.pardir or os.path.sep in part:<BR/> raise ValueError('Bad path segment: %r' % part)<BR/> zoneinfo = zipfile.ZipFile(os.path.join(os.path.dirname(__file__), 'zoneinfo.zip'))<BR/> return StringIO(zoneinfo.read(os.path.join('zoneinfo', *name_parts)))Stefanohttps://www.blogger.com/profile/17333165406922951563noreply@blogger.com