added global_settings.is_py2

This commit is contained in:
ilvalle committed 2016-07-06 17:25:26 +02:00
1 parent 5e94c11e40
commit 967b2e27a7
4 files changed
+7 -11

No files matched your search

-5
View File
@@ -45,11 +45,6 @@ if PY2:
unichr = unichr unichr = unichr
unicodeT = unicode unicodeT = unicode
def implements_iterator(cls):
cls.next = cls.__next__
del cls.__next__
return cls
def implements_bool(cls): def implements_bool(cls):
cls.__nonzero__ = cls.__bool__ cls.__nonzero__ = cls.__bool__
del cls.__bool__ del cls.__bool__
+2 -2
View File
@@ -40,7 +40,7 @@ try:
except ImportError: except ImportError:
have_settings = False have_settings = False
from gluon._compat import pickle, thread, to_bytes, to_native from gluon._compat import pickle, thread, to_bytes, to_native, hashlib_md5
try: try:
import psutil import psutil
@@ -624,7 +624,7 @@ class Cache(object):
cache_key.append(current.request.env.query_string) cache_key.append(current.request.env.query_string)
if lang_: if lang_:
cache_key.append(current.T.accepted_language) cache_key.append(current.T.accepted_language)
cache_key = hashlib.md5('__'.join(cache_key)).hexdigest() cache_key = hashlib_md5('__'.join(cache_key)).hexdigest()
if prefix: if prefix:
cache_key = prefix + cache_key cache_key = prefix + cache_key
try: try:
+2 -4
View File
@@ -21,7 +21,7 @@ import base64
from gluon import sanitizer, decoder from gluon import sanitizer, decoder
import itertools import itertools
from gluon._compat import reduce, pickle, copyreg, HTMLParser, name2codepoint, iteritems, unichr, unicodeT, urllib_quote, to_bytes, \ from gluon._compat import reduce, pickle, copyreg, HTMLParser, name2codepoint, iteritems, unichr, unicodeT, urllib_quote, to_bytes, \
to_native, to_unicode, _local_html_escape, basestring, urlencode to_native, to_unicode, _local_html_escape, basestring, urlencode, implements_bool
import marshal import marshal
from gluon.storage import Storage from gluon.storage import Storage
@@ -671,7 +671,7 @@ def XML_pickle(data):
return XML_unpickle, (marshal.dumps(str(data)),) return XML_unpickle, (marshal.dumps(str(data)),)
copyreg.pickle(XML, XML_pickle, XML_unpickle) copyreg.pickle(XML, XML_pickle, XML_unpickle)
@implements_bool
class DIV(XmlComponent): class DIV(XmlComponent):
""" """
HTML helper, for easy generating and manipulating a DOM structure. HTML helper, for easy generating and manipulating a DOM structure.
@@ -824,8 +824,6 @@ class DIV(XmlComponent):
""" """
return True return True
__nonzero__ = __bool__
def _fixup(self): def _fixup(self):
""" """
Handling of provided components. Handling of provided components.
+3
View File
@@ -10,6 +10,7 @@ import os
import sys import sys
import platform import platform
from gluon.storage import Storage from gluon.storage import Storage
from gluon._compat import PY2
global_settings = Storage() global_settings = Storage()
settings = global_settings # legacy compatibility settings = global_settings # legacy compatibility
@@ -40,3 +41,5 @@ global_settings.is_jython = \
global_settings.is_source = os.path.exists(os.path.join( global_settings.is_source = os.path.exists(os.path.join(
global_settings.gluon_parent, 'web2py.py')) global_settings.gluon_parent, 'web2py.py'))
global_settings.is_py2 = PY2