From eeb1df1315d762d4a04e816b20b6bad694543839 Mon Sep 17 00:00:00 2001 From: gordon chung Date: Tue, 2 Dec 2014 09:35:40 -0500 Subject: sync oslo this patch also corrects an issue where we incorrectly referenced common._i18n this patch syncs to: Ia1820495a989f4f84530ab83f2d87d53a9f761df Change-Id: Ia192869d7e92732000b9033b09b97316ba5d5028 --- pycadf/_i18n.py | 33 +++++++++++++++++++++++++++++++ pycadf/middleware/notifier.py | 2 +- pycadf/openstack/common/_i18n.py | 40 -------------------------------------- pycadf/openstack/common/context.py | 8 ++------ tox.ini | 5 ++++- 5 files changed, 40 insertions(+), 48 deletions(-) create mode 100644 pycadf/_i18n.py delete mode 100644 pycadf/openstack/common/_i18n.py diff --git a/pycadf/_i18n.py b/pycadf/_i18n.py new file mode 100644 index 0000000..f3cc295 --- /dev/null +++ b/pycadf/_i18n.py @@ -0,0 +1,33 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +"""oslo.i18n integration module. +See http://docs.openstack.org/developer/oslo.i18n/usage.html +""" + +from oslo import i18n + + +_translators = i18n.TranslatorFactory(domain='pycadf') + +# The primary translation function using the well-known name "_" +_ = _translators.primary + +# Translators for log levels. +# +# The abbreviated names are meant to reflect the usual use of a short +# name like '_'. The "L" is for "log" and the other letter comes from +# the level. +_LI = _translators.log_info +_LW = _translators.log_warning +_LE = _translators.log_error +_LC = _translators.log_critical diff --git a/pycadf/middleware/notifier.py b/pycadf/middleware/notifier.py index adadb12..c94d6dd 100644 --- a/pycadf/middleware/notifier.py +++ b/pycadf/middleware/notifier.py @@ -23,8 +23,8 @@ import oslo.messaging import six import webob.dec +from pycadf._i18n import _ from pycadf.middleware import base -from pycadf.openstack.common._i18n import _ # noqa from pycadf.openstack.common import context LOG = None diff --git a/pycadf/openstack/common/_i18n.py b/pycadf/openstack/common/_i18n.py deleted file mode 100644 index e9993ad..0000000 --- a/pycadf/openstack/common/_i18n.py +++ /dev/null @@ -1,40 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -"""oslo.i18n integration module. - -See http://docs.openstack.org/developer/oslo.i18n/usage.html - -""" - -import oslo.i18n - - -# NOTE(dhellmann): This reference to o-s-l-o will be replaced by the -# application name when this module is synced into the separate -# repository. It is OK to have more than one translation function -# using the same domain, since there will still only be one message -# catalog. -_translators = oslo.i18n.TranslatorFactory(domain='pycadf') - -# The primary translation function using the well-known name "_" -_ = _translators.primary - -# Translators for log levels. -# -# The abbreviated names are meant to reflect the usual use of a short -# name like '_'. The "L" is for "log" and the other letter comes from -# the level. -_LI = _translators.log_info -_LW = _translators.log_warning -_LE = _translators.log_error -_LC = _translators.log_critical diff --git a/pycadf/openstack/common/context.py b/pycadf/openstack/common/context.py index b612db7..1689890 100644 --- a/pycadf/openstack/common/context.py +++ b/pycadf/openstack/common/context.py @@ -117,10 +117,6 @@ def get_context_from_function_and_args(function, args, kwargs): def is_user_context(context): """Indicates if the request context is a normal user.""" - if not context: + if not context or context.is_admin: return False - if context.is_admin: - return False - if not context.user_id or not context.project_id: - return False - return True + return context.user_id and context.project_id diff --git a/tox.ini b/tox.ini index 75d37fd..9385341 100644 --- a/tox.ini +++ b/tox.ini @@ -31,4 +31,7 @@ commands = oslo_debug_helper {posargs} show-source = True ignore = H405,H904 exclude = .tox,dist,doc,*.egg,build,./pycadf/openstack/common -builtins = _ + +[hacking] +import_exceptions = + pycadf._i18n -- cgit v1.2.1