#9439 closed defect (fixed)
KeyError: 'trac/locale'
Reported by: | easteregg | Owned by: | Remy Blank |
---|---|---|---|
Priority: | high | Milestone: | 0.12.2 |
Component: | i18n | Version: | 0.12 |
Severity: | blocker | Keywords: | babel i18n |
Cc: | bountin@…, felix.schwarz@… | Branch: | |
Release Notes: | |||
API Changes: | |||
Internal Changes: |
Description
How to Reproduce
While doing a GET operation on /wiki
, Trac issued an internal error.
i upgraded to the version 0.12 and installed babel for i18n support, but everypage and the cmd trac-admin crashes with this error.
Request parameters:
{}
User agent: Opera/9.80 (Windows NT 6.1; U; en) Presto/2.5.24 Version/10.53
System Information
Trac | 0.12
|
Babel | 0.9.5
|
Genshi | 0.6
|
mod_python | 3.3.1
|
MySQL | server: "5.0.51a-24+lenny4", client: "5.0.51a", thread-safe: 1
|
MySQLdb | 1.2.2
|
Pygments | 0.10
|
Python | 2.5.2 (r252:60911, Jan 24 2010, 18:02:01) [GCC 4.3.2]
|
pytz | 2008c
|
RPC | 1.6.6
|
setuptools | 0.6c11
|
Subversion | 1.5.1 (r32289)
|
jQuery | 1.4.2
|
Enabled Plugins
AutocompleteUsers | 0.4.1
|
IniAdmin | 0.2
|
SvnAuthzAdminPlugin | 0.1.2.-Moved.to.Trac.0.11-
|
TracAccountManager | 0.2.1dev-r7737
|
TracTicketDelete | 2.0
|
TracWysiwyg | 0.2-r7772
|
TracXMLRPC | 1.6.6
|
Python Traceback
Traceback (most recent call last): File "build/bdist.linux-x86_64/egg/trac/web/main.py", line 513, in _dispatch_request dispatcher.dispatch(req) File "build/bdist.linux-x86_64/egg/trac/web/main.py", line 200, in dispatch chosen_handler) File "build/bdist.linux-x86_64/egg/trac/web/main.py", line 346, in _pre_process_request chosen_handler = filter_.pre_process_request(req, chosen_handler) File "build/bdist.linux-x86_64/egg/trac/versioncontrol/api.py", line 327, in pre_process_request if is_default(reponame): File "build/bdist.linux-x86_64/egg/trac/versioncontrol/api.py", line 32, in is_default return not reponame or reponame in ('(default)', _('(default)')) File "build/bdist.linux-x86_64/egg/trac/util/translation.py", line 186, in gettext if not self.isactive: File "build/bdist.linux-x86_64/egg/trac/util/translation.py", line 175, in isactive self.activate(get_locale(), env_path) File "build/bdist.linux-x86_64/egg/trac/util/translation.py", line 141, in activate locale_dir = pkg_resources.resource_filename('trac', 'locale') File "/usr/lib/python2.5/site-packages/setuptools-0.6c11-py2.5.egg/pkg_resources.py", line 882, in resource_filename self, resource_name File "/usr/lib/python2.5/site-packages/setuptools-0.6c11-py2.5.egg/pkg_resources.py", line 1352, in get_resource_filename return self._extract_resource(manager, zip_path) File "/usr/lib/python2.5/site-packages/setuptools-0.6c11-py2.5.egg/pkg_resources.py", line 1363, in _extract_resource zip_stat = self.zipinfo[zip_path] KeyError: 'trac/locale'
trac admin
svn:/usr/lib/python2.5/site-packages# trac-admin Traceback (most recent call last): File "/usr/bin/trac-admin", line 8, in <module> load_entry_point('Trac==0.12', 'console_scripts', 'trac-admin')() File "build/bdist.linux-x86_64/egg/trac/admin/console.py", line 524, in run File "build/bdist.linux-x86_64/egg/trac/util/translation.py", line 316, in activate File "build/bdist.linux-x86_64/egg/trac/util/translation.py", line 141, in activate File "/usr/lib/python2.5/site-packages/pkg_resources.py", line 882, in resource_filename """ % (old_exc, cache_path) File "/usr/lib/python2.5/site-packages/pkg_resources.py", line 1352, in get_resource_filename stat = os.stat(real_path) File "/usr/lib/python2.5/site-packages/pkg_resources.py", line 1363, in _extract_resource KeyError: 'trac/locale'
PS: there is no 0.12 stable version in your trac ;)
Attachments (6)
Change History (52)
comment:1 by , 15 years ago
Version: | → 0.12 |
---|
comment:2 by , 15 years ago
Cc: | added |
---|
comment:4 by , 15 years ago
How did you install Trac? From which archive? Are you sure you have the trac/locale
folder installed?
comment:5 by , 15 years ago
How do you install the trac/locale folder? TracInstall is not up-to-date for l10n.
comment:6 by , 15 years ago
I had the same issue. I did my upgrade using easy_install. It worked until I installed babel. If I remove the Babel egg directory from my python site-packages, everything works fine.
comment:7 by , 15 years ago
Owner: | set to |
---|
Ah, interesting. So installing Trac without Babel will not install the locales, and after installing Babel, Trac will look for the locales and die. We should probably make activate()
(even) more robust, or alternatively, make sure trac/locale
always exists.
Thanks for the additional info!
follow-up: 9 comment:8 by , 15 years ago
Very similar case I think:
In my case I removed babel egg a few times and reinstalled, but it still dosn't work
Oops… Trac detected an internal error: KeyError: 'trac/locale'
This is probably a local installation issue.
Before you do that, though, please first try searching for similar issues, as it is quite likely that this problem has been reported before. For questions about installation and configuration of Trac or its plugins, please try the mailing list instead of creating a ticket.
Otherwise, please ==== How to Reproduce ====
While doing a GET operation on /login
, Trac issued an internal error.
(please provide additional details here)
Request parameters:
{}
User agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; MS-RTC EA 2; OfficeLiveConnector.1.5; OfficeLivePatch.1.3)
System Information
Trac | 0.12
|
Babel | 0.9.5
|
CustomFieldAdmin | 0.2.2
|
Docutils | 0.6
|
Genshi | 0.6
|
mod_python | 3.3.1
|
Pygments | 1.2.2
|
pysqlite | 2.4.1
|
Python | 2.6.5 (r265:79063, Apr 16 2010, 13:28:26) [GCC 4.4.3]
|
pytz | 2010b
|
setuptools | 0.6c12
|
SQLite | 3.6.22
|
Subversion | 1.6.6 (r40053)
|
jQuery | 1.4.2
|
Enabled Plugins
CalendarPopUp | 0.0.2
|
IniAdmin | 0.2
|
SvnAuthzAdminPlugin | 0.1.2.-Moved.to.Trac.0.11-
|
TracAccountManager | 0.2.1dev-r7737
|
TracCustomFieldAdmin | 0.2.2
|
TracEmoticons | 0.1
|
TracGanttCalendarPlugin | 0.1
|
TracGoogleAnalytics | 0.2.2
|
TracMasterTickets | 2.1.3
|
TracPageToPDF | 0.2
|
TracProgressMeterMacro | 0.2
|
TracThemeEngine | 2.0.1
|
TracUserManagerPlugin | 0.4
|
TracWysiwyg | 0.2-r7350
|
Python Traceback
Traceback (most recent call last): File "build/bdist.linux-i686/egg/trac/web/main.py", line 513, in _dispatch_request dispatcher.dispatch(req) File "build/bdist.linux-i686/egg/trac/web/main.py", line 200, in dispatch chosen_handler) File "build/bdist.linux-i686/egg/trac/web/main.py", line 346, in _pre_process_request chosen_handler = filter_.pre_process_request(req, chosen_handler) File "build/bdist.linux-i686/egg/trac/versioncontrol/api.py", line 327, in pre_process_request if is_default(reponame): File "build/bdist.linux-i686/egg/trac/versioncontrol/api.py", line 32, in is_default return not reponame or reponame in ('(default)', _('(default)')) File "build/bdist.linux-i686/egg/trac/util/translation.py", line 186, in gettext if not self.isactive: File "build/bdist.linux-i686/egg/trac/util/translation.py", line 175, in isactive self.activate(get_locale(), env_path) File "build/bdist.linux-i686/egg/trac/util/translation.py", line 141, in activate locale_dir = pkg_resources.resource_filename('trac', 'locale') File "build/bdist.linux-i686/egg/pkg_resources.py", line 882, in resource_filename self, resource_name File "build/bdist.linux-i686/egg/pkg_resources.py", line 1352, in get_resource_filename return self._extract_resource(manager, zip_path) File "build/bdist.linux-i686/egg/pkg_resources.py", line 1363, in _extract_resource zip_stat = self.zipinfo[zip_path] KeyError: 'trac/locale' }}} a new bug report describing the problem and explain how to reproduce it. Python Traceback Most recent call last: File "build/bdist.linux-i686/egg/trac/web/main.py", line 513, in _dispatch_request Code fragment:Line 508 try: 509 if not env and env_error: 510 raise HTTPInternalError(env_error) 511 try: 512 dispatcher = RequestDispatcher(env) 513 dispatcher.dispatch(req) 514 except RequestDone: 515 pass 516 resp = req._response or [] 517 518 except HTTPException, e: Local variables:Name Value dispatcher <trac.web.main.RequestDispatcher object at 0x22171aec> e KeyError('trac/locale',) env <trac.env.Environment object at 0x21db436c> env_error None req <Request "GET '/login'"> resp [] File "build/bdist.linux-i686/egg/trac/web/main.py", line 200, in dispatch Code fragment:Line 195 if not req.path_info or req.path_info == '/': 196 chosen_handler = self.default_handler 197 # pre-process any incoming request, whether a handler 198 # was found or not 199 chosen_handler = self._pre_process_request(req, 200 chosen_handler) 201 except TracError, e: 202 raise HTTPInternalError(e) 203 if not chosen_handler: 204 if req.path_info.endswith('/'): 205 # Strip trailing / and redirect Local variables:Name Value chosen_handler <trac.web.auth.LoginModule object at 0x21fc778c> chrome <trac.web.chrome.Chrome object at 0x2217106c> err (<type 'exceptions.KeyError'>, KeyError('trac/locale',), <traceback object ... handler <trac.web.auth.LoginModule object at 0x21fc778c> req <Request "GET '/login'"> self <trac.web.main.RequestDispatcher object at 0x22171aec> File "build/bdist.linux-i686/egg/trac/web/main.py", line 346, in _pre_process_request Code fragment:Line 341 req.outcookie['trac_form_token']['secure'] = True 342 return req.outcookie['trac_form_token'].value 343 344 def _pre_process_request(self, req, chosen_handler): 345 for filter_ in self.filters: 346 chosen_handler = filter_.pre_process_request(req, chosen_handler) 347 return chosen_handler 348 349 def _post_process_request(self, req, *args): 350 nbargs = len(args) 351 resp = args Local variables:Name Value chosen_handler <trac.web.auth.LoginModule object at 0x21fc778c> filter_ <trac.versioncontrol.api.RepositoryManager object at 0x21fc754c> req <Request "GET '/login'"> self <trac.web.main.RequestDispatcher object at 0x22171aec> File "build/bdist.linux-i686/egg/trac/versioncontrol/api.py", line 327, in pre_process_request Code fragment:Line 322 def pre_process_request(self, req, handler): 323 from trac.web.chrome import Chrome, add_warning 324 if handler is not Chrome(self.env): 325 for reponame in self.repository_sync_per_request: 326 start = time.time() 327 if is_default(reponame): 328 reponame = '' 329 try: 330 repo = self.get_repository(reponame) 331 if repo: 332 repo.sync() Local variables:Name Value Chrome <class 'trac.web.chrome.Chrome'> add_warning <function add_warning at 0x21c9a87c> handler <trac.web.auth.LoginModule object at 0x21fc778c> reponame u'(default)' req <Request "GET '/login'"> self <trac.versioncontrol.api.RepositoryManager object at 0x21fc754c> start 1277220012.5685191 File "build/bdist.linux-i686/egg/trac/versioncontrol/api.py", line 32, in is_default Code fragment:Line 27 from trac.web.api import IRequestFilter 28 29 30 def is_default(reponame): 31 """Check whether `reponame` is the default repository.""" 32 return not reponame or reponame in ('(default)', _('(default)')) 33 34 35 class IRepositoryConnector(Interface): 36 """Provide support for a specific version control system.""" 37 Local variables:Name Value reponame u'(default)' File "build/bdist.linux-i686/egg/trac/util/translation.py", line 186, in gettext Code fragment:Line 181 return getattr(self.active, name) 182 183 def gettext(self, string, **kwargs): 184 def _gettext(): 185 return safefmt(self.active.ugettext(string), kwargs) 186 if not self.isactive: 187 return LazyProxy(_gettext) 188 return _gettext() 189 190 def dgettext(self, domain, string, **kwargs): 191 def _dgettext(): Local variables:Name Value _gettext <function _gettext at 0x221f164c> kwargs {} self <trac.util.translation.TranslationsProxy object at 0x21a1ce8c> string '(default)' File "build/bdist.linux-i686/egg/trac/util/translation.py", line 175, in isactive Code fragment:Line 170 @property 171 def isactive(self): 172 if self._current.args is not None: 173 get_locale, env_path = self._current.args 174 self._current.args = None 175 self.activate(get_locale(), env_path) 176 return self._current.translations is not None 177 178 # Delegated methods 179 180 def __getattr__(self, name): Local variables:Name Value env_path '/var/lib/trac/nachtwachtluna' get_locale <function <lambda> at 0x221f1534> self <trac.util.translation.TranslationsProxy object at 0x21a1ce8c> File "build/bdist.linux-i686/egg/trac/util/translation.py", line 141, in activate Code fragment:Line 136 def make_activable(self, get_locale, env_path=None): 137 self._current.args = (get_locale, env_path) 138 139 def activate(self, locale, env_path=None): 140 try: 141 locale_dir = pkg_resources.resource_filename('trac', 'locale') 142 except pkg_resources.ExtractionError: 143 return # delay extraction 144 t = Translations.load(locale_dir, locale or 'en_US') 145 if not t or t.__class__ is NullTranslations: 146 t = self._null_translations Local variables:Name Value env_path '/var/lib/trac/nachtwachtluna' locale None self <trac.util.translation.TranslationsProxy object at 0x21a1ce8c> File "build/bdist.linux-i686/egg/pkg_resources.py", line 882, in resource_filename Code fragment:Line 877 ) 878 879 def resource_filename(self, package_or_requirement, resource_name): 880 """Return a true filesystem path for specified resource""" 881 return get_provider(package_or_requirement).get_resource_filename( 882 self, resource_name 883 ) 884 885 def resource_stream(self, package_or_requirement, resource_name): 886 """Return a readable file-like object for specified resource""" 887 return get_provider(package_or_requirement).get_resource_stream( Local variables:Name Value package_or_requirement 'trac' resource_name 'locale' self <pkg_resources.ResourceManager instance at 0x2184cd2c> File "build/bdist.linux-i686/egg/pkg_resources.py", line 1352, in get_resource_filename Code fragment:Line 1347 zip_path = self._resource_to_zip(resource_name) 1348 eagers = self._get_eager_resources() 1349 if '/'.join(self._parts(zip_path)) in eagers: 1350 for name in eagers: 1351 self._extract_resource(manager, self._eager_to_zip(name)) 1352 return self._extract_resource(manager, zip_path) 1353 1354 def _extract_resource(self, manager, zip_path): 1355 1356 if zip_path in self._index(): 1357 for name in self._index()[zip_path]: Local variables:Name Value eagers [] manager <pkg_resources.ResourceManager instance at 0x2184cd2c> resource_name 'locale' self <pkg_resources.ZipProvider instance at 0x2214f6cc> zip_path 'trac/locale' File "build/bdist.linux-i686/egg/pkg_resources.py", line 1363, in _extract_resource Code fragment:Line 1358 last = self._extract_resource( 1359 manager, os.path.join(zip_path, name) 1360 ) 1361 return os.path.dirname(last) # return the extracted directory name 1362 1363 zip_stat = self.zipinfo[zip_path] 1364 t,d,size = zip_stat[5], zip_stat[6], zip_stat[3] 1365 date_time = ( 1366 (d>>9)+1980, (d>>5)&0xF, d&0x1F, # ymd 1367 (t&0xFFFF)>>11, (t>>5)&0x3F, (t&0x1F) * 2, 0, 0, -1 # hms, etc. 1368 ) Local variables:Name Value manager <pkg_resources.ResourceManager instance at 0x2184cd2c> self <pkg_resources.ZipProvider instance at 0x2214f6cc> zip_path 'trac/locale' File "build/bdist.linux-i686/egg/trac/web/main.py", line 513, in _dispatch_request dispatcher.dispatch(req) File "build/bdist.linux-i686/egg/trac/web/main.py", line 200, in dispatch chosen_handler) File "build/bdist.linux-i686/egg/trac/web/main.py", line 346, in _pre_process_request chosen_handler = filter_.pre_process_request(req, chosen_handler) File "build/bdist.linux-i686/egg/trac/versioncontrol/api.py", line 327, in pre_process_request if is_default(reponame): File "build/bdist.linux-i686/egg/trac/versioncontrol/api.py", line 32, in is_default return not reponame or reponame in ('(default)', _('(default)')) File "build/bdist.linux-i686/egg/trac/util/translation.py", line 186, in gettext if not self.isactive: File "build/bdist.linux-i686/egg/trac/util/translation.py", line 175, in isactive self.activate(get_locale(), env_path) File "build/bdist.linux-i686/egg/trac/util/translation.py", line 141, in activate locale_dir = pkg_resources.resource_filename('trac', 'locale') File "build/bdist.linux-i686/egg/pkg_resources.py", line 882, in resource_filename self, resource_name File "build/bdist.linux-i686/egg/pkg_resources.py", line 1352, in get_resource_filename return self._extract_resource(manager, zip_path) File "build/bdist.linux-i686/egg/pkg_resources.py", line 1363, in _extract_resource zip_stat = self.zipinfo[zip_path] System Information: User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; MS-RTC EA 2; OfficeLiveConnector.1.5; OfficeLivePatch.1.3) Trac 0.12 Babel 0.9.5 CustomFieldAdmin 0.2.2 Docutils 0.6 Genshi 0.6 mod_python 3.3.1 Pygments 1.2.2 pysqlite 2.4.1 Python 2.6.5 (r265:79063, Apr 16 2010, 13:28:26) [GCC 4.4.3] pytz 2010b setuptools 0.6c12 SQLite 3.6.22 Subversion 1.6.6 (r40053) jQuery 1.4.2 Enabled Plugins: CalendarPopUp 0.0.2 /usr/local/lib/python2.6/dist-packages/CalendarPopUp-0.0.2-py2.6.egg IniAdmin 0.2 /usr/local/lib/python2.6/dist-packages/IniAdmin-0.2-py2.6.egg SvnAuthzAdminPlugin 0.1.2.-Moved.to.Trac.0.11- /usr/local/lib/python2.6/dist-packages/SvnAuthzAdminPlugin-0.1.2._Moved.to.Trac.0.11_-py2.6.egg TracAccountManager 0.2.1dev-r7737 /usr/local/lib/python2.6/dist-packages/TracAccountManager-0.2.1dev_r7737-py2.6.egg TracCustomFieldAdmin 0.2.2 /usr/local/lib/python2.6/dist-packages/TracCustomFieldAdmin-0.2.2-py2.6.egg TracEmoticons 0.1 /usr/local/lib/python2.6/dist-packages/TracEmoticons-0.1-py2.6.egg TracGanttCalendarPlugin 0.1 /usr/local/lib/python2.6/dist-packages/TracGanttCalendarPlugin-0.1-py2.6.egg TracGoogleAnalytics 0.2.2 /usr/local/lib/python2.6/dist-packages/TracGoogleAnalytics-0.2.2-py2.6.egg TracMasterTickets 2.1.3 /usr/local/lib/python2.6/dist-packages/TracMasterTickets-2.1.3-py2.6.egg TracPageToPDF 0.2 /usr/local/lib/python2.6/dist-packages/TracPageToPDF-0.2-py2.6.egg TracProgressMeterMacro 0.2 /usr/local/lib/python2.6/dist-packages/TracProgressMeterMacro-0.2-py2.6.egg TracThemeEngine 2.0.1 /usr/local/lib/python2.6/dist-packages/TracThemeEngine-2.0.1-py2.6.egg TracUserManagerPlugin 0.4 /usr/local/lib/python2.6/dist-packages/TracUserManagerPlugin-0.4-py2.6.egg TracWysiwyg 0.2-r7350 /usr/local/lib/python2.6/dist-packages/TracWysiwyg-0.2_r7350-py2.6.egg
follow-up: 12 comment:9 by , 15 years ago
Replying to ton.rademaker@…:
In my case I removed babel egg a few times and reinstalled, but it still dosn't work
You should re-install Trac after installing Babel.
follow-ups: 21 23 comment:10 by , 15 years ago
Remy, I see you've grabbed the ticket. Do you have a plan already?
If not, I'd like to try the approach of early instantiation of Locale objects, which would not only catch the fact they're not present at startup time and enable us to cope with the failure, but in addition would avoid:
- costly instantiation of Locale, for each request
- limit concurrent first time extraction issues (#9107 take 2)
If this is fixed, together with the numerous translations updates we received lately, this could warrant an early 0.12.1 release….
comment:11 by , 15 years ago
No, I didn't have a precise plan other than to analyze the issue, so feel free to beat me to it.
About 0.12.1, let's create the 0.12-stable branch and try to get a few patches from 0.12.1 in as well.
comment:12 by , 15 years ago
Replying to rblank:
Replying to ton.rademaker@…:
In my case I removed babel egg a few times and reinstalled, but it still dosn't work
You should re-install Trac after installing Babel.
I did that, but no success yet, I can't afford removing and reinstalling trac, since I am not fluent enough in this to risk loosing my darabase of tickets…
follow-up: 14 comment:13 by , 15 years ago
Re-installing from source will work for sure (grab the .tar.gz or .zip from TracDownload, go in the Trac-0.12/ folder and do python setup.py install
).
I'll test with easy_install
, but I'm pretty sure you need to specify easy_install -U Trac
to get it to work in this situation.
follow-up: 15 comment:14 by , 15 years ago
… you need to specify
easy_install -U Trac
to get it to work in this situation.
Actually that's not enough, as the version didn't change the package won't be rebuilt.
So you really need to "uninstall" Trac first, which should be pretty trivial anyway: find the "Trac-0.12…egg" file in your Python installation (usually below a site-packages
folder, e.g. lib/python2.7/site-packages/Trac-0.12-py2.7.egg
), and delete it.
comment:15 by , 15 years ago
Replying to cboos:
… you need to specify
easy_install -U Trac
to get it to work in this situation.Actually that's not enough, as the version didn't change the package won't be rebuilt.
So you really need to "uninstall" Trac first, which should be pretty trivial anyway: find the "Trac-0.12…egg" file in your Python installation (usually below a
site-packages
folder, e.g.lib/python2.7/site-packages/Trac-0.12-py2.7.egg
), and delete it.
THIS DID IT! Great, thanks!!! I am a happy user again!
follow-up: 18 comment:16 by , 15 years ago
Also works for me :)
- Deleted Trac egg
- easy_install -U babel
- easy_install -U trac
- Apache Restart
- German Trac :)
comment:17 by , 14 years ago
i encountered the same issue. after i installed Bable, i reinstalled it after i installed Babel, just rm the Tac egg
follow-up: 19 comment:18 by , 14 years ago
Replying to anonymous:
Also works for me :)
- Deleted Trac egg
- easy_install -U babel
- easy_install -U trac
- Apache Restart
- German Trac :)
thanks a lot! ;)
comment:19 by , 14 years ago
comment:21 by , 14 years ago
Replying to cboos:
Remy, I see you've grabbed the ticket. Do you have a plan already?
If not, I'd like to try the approach of early instantiation of Locale objects, which would not only catch the fact they're not present at startup time and enable us to cope with the failure, but in addition would avoid:
- costly instantiation of Locale, for each request
- limit concurrent first time extraction issues (#9107 take 2)
Early loading also requires some additional means in order to allow one to replace existing locales by newer revisions without having to restart the server all over again. So the locale manager or whatever is repsonsible for loading the resources should also take into account changes to the locale files and reload them whenever necessary.
comment:22 by , 14 years ago
Cc: | added |
---|
comment:23 by , 14 years ago
Replying to cboos:
I'd like to try the approach of early instantiation of Locale objects, which would not only catch the fact they're not present at startup time and enable us to cope with the failure
I don't remember what I meant there with "cope with the failure". Showing an explicit error message and exit? I don't think we can trigger a "re-install" (not to mention a deploy, for the js/messages).
comment:24 by , 14 years ago
The simple fix committed in [10134] fixes the original issue, and allows running from a locale-less egg on a machine with Babel installed. It's still necessary to install Babel before Trac if translations should be available, but there's not much we can do about that.
Christian, would you like to keep this ticket open for your experiments in "early instantiation", or should we close it?
follow-up: 26 comment:25 by , 14 years ago
I fear that failing silently is going to be worse than having the exception, as we are going to get a lot of "I installed Babel but can't get Trac in my language, got no error, and there's nothing in the log…".
We could pass env.log
through make_activable
and activate
, and warn there (it's the easiest thing to do, since we do delayed activation).
For the early activation, I'll make a note in TracDev/ToDo.
comment:26 by , 14 years ago
Replying to cboos:
I fear that failing silently is going to be worse than having the exception, as we are going to get a lot of "I installed Babel but can't get Trac in my language, got no error, and there's nothing in the log…".
Not really. At least the installation works, and the next question would be "Does your Trac egg contain files in trac/locale?".
We could pass
env.log
throughmake_activable
andactivate
, and warn there (it's the easiest thing to do, since we do delayed activation).
That's what I wanted to do, but the absence of logger made me drop the idea. It's still a good idea, so I'll implement it.
comment:27 by , 14 years ago
#9647 was closed as a duplicate, and has a different exception thrown at a different location. So I'll need to work on it some more (probably catching Exception
in both locations where we resolve trac.locale
).
comment:28 by , 14 years ago
9439-log-activate-r10144.patch logs errors during listing of locales and activation… and is quite ugly. I'm not sure this is the right approach.
How about logging unconditionally in get_available_locales()
when no locales are found, and just dropping the exception in activate()
? This should be enough to diagnose any issues.
comment:29 by , 14 years ago
9439-log-missing-r10145.patch is quite a bit simpler, and only logs when no locales are found, assuming this means that locale data is missing. My preference goes to this one.
Thoughts?
comment:31 by , 14 years ago
The second eventually, but I still have the impression we could come with something easier, let me have a try.
by , 14 years ago
Attachment: | 9493-has_babel-False.patch added |
---|
add an explicit warning in the log and in the About page when Babel was installed after Trac and no catalogs are available. Applies on r10152.
comment:32 by , 14 years ago
Please try out attachment:9493-has_babel-False.patch. It's less intrusive on the translation API, and goes in the direction of early pre-loading of the catalogs (though that will not happen on 0.12-stable, the way I see it now).
follow-up: 34 comment:33 by , 14 years ago
Haven't tested the patch yet, but all good ideas, and nice visibility in the system info. We should probably leave the translation marker out permanently, as the text will end up in the semi-automatic bug reports. Or how about adding the comment to the "Language" preference panel instead? That's certainly one location that wouldn't be overlooked. Or even both: a longer explanation on the "Language" panel, and a short marker in the system info for us to see in the bug reports.
I would catch Exception
instead of (KeyError, WindowsError)
though, as we don't really know what kinds of exceptions resource_listdir()
will throw (the KeyError
happened in resource_filename()
and not in resource_listdir()
, which raised an OSError
(and WindowsError
doesn't exist on non-Windows platforms (except in our trac.util
))).
(OT: You know you have been programming too much when you start nesting parentheses in plain English :)
comment:34 by , 14 years ago
Replying to rblank:
Haven't tested the patch yet, but all good ideas, and nice visibility in the system info. We should probably leave the translation marker out permanently, as the text will end up in the semi-automatic bug reports.
Not only that, but I just realized that by definition this one will never be shown translated…
Or how about adding the comment to the "Language" preference panel instead? That's certainly one location that wouldn't be overlooked. Or even both: a longer explanation on the "Language" panel, and a short marker in the system info for us to see in the bug reports.
Ok, but for 0.12.2 only because of the string freeze. See no-Babel-prefs-language.patch.
I would catch
Exception
instead of(KeyError, WindowsError)
though, as we don't really know what kinds of exceptionsresource_listdir()
will throw (theKeyError
happened inresource_filename()
and not inresource_listdir()
, which raised anOSError
(andWindowsError
doesn't exist on non-Windows platforms (except in ourtrac.util
))).
Right, see updated 9493-has_babel-False.2.patch. I'd like commit that before the rc1 this evening, so it would be nice if it gets some real testing before (worksforme so far).
(OT: You know you have been programming too much when you start nesting parentheses in plain English :)
Heh. I don't know how effective it is, but since a while I do a rewrite pass on all my texts in order to remove the parentheses… (though I never reached 3 levels of nesting (as far as I remember)) ;-)
by , 14 years ago
Attachment: | no-Babel-prefs-language.patch added |
---|
Add more information in the Language preference panel.
follow-up: 36 comment:35 by , 14 years ago
Doing the check once at module load time is prone to repeat a symptom similar as #9107, except now certain processes would have translations activated, and others wouldn't.
I was thinking something simpler (see 9439-notify-missing-r1052.patch), with a different message for TRAC_ADMIN
and for normal users. It should also be reasonably robust against transient failures, like bad permissions on the egg cache, and not require a server restart after fixing the issue.
by , 14 years ago
Attachment: | 9439-notify-missing-r1052.patch added |
---|
Handle missing locales and notify user and admin.
follow-up: 37 comment:36 by , 14 years ago
Replying to rblank:
Doing the check once at module load time is prone to repeat a symptom similar as #9107, except now certain processes would have translations activated, and others wouldn't.
No, an ExtractionError
would still have left has_babel
to True
and the delayed activation would still have worked, so I think there was no regression on #9107.
I was thinking something simpler (see 9439-notify-missing-r1052.patch), with a different message for
TRAC_ADMIN
and for normal users. It should also be reasonably robust against transient failures, like bad permissions on the egg cache, and not require a server restart after fixing the issue.
That's nevertheless better. But you shouldn't commit the prefs_language.html part as we promised a string freeze ;-)
comment:37 by , 14 years ago
Replying to cboos:
But you shouldn't commit the prefs_language.html part as we promised a string freeze ;-)
Sure, no worries. Thanks for the review!
comment:39 by , 14 years ago
comment:40 by , 14 years ago
I meant a self.log.warning()
, as I did in my patch.
But I was still thinking that this would only happen once in the Component.__init__
, now we have ISystemInfoProvider.get_system_info()
so this would happen everytime that method is invoked. That's still not that often, so I think this wouldn't pollute the log too much and would be occasionally useful, for the admins who have the reflex to look in there when troubleshooting.
comment:41 by , 14 years ago
Ok, logging statement added in [10156]. I'll keep this ticket open (and retarget it to 0.12.2 once it is defined) for adding the message to the preference panel.
comment:42 by , 14 years ago
Milestone: | 0.12.1 → 0.12.2 |
---|
comment:44 by , 14 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
The message on the language preference panel has been committed in [10244].
Is your egg-cache location writable?
BTW, you don't need TracTicketDelete anymore, just enable
tracopt.ticket.deleter.*
.