Fix encoding issue when manually loading templates for forms

We used to manually load the template files for the edit pages using
turbogears.meta.load_kid_template(). Unfortunately this went through
the one code path where encoding was completely ignored. It ended up
defaulting to sys.getdefaultencoding() which is 'ascii'. So even though
most of the templates are loaded as 'utf-8' the few that really mattered
weren't.

The fix is to call kid.load_template() ourselves and set the encoding of
the class we just loaded to either the setting in the app.cfg file or
to the normal default value of 'utf-8'.

454076
This commit is contained in:
Rob Crittenden
2008-07-22 15:14:23 -04:00
parent cdba310f02
commit bae3a2101f
6 changed files with 40 additions and 7 deletions

View File

@@ -19,6 +19,7 @@ import turbogears
from turbogears import validators, widgets
from tg_expanding_form_widget.tg_expanding_form_widget import ExpandingForm
from ipagui.helpers.validators import *
from ipagui.helpers import ipahelper
class UserFields(object):
givenname = widgets.TextField(name="givenname", label="First Name")
@@ -120,7 +121,8 @@ class UserNewForm(widgets.Form):
def __init__(self, *args, **kw):
super(UserNewForm,self).__init__(*args, **kw)
(self.template_c, self.template) = widgets.meta.load_kid_template("ipagui.templates.usernewform")
(self.template_c, self.template) = ipahelper.load_template("ipagui.templates.usernewform")
self.user_fields = UserFields
def update_params(self, params):
@@ -172,7 +174,8 @@ class UserEditForm(widgets.Form):
def __init__(self, *args, **kw):
super(UserEditForm,self).__init__(*args, **kw)
(self.template_c, self.template) = widgets.meta.load_kid_template("ipagui.templates.usereditform")
(self.template_c, self.template) = ipahelper.load_template("ipagui.templates.usereditform")
self.user_fields = UserFields