[ckan-dev] Translators and threads

Adrià Mercader amercadero at gmail.com
Tue Apr 19 10:31:30 UTC 2011


Thanks guys,

The MockTranslator suggestion by David Read worked fine, with David
Raznick's solution I get a new error:
pylons.i18n.translation.LanguageError: IOError: [Errno 2] No
translation file found for domain: 'ckan'

so MockTranslator it is :)

2011/4/19 David Raznick <kindly at gmail.com>:
>
>
> 2011/4/19 Adrià Mercader <amercadero at gmail.com>
>>
>> Hi all,
>>
>> I have a question related with translators and threads, and I was
>> hoping somebody could give me a clue.
>>
>> I'm using the new logic functions in ckan core to create/edit packages
>> from the import stage of the harvesting process, which runs on a
>> queue. When the logic functions found an error, they use the
>> underscore function to i18nize the message:
>> _('Package not found') or whatever
>>
>> The problem is that then I get an error like this one:
>>
>> TypeError: No object (name: translator) has been registered for this
>> thread
>>
>> (Full traceback at the end of the email)
>>
>> I guess it's related with the code running on a different thread. Does
>> anyone know how "to register the translator for this thread"?
>
> I think you can use
> from python.i18n import set_lang
> set_lang('en')
> see James book for more details
> http://pylonsbook.com/en/1.1/internationalization-and-localization.html#setting-the-language-in-the-config-file
>
>
>>
>> Thanks,
>>
>> Adrià
>>
>> Traceback (most recent call last):
>>  File "/home/adria/dev/envs/ckan/bin/paster", line 8, in <module>
>>    load_entry_point('PasteScript==1.7.3', 'console_scripts', 'paster')()
>>  File
>> "/home/adria/dev/envs/ckan/lib/python2.6/site-packages/paste/script/command.py",
>> line 84, in run
>>    invoke(command, command_name, options, args[1:])
>>  File
>> "/home/adria/dev/envs/ckan/lib/python2.6/site-packages/paste/script/command.py",
>> line 123, in invoke
>>    exit_code = runner.run(args)
>>  File
>> "/home/adria/dev/envs/ckan/lib/python2.6/site-packages/paste/script/command.py",
>> line 218, in run
>>    result = self.command()
>>  File
>> "/home/adria/dev/envs/ckan/src/ckanext-harvest/ckanext/harvest/commands/harvester.py",
>> line 86, in command
>>    consumer.wait()
>>  File
>> "/home/adria/dev/envs/ckan/lib/python2.6/site-packages/carrot/messaging.py",
>> line 446, in wait
>>    it.next()
>>  File
>> "/home/adria/dev/envs/ckan/lib/python2.6/site-packages/carrot/backends/pyamqplib.py",
>> line 300, in consume
>>    self.channel.wait()
>>  File
>> "/home/adria/dev/envs/ckan/lib/python2.6/site-packages/amqplib/client_0_8/abstract_channel.py",
>> line 107, in wait
>>    return amqp_method(self, args, content)
>>  File
>> "/home/adria/dev/envs/ckan/lib/python2.6/site-packages/amqplib/client_0_8/channel.py",
>> line 1973, in _basic_deliver
>>    func(msg)
>>  File
>> "/home/adria/dev/envs/ckan/lib/python2.6/site-packages/carrot/messaging.py",
>> line 291, in _receive_callback
>>    self.receive(message.payload, message)
>>  File
>> "/home/adria/dev/envs/ckan/lib/python2.6/site-packages/carrot/messaging.py",
>> line 344, in receive
>>    callback(message_data, message)
>>  File
>> "/home/adria/dev/envs/ckan/src/ckanext-harvest/ckanext/harvest/queue.py",
>> line 136, in fetch_callback
>>    harvester.import_stage(obj)
>>  File
>> "/home/adria/dev/envs/ckan/src/ckanext-harvest/ckanext/harvest/harvesters.py",
>> line 163, in import_stage
>>    raise e
>> TypeError: No object (name: translator) has been registered for this
>> thread
>>
>> _______________________________________________
>> ckan-dev mailing list
>> ckan-dev at lists.okfn.org
>> http://lists.okfn.org/mailman/listinfo/ckan-dev
>
>
> _______________________________________________
> ckan-dev mailing list
> ckan-dev at lists.okfn.org
> http://lists.okfn.org/mailman/listinfo/ckan-dev
>
>




More information about the ckan-dev mailing list