CcSelectorPlugin fails without Babel

20 views
Skip to first unread message

Clemens Feige

unread,
Mar 24, 2024, 8:35:54 AMMar 24
to trac-...@googlegroups.com
Hello

Summary:
The CcSelectorPlugin produces an error message if Babel is not installed.

https://trac-hacks.org/wiki/CcSelectorPlugin

Background:

I have been using the CcSelectorPlugin for many years. Now I
re-installed my TRAC server (now with TRAC 1.6). Intentionally I decided
to install TRAC without Babel because we do not want multi-lingual support.

After installing CcSelectorPlugin (Version 0.3, TrackHacks Revision
18597, from Nov. 2023, installation via PIP) it presents the following
error when I click the "CC Selection" button:

Trac detected an internal error:
KeyError: 'dgettext'

The Python Traceback points to "site-packages/trac/util/translation.py".

Of course the solution is to install Babel, which will solve the problem.

Nevertheless IMHO either a plug-in should clearly state its dependencies
during installation (or during run-time or in the documentation). Best
of course would be would be, if the plug-in could run without Babel.
After all, Babel is just optional for TRAC.

Don't get me wrong. I do not complain or blame. I just want to avoid
that people remove this nice plug-in just because they are facing a
"mysterious" error and do not see the simply solution to install Babel.

Unfortunately I know only little about Python and nothing about Babel
and thus cannot offer a patch. Shall I file a bug report?

Best regards
Clemens




Jun Omae

unread,
Mar 24, 2024, 8:46:54 AMMar 24
to trac-...@googlegroups.com
Could you please post entire of the traceback?

Jun Omae <jun...@gmail.com> (大前 潤)

Clemens Feige

unread,
Mar 25, 2024, 4:08:29 AMMar 25
to trac-...@googlegroups.com
> On Sun, Mar 24, 2024 at 21:35 Clemens Feige <c.f...@osypkamed.com
> <mailto:c.f...@osypkamed.com>> wrote:
>
> Hello
>
> Summary:
> The CcSelectorPlugin produces an error message if Babel is not
> installed.
>
> https://trac-hacks.org/wiki/CcSelectorPlugin
> <https://trac-hacks.org/wiki/CcSelectorPlugin>
>
> Background:
>
> I have been using the CcSelectorPlugin for many years. Now I
> re-installed my TRAC server (now with TRAC 1.6). Intentionally I decided
> to install TRAC without Babel because we do not want multi-lingual
> support.
>
> After installing CcSelectorPlugin (Version 0.3, TrackHacks Revision
> 18597, from Nov. 2023, installation via PIP) it presents the following
> error when I click the "CC Selection" button:
>
> Trac detected an internal error:
> KeyError: 'dgettext'
>
> The Python Traceback points to "site-packages/trac/util/translation.py".
>
> Of course the solution is to install Babel, which will solve the
> problem.
>
> Nevertheless IMHO either a plug-in should clearly state its dependencies
> during installation (or during run-time or in the documentation). Best
> of course would be, if the plug-in could run without Babel.
Here is the traceback.

Python Traceback
File "/data/trac/python/lib/python3.11/site-packages/trac/web/main.py",
line 609, in dispatch_request dispatcher.dispatch(req)
File "/data/trac/python/lib/python3.11/site-packages/trac/web/main.py",
line 301, in dispatch raise e
File "/data/trac/python/lib/python3.11/site-packages/trac/web/main.py",
line 265, in dispatch output = chrome.render_template(req, template,
data, metadata)
File
"/data/trac/python/lib/python3.11/site-packages/trac/web/chrome.py",
line 1381, in render_template template, data =
self.prepare_template(req, filename, data, text,
File
"/data/trac/python/lib/python3.11/site-packages/trac/web/chrome.py",
line 1487, in prepare_template domain_functions =
translation.domain_functions(domain, symbols)
File
"/data/trac/python/lib/python3.11/site-packages/trac/util/translation.py",
line 92, in domain_functions return [_functions[s] for s in symbols]
File
"/data/trac/python/lib/python3.11/site-packages/trac/util/translation.py",
line 92, in <listcomp> return [_functions[s] for s in symbols]

One can also "simulate" the issue by temporarily renaming the babel
installation directory. See attached screen shot.

Clemens
ccselector_oops.jpg

Jun Omae

unread,
Mar 25, 2024, 6:31:41 AMMar 25
to trac-...@googlegroups.com
On 2024/03/25 17:08, Clemens Feige wrote:
> Here is the traceback.
>
> Python Traceback
> File "/data/trac/python/lib/python3.11/site-packages/trac/web/main.py", line 609, in dispatch_request
> dispatcher.dispatch(req)
> File "/data/trac/python/lib/python3.11/site-packages/trac/web/main.py", line 301, in dispatch
> raise e
> File "/data/trac/python/lib/python3.11/site-packages/trac/web/main.py", line 265, in dispatch
> output = chrome.render_template(req, template, data, metadata)
> File "/data/trac/python/lib/python3.11/site-packages/trac/web/chrome.py", line 1381, in render_template
> template, data = self.prepare_template(req, filename, data, text,
> File "/data/trac/python/lib/python3.11/site-packages/trac/web/chrome.py", line 1487, in prepare_template
> domain_functions = translation.domain_functions(domain, symbols)
> File "/data/trac/python/lib/python3.11/site-packages/trac/util/translation.py", line 92, in domain_functions
> return [_functions[s] for s in symbols]
> File "/data/trac/python/lib/python3.11/site-packages/trac/util/translation.py", line 92, in <listcomp>
> return [_functions[s] for s in symbols]
>
> One can also "simulate" the issue by temporarily renaming the babel
> installation directory. See attached screen shot.

Thanks for the feedback.

> Unfortunately I know only little about Python and nothing about Babel
> and thus cannot offer a patch. Shall I file a bug report?

That is an issue of Trac core since 1.4.x.
It is reproduced with Trac 1.4.4 and 1.6 without Babel.
Please report it to trac.edgewall.org/newticket.


$ python3.11 -m venv /dev/shm/trac-1.6
$ /dev/shm/trac-1.6/bin/pip install -q Trac~=1.6.0
$ /dev/shm/trac-1.6/bin/python
Python 3.11.8 (main, Feb 25 2024, 16:41:26) [GCC 9.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import babel
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'babel'
>>> import trac
>>> trac.__version__
'1.6'
>>> from trac.test import EnvironmentStub, MockRequest
>>> from trac.web.chrome import Chrome
>>> env = EnvironmentStub()
>>> req = MockRequest(env)
>>> chrome = Chrome(env)
>>> chrome.prepare_template(req, 'layout.html', {}, domain='messages')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/dev/shm/trac-1.6/lib/python3.11/site-packages/trac/web/chrome.py", line 1487, in prepare_template
domain_functions = translation.domain_functions(domain, symbols)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/dev/shm/trac-1.6/lib/python3.11/site-packages/trac/util/translation.py", line 92, in domain_functions
return [_functions[s] for s in symbols]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/dev/shm/trac-1.6/lib/python3.11/site-packages/trac/util/translation.py", line 92, in <listcomp>
return [_functions[s] for s in symbols]
~~~~~~~~~~^^^
KeyError: 'dgettext'
>>>


$ virtualenv -p /usr/bin/python2.7 /dev/shm/trac-1.4
$ /dev/shm/trac-1.4/bin/pip install -q Trac~=1.4.0
$ /dev/shm/trac-1.4/bin/python
Python 2.7.18 (default, Jul 1 2022, 12:27:04)
[GCC 9.4.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import babel
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named babel
>>> import trac
>>> trac.__version__
'1.4.4'
>>> from trac.test import EnvironmentStub, MockRequest
>>> from trac.web.chrome import Chrome
>>> env = EnvironmentStub()
>>> req = MockRequest(env)
>>> chrome = Chrome(env)
>>> chrome.prepare_template(req, 'layout.html', {}, domain='messages')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/dev/shm/trac-1.4/lib/python2.7/site-packages/trac/web/chrome.py", line 1614, in prepare_template
domain_functions = translation.domain_functions(domain, symbols)
File "/dev/shm/trac-1.4/lib/python2.7/site-packages/trac/util/translation.py", line 92, in domain_functions
return [_functions[s] for s in symbols]
KeyError: 'dngettext'
>>>


--

Clemens Feige

unread,
Mar 25, 2024, 7:31:59 AMMar 25
to trac-...@googlegroups.com
> On Sun, Mar 24, 2024 at 21:35 Clemens wrote:
>
> Hello
>
> Summary:
> The CcSelectorPlugin produces an error message if Babel is not installed.
>
> https://trac-hacks.org/wiki/CcSelectorPlugin


Jun Omae wrote on 25.03.2024 at 11:31:
[snip]
>
> Thanks for the feedback.
>
[snip]
>
> That is an issue of Trac core since 1.4.x.
> It is reproduced with Trac 1.4.4 and 1.6 without Babel.
> Please report it to trac.edgewall.org/newticket.
>
[snip]

I created the ticket:

https://trac.edgewall.org/ticket/13745

Clemens
Reply all
Reply to author
Forward
0 new messages