Permalink
Browse files

Thanks to bmihelac for the fix, this fixes issue #GH-90

  • Loading branch information...
maraujop committed Sep 17, 2011
1 parent 0f1ba29 commit 2f57d6cc6564c24ab02b4385ba2f7af5d669a75e
Showing with 4 additions and 2 deletions.
  1. +4 −2 uni_form/layout.py
View
@@ -166,7 +166,7 @@ class Fieldset(object):
def __init__(self, legend, *fields, **kwargs):
self.fields = list(fields)
- self.legend = Template(legend)
+ self.legend = unicode(legend)

This comment has been minimized.

Show comment
Hide comment
@bmihelac

bmihelac Sep 17, 2011

Contributor

If we use unicodehere, lazy translation string would be translated when this fieldset is created and not when it is rendered.
Isn't it maybe too early?

@bmihelac

bmihelac Sep 17, 2011

Contributor

If we use unicodehere, lazy translation string would be translated when this fieldset is created and not when it is rendered.
Isn't it maybe too early?

This comment has been minimized.

Show comment
Hide comment
@maraujop

maraujop Sep 17, 2011

Collaborator

Good point, I've tried dev on a project full of i18n and it works this way. So I guess it's late enough this way and probably this unloads some work when rendering, right?

@maraujop

maraujop Sep 17, 2011

Collaborator

Good point, I've tried dev on a project full of i18n and it works this way. So I guess it's late enough this way and probably this unloads some work when rendering, right?

This comment has been minimized.

Show comment
Hide comment
@bmihelac

bmihelac Sep 17, 2011

Contributor

As long as helper is defined as a property of a form, it is initiated every time it is called.

I do not have any helper defined outside of a form for now but can imagine it happen for some reason.

@bmihelac

bmihelac Sep 17, 2011

Contributor

As long as helper is defined as a property of a form, it is initiated every time it is called.

I do not have any helper defined outside of a form for now but can imagine it happen for some reason.

This comment has been minimized.

Show comment
Hide comment
@maraujop

maraujop Sep 17, 2011

Collaborator

Most of my helpers are static variables of the form. So they behave like a Singleton, they get created first time a form is instantiated and then reused. This is the way that best performs if you don't manipulate helpers in your views. All this has been updated in 0.9.0 docs. So I guess leaving it like this is ok. Thanks for paying so much attention.

@maraujop

maraujop Sep 17, 2011

Collaborator

Most of my helpers are static variables of the form. So they behave like a Singleton, they get created first time a form is instantiated and then reused. This is the way that best performs if you don't manipulate helpers in your views. All this has been updated in 0.9.0 docs. So I guess leaving it like this is ok. Thanks for paying so much attention.

This comment has been minimized.

Show comment
Hide comment
@bmihelac

bmihelac Sep 17, 2011

Contributor

ok, i will check it later on 0.9.0

best

@bmihelac

bmihelac Sep 17, 2011

Contributor

ok, i will check it later on 0.9.0

best

self.css_class = kwargs.get('css_class', '')
self.css_id = kwargs.get('css_id', None)
# Overrides class variable with an instance level variable
@@ -177,7 +177,9 @@ def render(self, form, form_style, context):
for field in self.fields:
fields += render_field(field, form, form_style, context)
- legend = u'%s' % self.legend.render(context)
+ legend = ''
+ if self.legend:
+ legend = u'%s' % Template(self.legend).render(context)
return render_to_string(self.template, Context({'fieldset': self, 'legend': legend, 'fields': fields, 'form_style': form_style}))

0 comments on commit 2f57d6c

Please sign in to comment.