diff --git a/gluon/custom_import.py b/gluon/custom_import.py index 8e848626..ef6c7ab2 100644 --- a/gluon/custom_import.py +++ b/gluon/custom_import.py @@ -62,6 +62,9 @@ def custom_importer(name, globals=None, locals=None, fromlist=None, level=-1): except: # there is no current.request (should never happen) base_importer = NATIVE_IMPORTER + if not(PY2) and level < 0: + level = 0 + # if not relative and not from applications: if hasattr(current, 'request') \ and level <= 0 \ @@ -104,9 +107,6 @@ def custom_importer(name, globals=None, locals=None, fromlist=None, level=-1): finally: if import_tb: import_tb = None - elif not(PY2) and level < 0: - # FIXME PY3 why level is < 0? - level = 0 return NATIVE_IMPORTER(name, globals, locals, fromlist, level) diff --git a/gluon/globals.py b/gluon/globals.py index 2cd7ddcf..ae8b2ac2 100644 --- a/gluon/globals.py +++ b/gluon/globals.py @@ -453,9 +453,9 @@ class Response(Storage): for meta in iteritems((self.meta or {})): k, v = meta if isinstance(v, dict): - s += '\n' + s += '\n' else: - s += '\n' % (k, xmlescape(v)) + s += '\n' % (k, to_native(xmlescape(v))) self.write(s, escape=False) def include_files(self, extensions=None): diff --git a/gluon/sqlhtml.py b/gluon/sqlhtml.py index edadb7c2..701b9872 100644 --- a/gluon/sqlhtml.py +++ b/gluon/sqlhtml.py @@ -19,7 +19,7 @@ import urllib import re import os -from gluon._compat import StringIO, unichr, urllib_quote, iteritems, basestring, long, unicodeT +from gluon._compat import StringIO, unichr, urllib_quote, iteritems, basestring, long, unicodeT, to_native from gluon.http import HTTP, redirect from gluon.html import XmlComponent, truncate_string from gluon.html import XML, SPAN, TAG, A, DIV, CAT, UL, LI, TEXTAREA, BR, IMG @@ -1395,8 +1395,8 @@ class SQLFORM(FORM): self['hidden']['id'] = record[table._id.name] (begin, end) = self._xml() - self.custom.begin = XML("<%s %s>" % (self.tag, begin)) - self.custom.end = XML("%s" % (end, self.tag)) + self.custom.begin = XML("<%s %s>" % (self.tag, to_native(begin))) + self.custom.end = XML("%s" % (to_native(end), self.tag)) table = self.createform(xfields) self.components = [table]