diff options
| author | Andy Smith <code@term.ie> | 2010-10-25 20:44:19 +0000 |
|---|---|---|
| committer | Tarmac <> | 2010-10-25 20:44:19 +0000 |
| commit | 954c91e315ba2745602336918a455ef3de047a8a (patch) | |
| tree | a9fdd5b99cc8a4d4aff39321b639bd347789ee59 /nova/utils.py | |
| parent | c3fbd2f09502d7436395fde3637036a44ce629a5 (diff) | |
| parent | 2e67031ffb981ae1a47043cd48d50470eb6dc0b6 (diff) | |
| download | nova-954c91e315ba2745602336918a455ef3de047a8a.tar.gz nova-954c91e315ba2745602336918a455ef3de047a8a.tar.xz nova-954c91e315ba2745602336918a455ef3de047a8a.zip | |
Remove the last vestigial bits of tornado code still in use.
An IP lawyer may want to comment on whether we need to assign copyright for the relavent 5 lines.
Diffstat (limited to 'nova/utils.py')
| -rw-r--r-- | nova/utils.py | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/nova/utils.py b/nova/utils.py index 7683fc9f4..e58302c11 100644 --- a/nova/utils.py +++ b/nova/utils.py @@ -28,6 +28,7 @@ import random import subprocess import socket import sys +from xml.sax import saxutils from twisted.internet.threads import deferToThread @@ -212,3 +213,27 @@ def deferredToThread(f): def g(*args, **kwargs): return deferToThread(f, *args, **kwargs) return g + + +def xhtml_escape(value): + """Escapes a string so it is valid within XML or XHTML. + + Code is directly from the utf8 function in + http://github.com/facebook/tornado/blob/master/tornado/escape.py + + """ + return saxutils.escape(value, {'"': """}) + + +def utf8(value): + """Try to turn a string into utf-8 if possible. + + Code is directly from the utf8 function in + http://github.com/facebook/tornado/blob/master/tornado/escape.py + + """ + if isinstance(value, unicode): + return value.encode("utf-8") + assert isinstance(value, str) + return value + |
