diff --git a/gluon/languages.py b/gluon/languages.py index 73ce7a91..695d553c 100644 --- a/gluon/languages.py +++ b/gluon/languages.py @@ -324,8 +324,8 @@ def write_dict(filename, contents): try: fp = LockedFile(filename, 'w') fp.write('# -*- coding: utf-8 -*-\n{\n') - for key in sorted(contents, sort_function): - fp.write('%s: %s,\n' % (repr(Utf8(key)), + for key in sorted(contents, sort_function): + fp.write('%s: %s,\n' % (repr(Utf8(key)), repr(Utf8(contents[key])))) fp.write('}\n') except (IOError, OSError): @@ -558,18 +558,19 @@ class translator(object): self.force(self.http_accept_language) def plural(self, word, n): - """ Gets plural form of word for number *n* - invoked from T()/T.M() in `%%{}` tag + """ + Gets plural form of word for number *n* + invoked from T()/T.M() in `%%{}` tag - Args: - word (str): word in singular - n (numeric): number plural form created for + Note: + "word" MUST be defined in current language (T.accepted_language) - Returns: - word (str): word in appropriate singular/plural form + Args: + word (str): word in singular + n (numeric): number plural form created for - Note: - "word" MUST be defined in current language (T.accepted_language) + Returns: + word (str): word in appropriate singular/plural form """ if int(n) == 1: diff --git a/gluon/restricted.py b/gluon/restricted.py index 59b7b751..f8eeddb2 100644 --- a/gluon/restricted.py +++ b/gluon/restricted.py @@ -197,8 +197,9 @@ class RestrictedError(Exception): def compile2(code, layer): """ - The +'\n' is necessary else compile fails when code ends in a comment. + The ``+'\\n'`` is necessary else compile fails when code ends in a comment. """ + return compile(code.rstrip().replace('\r\n', '\n') + '\n', layer, 'exec') diff --git a/gluon/tests/test_html.py b/gluon/tests/test_html.py index a5668da3..bce172fb 100644 --- a/gluon/tests/test_html.py +++ b/gluon/tests/test_html.py @@ -38,6 +38,7 @@ def fix_sys_path(): fix_sys_path() from html import * +from storage import Storage class TestBareHelpers(unittest.TestCase): @@ -276,6 +277,45 @@ class TestBareHelpers(unittest.TestCase): self.assertEqual(UL('<>', _a='1', _b='2').xml(), '