|
From: <sub...@co...> - 2007-05-25 01:27:52
|
Author: ianb
Date: 2007-05-24 19:27:48 -0600 (Thu, 24 May 2007)
New Revision: 2698
Modified:
FormEncode/trunk/docs/news.txt
FormEncode/trunk/formencode/api.py
Log:
work with zip files (as with py2exe)
Modified: FormEncode/trunk/docs/news.txt
===================================================================
--- FormEncode/trunk/docs/news.txt 2007-05-21 22:05:33 UTC (rev 2697)
+++ FormEncode/trunk/docs/news.txt 2007-05-25 01:27:48 UTC (rev 2698)
@@ -14,6 +14,9 @@
* Added encoding parameter to htmlfill, which will handle cases when mixed
str and unicode objects are used (turning all str objects into unicode)
+* Be friendlier when loaded from a zip file (as with py2exe);
+ previously only egg zip files would work.
+
0.7.1
-----
Modified: FormEncode/trunk/formencode/api.py
===================================================================
--- FormEncode/trunk/formencode/api.py 2007-05-21 22:05:33 UTC (rev 2697)
+++ FormEncode/trunk/formencode/api.py 2007-05-25 01:27:48 UTC (rev 2698)
@@ -6,7 +6,10 @@
import textwrap
import re
import os
-from pkg_resources import resource_filename
+try:
+ from pkg_resources import resource_filename
+except ImportError:
+ resource_filename = None
__all__ = ['NoDefault', 'Invalid', 'Validator', 'Identity',
'FancyValidator', 'is_validator']
@@ -14,7 +17,13 @@
import gettext
def get_localedir():
- return resource_filename(__name__, "/i18n")
+ if resource_filename is not None:
+ try:
+ return resource_filename(__name__, "/i18n")
+ except NotImplementedError:
+ # resource_filename doesn't work with non-egg zip files
+ pass
+ return os.path.join(os.path.dirname(__file__), 'i18n')
def set_stdtranslation(domain="FormEncode", languages=None, \
localedir = get_localedir()):
|