Edgewall Software
Modify

Opened 9 years ago

Closed 9 years ago

#12330 closed defect (fixed)

running bdist_egg on svn checkout of TracSpamFilter does not include translations, which causes a crash

Reported by: Simon Fondrie-teitler <trac@…> Owned by: Ryan J Ollos
Priority: normal Milestone: plugin - spam-filter
Component: plugin/spamfilter Version:
Severity: normal Keywords:
Cc: Branch:
Release Notes:

Fixed KeyError for Trac with Babel when egg created without Babel installed.

API Changes:
Internal Changes:

Description

Setup.py includes locale/*/LC_MESSAGES/*.mo, however python setup.py bdist_egg does not compile the .po files to .mo files, so nothing gets included in the artifact. This causes trac to crash with the following error:

Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/trac/web/main.py", line 522, in dispatch_request
    return _dispatch_request(req, env, env_error)
  File "/usr/lib/python2.7/dist-packages/trac/web/main.py", line 561, in _dispatch_request
    send_internal_error(env, req, sys.exc_info())
  File "/usr/lib/python2.7/dist-packages/trac/web/main.py", line 679, in send_internal_error
    req.send_error(exc_info, status=500, env=env, data=data)
  File "/usr/lib/python2.7/dist-packages/trac/web/api.py", line 589, in send_error
    self.write(data)
  File "/usr/lib/python2.7/dist-packages/trac/web/api.py", line 679, in write
    for chunk in data:
  File "/usr/lib/python2.7/dist-packages/trac/web/main.py", line 554, in _dispatch_request
    dispatcher.dispatch(req)
  File "/usr/lib/python2.7/dist-packages/trac/web/main.py", line 247, in dispatch
    resp = chosen_handler.process_request(req)
  File "/usr/lib/python2.7/dist-packages/trac/wiki/web_ui.py", line 134, in process_request
    req.perm(versioned_page.resource).require('WIKI_VIEW')
  File "/usr/lib/python2.7/dist-packages/trac/perm.py", line 585, in require
    if not self._has_permission(action, resource):
  File "/usr/lib/python2.7/dist-packages/trac/perm.py", line 576, in _has_permission
    check_permission(action, perm.username, resource, perm)
  File "/usr/lib/python2.7/dist-packages/trac/perm.py", line 468, in check_permission
    perm)
  File "/usr/lib/python2.7/dist-packages/trac/perm.py", line 302, in check_permission
    get_user_permissions(username)
  File "/usr/lib/python2.7/dist-packages/trac/perm.py", line 397, in get_user_permissions
    actions = self.get_actions_dict()
  File "/usr/lib/python2.7/dist-packages/trac/perm.py", line 365, in get_actions_dict
    for requestor in self.requestors:
  File "/usr/lib/python2.7/dist-packages/trac/core.py", line 78, in extensions
    components = [component.compmgr[cls] for cls in classes]
  File "/usr/lib/python2.7/dist-packages/trac/core.py", line 204, in __getitem__
    component = cls(self)
  File "/usr/lib/python2.7/dist-packages/trac/core.py", line 140, in __call__
    self.__init__()
  File "<path to plugins>/TracSpamFilter-1.0.6.dev0-py2.7.egg/tracspamfilter/filtersystem.py", line 117, in __init__
  File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 954, in resource_filename
    self, resource_name
  File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 1652, in get_resource_filename
    return self._extract_resource(manager, zip_path)
  File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 1673, in _extract_resource
    timestamp, size = self._get_date_and_size(self.zipinfo[zip_path])
KeyError: 'tracspamfilter/locale'

Attachments (0)

Change History (5)

comment:1 by Ryan J Ollos, 9 years ago

Component: generalplugin/spamfilter
Owner: set to Ryan J Ollos
Status: newassigned

I cannot reproduce. Are you using the latest version installed from the 1.0 branch?

I tried in a new virtual environment:

$pip freeze
wheel==0.24.0
(pve2)~/Documents/Workspace/trac-dev/spam-filter$python setup.py bdist_egg
running bdist_egg
running egg_info
[...]
creating build/bdist.macosx-10.11-x86_64/egg/tracspamfilter/locale
creating build/bdist.macosx-10.11-x86_64/egg/tracspamfilter/locale/de
creating build/bdist.macosx-10.11-x86_64/egg/tracspamfilter/locale/de/LC_MESSAGES
copying build/lib/tracspamfilter/locale/de/LC_MESSAGES/tracspamfilter.mo -> build/bdist.macosx-10.11-x86_64/egg/tracspamfilter/locale/de/LC_MESSAGES
creating build/bdist.macosx-10.11-x86_64/egg/tracspamfilter/locale/fr
creating build/bdist.macosx-10.11-x86_64/egg/tracspamfilter/locale/fr/LC_MESSAGES
copying build/lib/tracspamfilter/locale/fr/LC_MESSAGES/tracspamfilter.mo -> build/bdist.macosx-10.11-x86_64/egg/tracspamfilter/locale/fr/LC_MESSAGES
creating build/bdist.macosx-10.11-x86_64/egg/tracspamfilter/locale/ko
creating build/bdist.macosx-10.11-x86_64/egg/tracspamfilter/locale/ko/LC_MESSAGES
copying build/lib/tracspamfilter/locale/ko/LC_MESSAGES/tracspamfilter.mo -> build/bdist.macosx-10.11-x86_64/egg/tracspamfilter/locale/ko/LC_MESSAGES
[...]
creating 'dist/TracSpamFilter-1.0.6.dev0-py2.7.egg' and adding 'build/bdist.macosx-10.11-x86_64/egg' to it
removing 'build/bdist.macosx-10.11-x86_64/egg' (and everything under it)
(pve2)~/Documents/Workspace/trac-dev/spam-filter$cd dist/
(pve2)~/Documents/Workspace/trac-dev/spam-filter/dist$ls
TracSpamFilter-1.0.6.dev0-py2.7.egg
(pve2)~/Documents/Workspace/trac-dev/spam-filter/dist$unzip TracSpamFilter-1.0.6.dev0-py2.7.egg
Archive:  TracSpamFilter-1.0.6.dev0-py2.7.egg
  inflating: EGG-INFO/dependency_links.txt  
  inflating: EGG-INFO/entry_points.txt
  [...]
  inflating: tracspamfilter/locale/de/LC_MESSAGES/tracspamfilter.mo  
  inflating: tracspamfilter/locale/fr/LC_MESSAGES/tracspamfilter.mo  
  inflating: tracspamfilter/locale/ko/LC_MESSAGES/tracspamfilter.mo  
  [...]

comment:2 by Ryan J Ollos, 9 years ago

I tried again with a clean working copy of tracspamfilter and I can reproduce now.

comment:3 by Ryan J Ollos, 9 years ago

More details: I can reproduce in the case that tracspamfilter is created before babel is installed. Workaround is to recreate tracspamfilter after installing babel.

comment:4 by Ryan J Ollos, 9 years ago

Proposed solution is same as in th:comment:7:ticket:11606:

  • tracspamfilter/filtersystem.py

     
    114114
    115115    def __init__(self):
    116116        """Set up translation domain"""
    117         locale_dir = resource_filename(__name__, 'locale')
    118         add_domain(self.env.path, locale_dir)
     117        try:
     118            locale_dir = resource_filename(__name__, 'locale')
     119        except KeyError:
     120            pass
     121        else:
     122            add_domain(self.env.path, locale_dir)
    119123
    120124    # IRejectHandler methods

comment:5 by Ryan J Ollos, 9 years ago

Release Notes: modified (diff)
Resolution: fixed
Status: assignedclosed

Fixed in [14503].

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Ryan J Ollos.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from Ryan J Ollos to the specified user.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.