use force_str when initializing site from xml (#36515)
This commit is contained in:
parent
4f7d4cd6cf
commit
937b2c538d
|
@ -58,6 +58,7 @@ from .http_response import HTTPResponse, AfterJob
|
|||
from .cron import CronJob
|
||||
from .substitution import Substitutions, CompatibilityNamesDict
|
||||
|
||||
from . import force_str
|
||||
from . import errors
|
||||
from . import template
|
||||
import logging
|
||||
|
@ -754,25 +755,24 @@ class QommonPublisher(Publisher, object):
|
|||
# list
|
||||
sub_cfg[child.tag] = []
|
||||
for c in child:
|
||||
if c.text in ('True', 'False'):
|
||||
value = (c.text == 'True')
|
||||
else:
|
||||
value = c.text.encode(self.site_charset)
|
||||
value = force_str(c.text)
|
||||
if value in ('True', 'False'):
|
||||
value = (value == 'True')
|
||||
sub_cfg[child.tag].append(value)
|
||||
else:
|
||||
# dict
|
||||
sub_cfg[child.tag] = {}
|
||||
for c in child:
|
||||
if c.text in ('True', 'False'):
|
||||
value = (c.text == 'True')
|
||||
else:
|
||||
value = c.text.encode(self.site_charset)
|
||||
value = force_str(c.text)
|
||||
if value in ('True', 'False'):
|
||||
value = (value == 'True')
|
||||
sub_cfg[child.tag][c.tag] = c
|
||||
else:
|
||||
text = child.text
|
||||
if text is None:
|
||||
sub_cfg[child.tag] = None
|
||||
continue
|
||||
text = force_str(text)
|
||||
try:
|
||||
sub_cfg[child.tag] = int(text)
|
||||
except (ValueError, TypeError):
|
||||
|
@ -782,7 +782,7 @@ class QommonPublisher(Publisher, object):
|
|||
if text in ('False', 'True'):
|
||||
sub_cfg[child.tag] = bool(text == 'True')
|
||||
else:
|
||||
sub_cfg[child.tag] = text.encode(self.site_charset)
|
||||
sub_cfg[child.tag] = text
|
||||
|
||||
return cfg
|
||||
|
||||
|
|
Loading…
Reference in New Issue