Merge pull request #315 from winniehell/patch_urlify_translitcodec

Use translitcodec for urlify
This commit is contained in:
mdipierro
2014-03-02 17:24:07 -06:00
6 changed files with 2548 additions and 2 deletions
+1 -2
View File
@@ -17,7 +17,6 @@ import cgi
import urllib
import struct
import decimal
import unicodedata
from cStringIO import StringIO
from gluon.utils import simple_hash, web2py_uuid, DIGEST_ALG_BY_SIZE
from gluon.dal import FieldVirtual, FieldMethod
@@ -2519,7 +2518,7 @@ def urlify(s, maxlen=80, keep_underscores=False):
if isinstance(s, str):
s = s.decode('utf-8') # to unicode
s = s.lower() # to lowercase
s = unicodedata.normalize('NFKD', s) # normalize eg è => e, ñ => n
s = s.encode('translit/long') # replace special characters
s = s.encode('ascii', 'ignore') # encode as ASCII
s = re.sub('&\w+?;', '', s) # strip html entities
if keep_underscores: