Solum code uses "_" for translation through built_in

Bug #1258254 reported by Georgy Okrokvertskhov
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Solum
Fix Released
Medium
Adrian Otto
Icehouse
Fix Released
Medium
Adrian Otto

Bug Description

Solum code uses global function "_" which is usually installed by openstack.common. This approach does not work in unit tests which do not import opentack.common directly. The usage of global function which might not be defined is not a good approach, so we need to do explicit import of translation function in solum code.

Revision history for this message
Adrian Otto (aotto) wrote :

I am looking for examples of the use of _ in the existing code. I would like to list the files here, and mark this bug as low hanging fruit.

Changed in solum:
importance: Undecided → Medium
Revision history for this message
Adrian Otto (aotto) wrote :

This bug is also referenced in https://review.openstack.org/60075

Revision history for this message
Adrian Otto (aotto) wrote :

The following files have _() calls in them that need fixing:

./solum/api/controllers/v1/assembly.py
./solum/api/controllers/v1/component.py
./solum/api/controllers/v1/extension.py
./solum/api/controllers/v1/operation.py
./solum/api/controllers/v1/sensor.py
./solum/api/controllers/v1/service.py
./solum/openstack/common/db/exception.py
./solum/openstack/common/db/sqlalchemy/session.py
./solum/openstack/common/db/sqlalchemy/utils.py
./solum/openstack/common/excutils.py
./solum/openstack/common/gettextutils.py
./solum/openstack/common/log.py

I plan to fix this now.

Revision history for this message
Adrian Otto (aotto) wrote :

It looks like in solum/openstack/common/gettextutils.py we already map _() to gettext(). Please advise.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to solum (master)

Fix proposed to branch: master
Review: https://review.openstack.org/60331

Changed in solum:
status: New → In Progress
Revision history for this message
Adrian Otto (aotto) wrote :

Fix proposed to branch: master
Review: https://review.openstack.org/60328

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to solum (master)

Reviewed: https://review.openstack.org/60328
Committed: http://github.com/stackforge/solum/commit/0524e7352ac17c171e2e5dd73ad37afba6c976e7
Submitter: Jenkins
Branch: master

commit 0524e7352ac17c171e2e5dd73ad37afba6c976e7
Author: Russell Bryant <email address hidden>
Date: Thu Dec 5 14:25:05 2013 -0500

    Fix missing imports of _

    A number of files used _() but didn't import it. Add the missing
    imports.

    Note that tox.ini is updated as well to ensure that the hacking rule
    about only importing modules is ignored for this case. This avoids
    having to add #noqa to every instance of this import.

    Test coverage that hits these code paths is being added in another
    review, where this originally came up:
    Idd883fda93be4f7d28554c26902da0b9744f0bf1

    Closes-bug: #1258254
    Change-Id: I19b89be8864ce3a27fef48d5b00e44110fa65adf

Changed in solum:
status: In Progress → Fix Committed
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.