database charset

2009-11-27 Thread Kresimir Tonkovic
Just an experience...

I created a database in mysql not caring much for charsets, and run
manage.py syncdb. All tables were created with the default charset
(iso-8892-1 swedish). Later I noticed my croatian chars were not
right, so I altered some tables and varchar fields to use utf8. This
worked well, so I made a small script to run these alter tables on all
tables/fields.

Next day I could not login to the admin - it complained that I had
cookies disabled. Googling this led me to a library conflict with php-
mhash, which I tried to solve but with no success. The servers error
log also complained about invalid padding in base64 encoded strings...
Much later I started backtracing all my steps and after I altered the
auth_session table back to iso-8859-1 things worked again.

Observations:

- If utf8 is the default in django, I think it would help if all
database operations were run with explicit charset options. I.e.
create table ( ... x varchar(100) charset utf8,...) charset utf8;
- It is not clear to me why changing the charset on auth_session would
break things. Keys and data are base64 encoded and use only ascii
anyway, so switching between iso-8859-1 and utf8 should change
nothing.

Hope this helps some poor soul in the future :-)

--
Krešimir Tonković
Multimodus d.o.o.
www.multimodus.hr

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.




Re: i18n and l10n of templates for emails

2008-12-08 Thread Kresimir Tonkovic

On 8 pro, 18:16, "R. Gorman" <[EMAIL PROTECTED]> wrote:
> I ran into the same issue, but different encoding.  I found that
> adding a special comment line to the beginning of the python file
> allowed for the desired encoding (source: 2.2.3 
> fromhttp://www.python.org/doc/2.5.2/tut/node4.html).
>
> Hope that helps,

Thanks R, but this has nothing to do with python code character set.
It's all about template translations.

Regards,
Krešimir
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



i18n and l10n of templates for emails

2008-12-08 Thread Kresimir Tonkovic

Hi!

I'm using templetes to generate the HTML body for some reports I send
daily by email. I do it like this:

context = Context()
context["some_var"] = some_value


resp = render_to_string("daily_report.html", context)

msg = EmailMultiAlternatives(
_(u'Daily report'), _('Please use a html-emabled mail
reader'),
_('[EMAIL PROTECTED]'), ['[EMAIL PROTECTED]'])
msg.attach_alternative(resp, "text/html")
msg.send()

The template is i18n-ized and is actually created from a page template
that works correctly. But these reports are never translated to the
langauge set in settings.py LANGUAGE_CODE, nor have I found any other
way to control i18n of this template's rendering. I guess this has to
do with me using Context instead of RequestContext. Obviously there is
no request here and thus no RequestContext.

Any ideas how I could control 18n in this scenario?

Regards,
Krešimir Tonković

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---