@@ -617,7 +617,7 @@
|
|||||||
flash: function (message, status) {
|
flash: function (message, status) {
|
||||||
var flash = $('.w2p_flash');
|
var flash = $('.w2p_flash');
|
||||||
web2py.hide_flash();
|
web2py.hide_flash();
|
||||||
flash.html(message).addClass(status);
|
flash.text(message).addClass(status);
|
||||||
if (flash.html()) flash.append('<span id="closeflash"> × </span>')[animateIn]();
|
if (flash.html()) flash.append('<span id="closeflash"> × </span>')[animateIn]();
|
||||||
},
|
},
|
||||||
hide_flash: function () {
|
hide_flash: function () {
|
||||||
|
|||||||
@@ -617,7 +617,7 @@
|
|||||||
flash: function (message, status) {
|
flash: function (message, status) {
|
||||||
var flash = $('.w2p_flash');
|
var flash = $('.w2p_flash');
|
||||||
web2py.hide_flash();
|
web2py.hide_flash();
|
||||||
flash.html(message).addClass(status);
|
flash.text(message).addClass(status);
|
||||||
if (flash.html()) flash.append('<span id="closeflash"> × </span>')[animateIn]();
|
if (flash.html()) flash.append('<span id="closeflash"> × </span>')[animateIn]();
|
||||||
},
|
},
|
||||||
hide_flash: function () {
|
hide_flash: function () {
|
||||||
|
|||||||
@@ -394,10 +394,9 @@ def ccache():
|
|||||||
redirect(URL(r=request))
|
redirect(URL(r=request))
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from guppy import hpy
|
from pympler.asizeof import asizeof
|
||||||
hp = hpy()
|
|
||||||
except ImportError:
|
except ImportError:
|
||||||
hp = False
|
asizeof = False
|
||||||
|
|
||||||
import shelve
|
import shelve
|
||||||
import os
|
import os
|
||||||
@@ -451,9 +450,9 @@ def ccache():
|
|||||||
ram['ratio'] = 0
|
ram['ratio'] = 0
|
||||||
|
|
||||||
for key, value in iteritems(cache.ram.storage):
|
for key, value in iteritems(cache.ram.storage):
|
||||||
if hp:
|
if asizeof:
|
||||||
ram['bytes'] += hp.iso(value[1]).size
|
ram['bytes'] += asizeof(value[1])
|
||||||
ram['objects'] += hp.iso(value[1]).count
|
ram['objects'] += 1
|
||||||
ram['entries'] += 1
|
ram['entries'] += 1
|
||||||
if value[0] < ram['oldest']:
|
if value[0] < ram['oldest']:
|
||||||
ram['oldest'] = value[0]
|
ram['oldest'] = value[0]
|
||||||
@@ -469,9 +468,9 @@ def ccache():
|
|||||||
except (KeyError, ZeroDivisionError):
|
except (KeyError, ZeroDivisionError):
|
||||||
disk['ratio'] = 0
|
disk['ratio'] = 0
|
||||||
else:
|
else:
|
||||||
if hp:
|
if asizeof:
|
||||||
disk['bytes'] += hp.iso(value[1]).size
|
disk['bytes'] += asizeof(value[1])
|
||||||
disk['objects'] += hp.iso(value[1]).count
|
disk['objects'] += 1
|
||||||
disk['entries'] += 1
|
disk['entries'] += 1
|
||||||
if value[0] < disk['oldest']:
|
if value[0] < disk['oldest']:
|
||||||
disk['oldest'] = value[0]
|
disk['oldest'] = value[0]
|
||||||
@@ -511,7 +510,7 @@ def ccache():
|
|||||||
total['keys'] = key_table(total['keys'])
|
total['keys'] = key_table(total['keys'])
|
||||||
|
|
||||||
return dict(form=form, total=total,
|
return dict(form=form, total=total,
|
||||||
ram=ram, disk=disk, object_stats=hp != False)
|
ram=ram, disk=disk, object_stats=asizeof != False)
|
||||||
|
|
||||||
|
|
||||||
def table_template(table):
|
def table_template(table):
|
||||||
|
|||||||
@@ -617,7 +617,7 @@
|
|||||||
flash: function (message, status) {
|
flash: function (message, status) {
|
||||||
var flash = $('.w2p_flash');
|
var flash = $('.w2p_flash');
|
||||||
web2py.hide_flash();
|
web2py.hide_flash();
|
||||||
flash.html(message).addClass(status);
|
flash.text(message).addClass(status);
|
||||||
if (flash.html()) flash.append('<span id="closeflash"> × </span>')[animateIn]();
|
if (flash.html()) flash.append('<span id="closeflash"> × </span>')[animateIn]();
|
||||||
},
|
},
|
||||||
hide_flash: function () {
|
hide_flash: function () {
|
||||||
|
|||||||
@@ -148,7 +148,7 @@
|
|||||||
{{=T.M("(**%.0d MB**)", total['bytes'] / 1048576)}}
|
{{=T.M("(**%.0d MB**)", total['bytes'] / 1048576)}}
|
||||||
{{pass}}
|
{{pass}}
|
||||||
{{else:}}
|
{{else:}}
|
||||||
{{=T.M("**not available** (requires the Python [[guppy http://pypi.python.org/pypi/guppy/ popup]] library)")}}
|
{{=T.M("**not available** (requires the Python [[Pympler https://pypi.python.org/pypi/Pympler popup]] library)")}}
|
||||||
{{pass}}
|
{{pass}}
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
@@ -176,7 +176,7 @@
|
|||||||
{{=T.M("(**%.0d MB**)", ram['bytes'] / 10485576)}}
|
{{=T.M("(**%.0d MB**)", ram['bytes'] / 10485576)}}
|
||||||
{{pass}}
|
{{pass}}
|
||||||
{{else:}}
|
{{else:}}
|
||||||
{{=T.M("``**not available**``:red (requires the Python [[guppy http://pypi.python.org/pypi/guppy/ popup]] library)")}}
|
{{=T.M("``**not available**``:red (requires the Python [[Pympler https://pypi.python.org/pypi/Pympler popup]] library)")}}
|
||||||
{{pass}}
|
{{pass}}
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
@@ -205,7 +205,7 @@
|
|||||||
{{=T.M("(**%.0d MB**)", disk['bytes'] / 1048576)}}
|
{{=T.M("(**%.0d MB**)", disk['bytes'] / 1048576)}}
|
||||||
{{pass}}
|
{{pass}}
|
||||||
{{else:}}
|
{{else:}}
|
||||||
{{=T.M("``**not available**``:red (requires the Python [[guppy http://pypi.python.org/pypi/guppy/ popup]] library)")}}
|
{{=T.M("``**not available**``:red (requires the Python [[Pympler https://pypi.python.org/pypi/Pympler popup]] library)")}}
|
||||||
{{pass}}
|
{{pass}}
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
|
|||||||
@@ -75,7 +75,7 @@
|
|||||||
{{else:}}
|
{{else:}}
|
||||||
<a class="dropdown-item" href="{{=URL('default','user/login')}}">{{=T('Login')}}</a>
|
<a class="dropdown-item" href="{{=URL('default','user/login')}}">{{=T('Login')}}</a>
|
||||||
<a class="dropdown-item" href="{{=URL('default','user/register')}}">{{=T('Sign up')}}</a>
|
<a class="dropdown-item" href="{{=URL('default','user/register')}}">{{=T('Sign up')}}</a>
|
||||||
<a class="dropdown-item" href="{{=URL('default','user/request_password')}}">{{=T('Lost Password')}}</a>
|
<a class="dropdown-item" href="{{=URL('default','user/retrieve_password')}}">{{=T('Lost Password')}}</a>
|
||||||
{{pass}}
|
{{pass}}
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
|
|||||||
+8
-2
@@ -431,10 +431,16 @@ class lazyT(object):
|
|||||||
return str(self) if self.M else local_html_escape(str(self), quote=False)
|
return str(self) if self.M else local_html_escape(str(self), quote=False)
|
||||||
|
|
||||||
def encode(self, *a, **b):
|
def encode(self, *a, **b):
|
||||||
return str(self).encode(*a, **b)
|
if PY2 and a[0] != 'utf8':
|
||||||
|
return to_unicode(str(self)).encode(*a, **b)
|
||||||
|
else:
|
||||||
|
return str(self)
|
||||||
|
|
||||||
def decode(self, *a, **b):
|
def decode(self, *a, **b):
|
||||||
return str(self).decode(*a, **b)
|
if PY2:
|
||||||
|
return str(self).decode(*a, **b)
|
||||||
|
else:
|
||||||
|
return str(self)
|
||||||
|
|
||||||
def read(self):
|
def read(self):
|
||||||
return str(self)
|
return str(self)
|
||||||
|
|||||||
+1
-1
@@ -1750,7 +1750,7 @@ class WSGIWorker(Worker):
|
|||||||
if self.request_method != 'HEAD':
|
if self.request_method != 'HEAD':
|
||||||
try:
|
try:
|
||||||
if self.chunked:
|
if self.chunked:
|
||||||
self.conn.sendall(b('%x\r\n%s\r\n' % (len(data), data)))
|
self.conn.sendall(b'%x\r\n%s\r\n' % (len(data), to_bytes(data, 'ISO-8859-1')))
|
||||||
else:
|
else:
|
||||||
self.conn.sendall(to_bytes(data))
|
self.conn.sendall(to_bytes(data))
|
||||||
except socket.timeout:
|
except socket.timeout:
|
||||||
|
|||||||
@@ -12,7 +12,9 @@ import tempfile
|
|||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
from gluon import languages
|
from gluon import languages
|
||||||
from gluon._compat import PY2
|
from gluon._compat import PY2, to_unicode, to_bytes
|
||||||
|
from gluon.storage import Messages
|
||||||
|
from gluon.html import SPAN
|
||||||
|
|
||||||
MP_WORKING = 0
|
MP_WORKING = 0
|
||||||
try:
|
try:
|
||||||
@@ -108,6 +110,8 @@ class TestTranslations(unittest.TestCase):
|
|||||||
T.force('it')
|
T.force('it')
|
||||||
self.assertEqual(str(T('Hello World')),
|
self.assertEqual(str(T('Hello World')),
|
||||||
'Salve Mondo')
|
'Salve Mondo')
|
||||||
|
self.assertEqual(to_unicode(T('Hello World')),
|
||||||
|
'Salve Mondo')
|
||||||
|
|
||||||
class TestDummyApp(unittest.TestCase):
|
class TestDummyApp(unittest.TestCase):
|
||||||
|
|
||||||
@@ -179,3 +183,43 @@ def index():
|
|||||||
for key in ['hello', 'world', '%s %%{shop}', 'ahoy']:
|
for key in ['hello', 'world', '%s %%{shop}', 'ahoy']:
|
||||||
self.assertTrue(key in en_dict)
|
self.assertTrue(key in en_dict)
|
||||||
self.assertTrue(key in pt_dict)
|
self.assertTrue(key in pt_dict)
|
||||||
|
|
||||||
|
class TestMessages(unittest.TestCase):
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
if os.path.isdir('gluon'):
|
||||||
|
self.langpath = 'applications/welcome/languages'
|
||||||
|
else:
|
||||||
|
self.langpath = os.path.realpath(
|
||||||
|
'../../applications/welcome/languages')
|
||||||
|
self.http_accept_language = 'en'
|
||||||
|
|
||||||
|
def tearDown(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def test_decode(self):
|
||||||
|
T = languages.translator(self.langpath, self.http_accept_language)
|
||||||
|
messages = Messages(T)
|
||||||
|
messages.update({'email_sent':'Email sent', 'test': "ä"})
|
||||||
|
self.assertEqual(to_unicode(messages.email_sent, 'utf-8'), 'Email sent')
|
||||||
|
|
||||||
|
class TestHTMLTag(unittest.TestCase):
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
if os.path.isdir('gluon'):
|
||||||
|
self.langpath = 'applications/welcome/languages'
|
||||||
|
else:
|
||||||
|
self.langpath = os.path.realpath(
|
||||||
|
'../../applications/welcome/languages')
|
||||||
|
self.http_accept_language = 'en'
|
||||||
|
|
||||||
|
def tearDown(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def test_decode(self):
|
||||||
|
T = languages.translator(self.langpath, self.http_accept_language)
|
||||||
|
elem = SPAN(T("Complete"))
|
||||||
|
self.assertEqual(elem.flatten(), "Complete")
|
||||||
|
elem = SPAN(T("Cannot be empty", language="ru"))
|
||||||
|
self.assertEqual(elem.xml(), to_bytes('<span>Пустое значение недопустимо</span>'))
|
||||||
|
self.assertEqual(elem.flatten(), 'Пустое значение недопустимо')
|
||||||
|
|||||||
+1
-1
@@ -11,7 +11,7 @@ Utilities and class for UTF8 strings managing
|
|||||||
----------------------------------------------
|
----------------------------------------------
|
||||||
"""
|
"""
|
||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
from gluon._compat import builtin as __builtin__, unicodeT, iteritems, to_unicode, to_native
|
from gluon._compat import builtin as __builtin__, unicodeT, iteritems, to_unicode, to_native, reload
|
||||||
|
|
||||||
__all__ = ['Utf8']
|
__all__ = ['Utf8']
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user