Opened 16 years ago
Closed 16 years ago
#7316 closed (fixed)
Use ugettext_lazy instead of ugettext in contrib.localflavor
Reported by: | Manuel Saelices | Owned by: | Manuel Saelices |
---|---|---|---|
Component: | contrib.localflavor | Version: | dev |
Severity: | Keywords: | ||
Cc: | Triage Stage: | Ready for checkin | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
There are many files in localflavor
that uses ugettext
for defining fields and widgets, for example:
from django.utils.translation import ugettext class NOSocialSecurityNumber(Field): """ Algorithm is documented at http://no.wikipedia.org/wiki/Personnummer """ default_error_messages = { 'invalid': ugettext(u'Enter a valid Norwegian social security number.'), } ...
This can produce a serious problem (in production server), because two things:
- String translation is got in import time, for example when web server starts. This string will never change.
- This is the most important problem: You could have error with circulars import, because
gettext
call will try import all applications installed on Django, but this file haven't loaded yet. I had this problem with Apache for a import cycle, because acontrib.localflavor
import. This is not acceptable.
I will attach a patch for fix this problem.
Attachments (1)
Change History (3)
by , 16 years ago
Attachment: | localflavor_r7554.diff added |
---|
comment:1 by , 16 years ago
Triage Stage: | Unreviewed → Ready for checkin |
---|
comment:2 by , 16 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Note:
See TracTickets
for help on using tickets.
Patch that fixes problem.