~corey.bryant/heat/kilo-3

« back to all changes in this revision

Viewing changes to debian/patches/oslo-i18n-private-classes.patch

  • Committer: Chuck Short
  • Date: 2015-01-12 17:47:39 UTC
  • mfrom: (84.1.1 heat)
  • Revision ID: zulcss@ubuntu.com-20150112174739-owg3l8a0lj7vng3g
Tags: 2015.1~b1-0ubuntu3
releasing package heat version 2015.1~b1-0ubuntu3

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
From 40fa30fd741968a182e21f98d70ec256e542d49a Mon Sep 17 00:00:00 2001
 
2
From: Doug Hellmann <doug@doughellmann.com>
 
3
Date: Tue, 6 Jan 2015 10:56:10 -0500
 
4
Subject: [PATCH] Do not use private classes from oslo.i18n
 
5
 
 
6
Use oslo.i18n.translate() without first testing if the argument being
 
7
passed is a Message instance. The Message class is meant to be hidden
 
8
from consumers, and translate() correctly detects untranslatable strings
 
9
and returns them as given.
 
10
 
 
11
Change-Id: I6e907adf16d8cf6fbbcf526632c91ca81611ea09
 
12
---
 
13
 heat/common/wsgi.py | 15 ++-------------
 
14
 1 file changed, 2 insertions(+), 13 deletions(-)
 
15
 
 
16
diff --git a/heat/common/wsgi.py b/heat/common/wsgi.py
 
17
index 86d6166..28608ec 100644
 
18
--- a/heat/common/wsgi.py
 
19
+++ b/heat/common/wsgi.py
 
20
@@ -744,19 +744,8 @@ def translate_exception(exc, locale):
 
21
         exc.message = i18n.translate(six.text_type(exc), locale)
 
22
 
 
23
     if isinstance(exc, webob.exc.HTTPError):
 
24
-        # If the explanation is not a Message, that means that the
 
25
-        # explanation is the default, generic and not translatable explanation
 
26
-        # from webop.exc. Since the explanation is the error shown when the
 
27
-        # exception is converted to a response, let's actually swap it with
 
28
-        # message, since message is what gets passed in at construction time
 
29
-        # in the API
 
30
-        if not isinstance(exc.explanation, i18n._message.Message):
 
31
-            exc.explanation = six.text_type(exc)
 
32
-            exc.detail = ''
 
33
-        else:
 
34
-            exc.explanation = \
 
35
-                i18n.translate(exc.explanation, locale)
 
36
-            exc.detail = i18n.translate(exc.detail, locale)
 
37
+        exc.explanation = i18n.translate(exc.explanation, locale)
 
38
+        exc.detail = i18n.translate(getattr(exc, 'detail', ''), locale)
 
39
     return exc
 
40
 
 
41
 
 
42
-- 
 
43
2.1.0
 
44