Malcolm Tredinnick wrote:
> On Mon, 2007-05-28 at 13:16 +0200, Michal wrote:
>> Malcolm Tredinnick wrote:
>>> On Mon, 2007-05-28 at 12:59 +0200, Michal wrote:
>>> [...]
>>>> My note was in relation with latest error (ie. I have problem with 
>>>> execution of tests due to verbose_name error).
>>>>
>>>> I am just after dinner too, so I will try to find what is wrong in my 
>>>> application... :)
>>>>
>>>>
>>>> Once again, sorry for my obscure latest report and english.
>>> No worries. :-)
>>>
>>> I think I've fixed this problem (non-ASCII bytestrings for verbose_name)
>>> in [5372], which I've just committed.
>> I am just rewrite all my string like:
>>
>>    verbose_name='něco'
>>    fields = (
>>      (None, {'fields': ('title', 'slug', 'annotation', 'content',)}),
>>      ('Hiearchie', {'fields': ('parent', 'order')}),
>>      ('Pokročilé nastavení', {'fields': ('short_title','template_name', 
>> 'person', 'info_box', 'show_menu')}),
>>      ('Omezení přístupu na stránku', {'fields': 
>> ('registration_required', 'groups')}),
>>    )
>>    order = models.IntegerField("Pořadí", help_text="Pořadí stránky v 
>> rámci sourozenců, tj. stránek které mají stejného rodiče.")
>>
>> to:
>>
>>    verbose_name=u'něco'
>>    fields = (
>>      (None, {'fields': ('title', 'slug', 'annotation', 'content',)}),
>>      (u'Hiearchie', {'fields': ('parent', 'order')}),
>>      (u'Pokročilé nastavení', {'fields': ('short_title','template_name', 
>> 'person', 'info_box', 'show_menu')}),
>>      (u'Omezení přístupu na stránku', {'fields': 
>> ('registration_required', 'groups')}),
>> )
>>    order = models.IntegerField(u"Pořadí", help_text=u"Pořadí stránky v 
>> rámci sourozenců, tj. stránek které mají stejného rodiče.")
>>
>>
>> I am also update my unicode branch to revision [5372] and now I get 
>> another error messages:
>>
>>
>> [EMAIL PROTECTED] app $./manage.py test
>> Creating test database...
>> Creating test database...
>> Creating table auth_message
>> Creating table auth_group
>> Creating table auth_user
>> Creating table auth_permission
>> Creating table django_content_type
>> Creating table django_session
>> Creating table django_site
>> Creating table django_admin_log
>> Creating table staticpages_staticpage
>> Creating table news_subscriber
>> Creating table news_new
>> Creating table news_tag
>> Creating table partners_partneruser
>> Creating table parameters_parameter
>> Creating table pressreleases_pressrelease
>> Traceback (most recent call last):
>>    File "./manage.py", line 11, in ?
>>      execute_manager(settings)
>>    File 
>> "/usr/local/lib/python2.4/site-packages/django/core/management.py", line 
>> 1678, in execute_manager
>>      execute_from_command_line(action_mapping, argv)
>>    File 
>> "/usr/local/lib/python2.4/site-packages/django/core/management.py", line 
>> 1592, in execute_from_command_line
>>      action_mapping[action](args[1:], int(options.verbosity))
>>    File 
>> "/usr/local/lib/python2.4/site-packages/django/core/management.py", line 
>> 1309, in test
>>      failures = test_runner(app_list, verbosity)
>>    File "/usr/local/lib/python2.4/site-packages/django/test/simple.py", 
>> line 84, in run_tests
>>      create_test_db(verbosity)
>>    File "/usr/local/lib/python2.4/site-packages/django/test/utils.py", 
>> line 118, in create_test_db
>>      management.syncdb(verbosity, interactive=False)
>>    File 
>> "/usr/local/lib/python2.4/site-packages/django/core/management.py", line 
>> 537, in syncdb
>>      _emit_post_sync_signal(created_models, verbosity, interactive)
>>    File 
>> "/usr/local/lib/python2.4/site-packages/django/core/management.py", line 
>> 464, in _emit_post_sync_signal
>>      verbosity=verbosity, interactive=interactive)
>>    File 
>> "/usr/local/lib/python2.4/site-packages/django/dispatch/dispatcher.py", 
>> line 358, in send
>>      sender=sender,
>>    File 
>> "/usr/local/lib/python2.4/site-packages/django/dispatch/robustapply.py", 
>> line 47, in robustApply
>>      return receiver(*arguments, **named)
>>    File 
>> "/usr/local/lib/python2.4/site-packages/django/contrib/auth/management.py", 
>> line 26, in create_permissions
>>      ctype = ContentType.objects.get_for_model(klass)
>>    File 
>> "/usr/local/lib/python2.4/site-packages/django/contrib/contenttypes/models.py",
>>  
>> line 20, in get_for_model
>>      model=key[1], defaults={'name': smart_unicode(opts.verbose_name_raw)})
>>    File 
>> "/usr/local/lib/python2.4/site-packages/django/db/models/manager.py", 
>> line 76, in get_or_create
>>      return self.get_query_set().get_or_create(**kwargs)
>>    File 
>> "/usr/local/lib/python2.4/site-packages/django/db/models/query.py", line 
>> 280, in get_or_create
>>      obj.save()
>>    File 
>> "/usr/local/lib/python2.4/site-packages/django/db/models/base.py", line 
>> 246, in save
>>      ','.join(placeholders)), db_values)
>>    File 
>> "/usr/local/lib/python2.4/site-packages/django/db/backends/postgresql/base.py",
>>  
>> line 54, in execute
>>      return self.cursor.execute(smart_str(sql, self.charset), 
>> self.format_params(params))
>>    File 
>> "/usr/local/lib/python2.4/site-packages/django/db/backends/postgresql/base.py",
>>  
>> line 51, in format_params
>>      return tuple([smart_str(p, self.charset, True) for p in params])
>>    File 
>> "/usr/local/lib/python2.4/site-packages/django/utils/encoding.py", line 
>> 55, in smart_str
>>      return s.encode(encoding, errors)
>> UnicodeEncodeError: 'ascii' codec can't encode character u'\xe1' in 
>> position 7: ordinal not in range(128)
> 
> That sounds like your database client encoding is set to ASCII for some
> reason, which isn't something Django is going to be able to handle.
> 
> Have a look in django/db/backends/postgresql/base.py, line 97, where is
> says
> 
>         cursor.execute("SHOW client_encoding")
>         encoding = ENCODING_MAP[cursor.fetchone()[0]]
> 
> and print out the value of encoding (maybe even assign cursor.fetchone()
> to a temporary variable and print that out, too). That will at least
> confirm that the problem is where we think it is.

You are right, the problem is in the database.

It seems like the test database is created in SQL_ASCII encoding. I 
looked into psql terminal and found:

             List of databases
       Name       |   Owner    | Encoding
-----------------+------------+-----------
  gr4unicode      | pgsql      | UNICODE
  test_gr4unicode | gr4unicode | SQL_ASCII

DB gr4unicode was created by me, manually:

   CREATE DATABASE gr4unicode WITH ENCODING 'UNICODE';

Database test_gr4unicode was created dynamically by calling ./manage.py test

I don't know, how to tell to test framework to create database with 
UNICODE charset... :(

> I'm working on isnotvalid's problem right at the moment; I'll come back
> to this once I've got that fixed (which will be soon).

Don't be in a hurry due to my problems! :)  Primarily I would like help 
you with unicode branch testing...

I am attached output "dump" of the latest call of ./manage.py test (I am 
printing fetchone and encodings variables).

Regards
Michal

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

[EMAIL PROTECTED] app $./manage.py test
Creating test database...
>>>>> cursor.fetchone(): ('UNICODE',)
>>>>> encoding: utf-8
Got an error creating the test database: ERROR:  database "test_gr4unicode" 
already exists

CREATE DATABASE "test_gr4unicode"
It appears the test database, test_gr4unicode, already exists. Type 'yes' to 
delete it, or 'no' to cancel: yes
Destroying old test database...
Creating test database...
>>>>> cursor.fetchone(): (u'SQL_ASCII',)
>>>>> encoding: ascii
>>>>> cursor.fetchone(): (u'SQL_ASCII',)
>>>>> encoding: ascii
Creating table auth_message
Creating table auth_group
Creating table auth_user
Creating table auth_permission
Creating table django_content_type
Creating table django_session
Creating table django_site
Creating table django_admin_log
Creating table staticpages_staticpage
Creating table news_subscriber
Creating table news_new
Creating table news_tag
Creating table partners_partneruser
Creating table parameters_parameter
Creating table pressreleases_pressrelease

[...] several messages:
>>>>> cursor.fetchone(): (u'SQL_ASCII',)
>>>>> encoding: ascii
[...]

Traceback (most recent call last):
  File "./manage.py", line 11, in ?
    execute_manager(settings)
  File "/usr/local/lib/python2.4/site-packages/django/core/management.py", line 
1678, in execute_manager
    execute_from_command_line(action_mapping, argv)
  File "/usr/local/lib/python2.4/site-packages/django/core/management.py", line 
1592, in execute_from_command_line
    action_mapping[action](args[1:], int(options.verbosity))
  File "/usr/local/lib/python2.4/site-packages/django/core/management.py", line 
1309, in test
    failures = test_runner(app_list, verbosity)
  File "/usr/local/lib/python2.4/site-packages/django/test/simple.py", line 84, 
in run_tests
    create_test_db(verbosity)
  File "/usr/local/lib/python2.4/site-packages/django/test/utils.py", line 118, 
in create_test_db
    management.syncdb(verbosity, interactive=False)
  File "/usr/local/lib/python2.4/site-packages/django/core/management.py", line 
537, in syncdb
    _emit_post_sync_signal(created_models, verbosity, interactive)
  File "/usr/local/lib/python2.4/site-packages/django/core/management.py", line 
464, in _emit_post_sync_signal
    verbosity=verbosity, interactive=interactive)
  File "/usr/local/lib/python2.4/site-packages/django/dispatch/dispatcher.py", 
line 358, in send
    sender=sender,
  File "/usr/local/lib/python2.4/site-packages/django/dispatch/robustapply.py", 
line 47, in robustApply
    return receiver(*arguments, **named)
  File 
"/usr/local/lib/python2.4/site-packages/django/contrib/auth/management.py", 
line 26, in create_permissions
    ctype = ContentType.objects.get_for_model(klass)
  File 
"/usr/local/lib/python2.4/site-packages/django/contrib/contenttypes/models.py", 
line 20, in get_for_model
    model=key[1], defaults={'name': smart_unicode(opts.verbose_name_raw)})
  File "/usr/local/lib/python2.4/site-packages/django/db/models/manager.py", 
line 76, in get_or_create
    return self.get_query_set().get_or_create(**kwargs)
  File "/usr/local/lib/python2.4/site-packages/django/db/models/query.py", line 
280, in get_or_create
    obj.save()
  File "/usr/local/lib/python2.4/site-packages/django/db/models/base.py", line 
246, in save
    ','.join(placeholders)), db_values)
  File 
"/usr/local/lib/python2.4/site-packages/django/db/backends/postgresql/base.py", 
line 54, in execute
    return self.cursor.execute(smart_str(sql, self.charset), 
self.format_params(params))
  File 
"/usr/local/lib/python2.4/site-packages/django/db/backends/postgresql/base.py", 
line 51, in format_params
    return tuple([smart_str(p, self.charset, True) for p in params])
  File "/usr/local/lib/python2.4/site-packages/django/utils/encoding.py", line 
55, in smart_str
    return s.encode(encoding, errors)
UnicodeEncodeError: 'ascii' codec can't encode character u'\xe1' in position 7: 
ordinal not in range(128)

Reply via email to