Ticket #8084 (closed Bug: fixed)
PlacelessTranslationService getLanguageError when .po file moves
| Reported by: | smcmahon | Owned by: | hannosch |
|---|---|---|---|
| Priority: | major | Milestone: | 3.1.1 |
| Component: | Internationalization | Keywords: | PlacelessTranslationService getLanguage |
| Cc: |
Description
If a .po file has moved -- for example if a product with .po files has been eggified -- PTS will fail to load with a misleading error:
Traceback (most recent call last):
File "/home/steve/p3buildout/parts/zope2/lib/python/Zope2/Startup/run.py", line 56, in ?
run()
File "/home/steve/p3buildout/parts/zope2/lib/python/Zope2/Startup/run.py", line 21, in run
starter.prepare()
File "/home/steve/p3buildout/parts/zope2/lib/python/Zope2/Startup/__init__.py", line 102, in prepare
self.startZope()
File "/home/steve/p3buildout/parts/zope2/lib/python/Zope2/Startup/__init__.py", line 278, in startZope
Zope2.startup()
File "/home/steve/p3buildout/parts/zope2/lib/python/Zope2/__init__.py", line 47, in startup
_startup()
File "/home/steve/p3buildout/parts/zope2/lib/python/Zope2/App/startup.py", line 102, in startup
OFS.Application.initialize(application)
File "/home/steve/p3buildout/parts/zope2/lib/python/OFS/Application.py", line 309, in initialize
initializer.initialize()
File "/home/steve/p3buildout/parts/zope2/lib/python/OFS/Application.py", line 338, in initialize
self.install_products()
File "/home/steve/p3buildout/parts/zope2/lib/python/OFS/Application.py", line 603, in install_products
return install_products(app)
File "/home/steve/p3buildout/parts/zope2/lib/python/OFS/Application.py", line 634, in install_products
folder_permissions, raise_exc=debug_mode)
File "/home/steve/p3buildout/parts/zope2/lib/python/OFS/Application.py", line 786, in install_product
initmethod(context)
File "/home/steve/p3buildout/parts/plone/PlacelessTranslationService/__init__.py", line 151, in initialize
cp_ts._load_i18n_dir(os.path.join(prod[3], prod[1], 'i18n'))
File "/home/steve/p3buildout/parts/plone/PlacelessTranslationService/PlacelessTranslationService.py", line 320, in _load_i18n_dir
self._load_catalog_file(name, basepath)
File "/home/steve/p3buildout/parts/plone/PlacelessTranslationService/PlacelessTranslationService.py", line 288, in _load_catalog_file
self.addCatalog(BrokenMessageCatalog(id, pofile, exc))
File "/home/steve/p3buildout/parts/plone/PlacelessTranslationService/PlacelessTranslationService.py", line 458, in addCatalog
lang = catalog.getLanguage()
AttributeError: getLanguage
This may only happen when running in debug mode or updates, when translation files are reloaded on start.
As far as I can tell, what's really going on is that PTS has cached the pathname for the source .po file in the ZODB. It looks that up by an id that has not changed with the move, gets the old pathname and tries to reopen the old file. An IOError is swallowed and only when later code tries getLanguage on the broken catalog object is a problem detected.
Change History
comment:2 Changed 4 years ago by smcmahon
Workaround for those who don't need PTS. Disable it by adding to buildout.cfg:
zope-conf-additional =
<environment>
DISABLE_PTS true
</environment>
Thanks, wiggy!
comment:3 Changed 4 years ago by naro
If you need PTS, use workaround above to start your Zope instance, go to Control_Panel/ Placeless Translation Service, click "Select All" at the bottom and delete all objects.
Finally remove DISABLE_PTS workaround and restart your zope instance. PTS should work again.

This will also crop up with a relocated Data.fs if the old instance isn't still around at the old path.