Remove encode stuff as we use unicode everywhere

This commit is contained in:
Cédric Krier committed 2008-07-24 12:54:12 +02:00
1 parent 5b982b9e9f
commit b1a9433904
6 files changed
+22 -53

No files matched your search

+1 -3
View File
@@ -204,8 +204,6 @@ class Translation(OSV, Cacheable):
if source:
source = source.strip().replace('\n',' ')
if isinstance(source, unicode):
source = source.encode('utf8')
cursor.execute('SELECT value ' \
'FROM ir_translation ' \
'WHERE lang=%s ' \
@@ -486,7 +484,7 @@ class ReportTranslationUpdate(Wizard):
return strings
if node.nodeValue:
txt = node.nodeValue.encode('utf-8').strip()
txt = node.nodeValue.strip()
if txt:
strings.append(txt)
+2 -2
View File
@@ -172,11 +172,11 @@ class View(OSV):
if element.get('string'):
string = element.get('string')
if string:
strings.append(string.encode('utf-8'))
strings.append(string)
if element.get('sum'):
string = element.get('sum')
if string:
strings.append(string.encode('utf-8'))
strings.append(string)
for child in element:
strings.extend(self._translate_view(child))
return strings
+4 -24
View File
@@ -31,9 +31,11 @@ import sha
def _symbol_f(symb):
if symb is None or symb == False:
return None
elif isinstance(symb, str):
return unicode(symb, 'utf-8')
elif isinstance(symb, unicode):
return symb.encode('utf-8')
return str(symb)
return symb
return unicode(symb)
class Column(object):
_classic_read = True
@@ -163,28 +165,6 @@ class Char(Column):
def __init__(self, string, size=None, **args):
Column.__init__(self, string=string, size=size, **args)
self._symbol_set = (self._symbol_c, self._symbol_set_char)
def _symbol_set_char(self, symb):
"""
takes a string (encoded in utf8)
and returns a string (encoded in utf8)
"""
#TODO we need to remove the "symb==False" from the next line BUT
#TODO for now too many things rely on this broken behavior
#TODO the 'symb is None' test should be common to all data types
if symb is None or symb == False:
return None
# we need to convert the string to a unicode object to be able
# to evaluate its length (and possibly truncate it) reliably
if isinstance(symb, str):
u_symb = unicode(symb, 'utf8')
elif isinstance(symb, unicode):
u_symb = symb
else:
u_symb = unicode(symb)
return u_symb.encode('utf8')
def sql_type(self):
if self.size:
+1 -7
View File
@@ -2587,13 +2587,7 @@ class ORM(object):
else:
add_null = False
if arg[1] in ('like', 'ilike'):
if isinstance(arg[2], str):
str_utf8 = arg[2]
elif isinstance(arg[2], unicode):
str_utf8 = arg[2].encode('utf-8')
else:
str_utf8 = str(arg[2])
qu2.append('%%%s%%' % str_utf8)
qu2.append('%%%s%%' % arg[2])
if not str_utf8:
add_null = True
else:
-3
View File
@@ -10,8 +10,6 @@ SESSION_TIMEOUT = 600 #seconds
_USER_CACHE = {}
def login(dbname, loginname, password, cache=True):
loginname = loginname.encode('utf-8')
password = password.encode('utf-8')
cursor = pooler.get_db(dbname).cursor()
password_sha = sha.new(password).hexdigest()
cursor.execute('SELECT id FROM res_user '
@@ -40,7 +38,6 @@ def check_super(passwd):
raise Exception('AccessDenied')
def check(dbname, user, session, outdate_timeout=True):
session = session.encode('utf-8')
result = False
if _USER_CACHE.get(dbname, {}).has_key(user):
to_del = []
+14 -14
View File
@@ -48,11 +48,11 @@ class MenuitemTagHandler:
values = {}
self.xml_id = attributes['id'].encode('utf8')
self.xml_id = attributes['id']
for attr in ('name', 'icon', 'sequence', 'parent', 'action', 'groups'):
if attributes.get(attr):
values[attr] = attributes.get(attr).encode('utf8')
values[attr] = attributes.get(attr)
if values.get('parent'):
@@ -83,7 +83,7 @@ class MenuitemTagHandler:
values['action'] = '%s,%s' % (action_type, action_id)
icon = attributes.get('icon', '').encode('utf8')
icon = attributes.get('icon', '')
if icon:
values['icon'] = icon
elif action_type == 'ir.action.wizard':
@@ -160,12 +160,12 @@ class RecordTagHandler:
# Manage the top level tag
if name == "record":
self.model = self.mh.pool.get(attributes["model"].encode('utf8'))
self.model = self.mh.pool.get(attributes["model"])
assert self.model, "The model %s does not exist !" % \
(attributes["model"].encode('utf8'),)
(attributes["model"],)
self.xml_id = attributes["id"].encode('utf8')
self.update = bool(int(attributes.get('update', '0').encode('utf8')))
self.xml_id = attributes["id"]
self.update = bool(int(attributes.get('update', '0')))
# create/update a dict containing fields values
self.values = {}
@@ -178,8 +178,8 @@ class RecordTagHandler:
# Manage included tags:
elif name == "field":
field_name = attributes['name'].encode('utf8')
field_type = attributes.get('type', '').encode('utf8')
field_name = attributes['name']
field_type = attributes.get('type', '')
# Create a new entry in the values
self.values[field_name] = ""
# Remind the current name (see characters)
@@ -189,13 +189,13 @@ class RecordTagHandler:
self.cdata = "start"
# Catch the known attributes
search_attr = attributes.get('search','').encode('utf8')
ref_attr = attributes.get('ref', '').encode('utf8')
eval_attr = attributes.get('eval', '').encode('utf8')
search_attr = attributes.get('search','')
ref_attr = attributes.get('ref', '')
eval_attr = attributes.get('eval', '')
if search_attr:
if attributes.get('model', ''):
search_model = attributes['model'].encode('utf8')
search_model = attributes['model']
else:
search_model = self.model._columns[field_name]._obj
f_obj = self.mh.pool.get(search_model)
@@ -237,7 +237,7 @@ class RecordTagHandler:
data = CDATA_START.sub('', data)
self.start_cdata = "inside"
self.values[self.current_field] += data.encode('utf8')
self.values[self.current_field] += data
def endElement(self, name):