[ckan-dev] Error while trying to create orgs within extension
Pedro G Silva
pedro.gracio at deimos.com.pt
Fri Mar 11 15:09:42 UTC 2016
Hi
I'm trying to create certain orgs and groups within an extenson (or check
if they exist and dont create them).
SO for that I'm using the IConfigurable interface, on the method
'configure'.
My sample code:
context = {
'model': model,
'session': model.Session,
'user': "deimos"
}
resource_dict={}
resource_dict['name']="ih"
resource_dict['image_display_url']
='/base/images/ih_logo.png'
resource_dict['title']= "IH"
plugins.toolkit.get_action('organization_create')(context,
resource_dict)
Running the plugin throws this error: result = _action(context,
data_dict, **kw)
File "/home/bunny/ckan/lib/default/src/ckan/ckan/logic/action/create.py",
line 923, in organization_create
return _group_or_org_create(context, data_dict, is_org=True)
File "/home/bunny/ckan/lib/default/src/ckan/ckan/logic/action/create.py",
line 723, in _group_or_org_create
rev.message = _(u'REST API: Create object %s') % data.get("name")
File
"/home/bunny/ckan/lib/default/local/lib/python2.7/site-packages/pylons/i18n/translation.py",
line 106, in ugettext
return pylons.translator.ugettext(value)
File
"/home/bunny/ckan/lib/default/local/lib/python2.7/site-packages/paste/registry.py",
line 137, in __getattr__
return getattr(self._current_obj(), attr)
File
"/home/bunny/ckan/lib/default/local/lib/python2.7/site-packages/paste/registry.py",
line 197, in _current_obj
'thread' % self.____name__)
TypeError: No object (name: translator) has been registered for this thread
I then tried to add
from pylons import config
from pylons.i18n.translation import set_lang
set_lang('en')
and got the following error:
File
"/home/bunny/ckan/lib/default/local/lib/python2.7/site-packages/pkg_resources.py",
line 2048, in load
entry = __import__(self.module_name, globals(),globals(), ['__name__'])
File
"/home/bunny/ckan/lib/default/src/ckanext-snimartheme/ckanext/snimartheme/plugin.py",
line 8, in <module>
set_lang('en')
File
"/home/bunny/ckan/lib/default/local/lib/python2.7/site-packages/pylons/i18n/translation.py",
line 182, in set_lang
translator = _get_translator(lang, **kwargs)
File
"/home/bunny/ckan/lib/default/local/lib/python2.7/site-packages/pylons/i18n/translation.py",
line 170, in _get_translator
raise LanguageError('IOError: %s' % ioe)
pylons.i18n.translation.LanguageError: IOError: [Errno 2] No translation
file found for domain: 'ckan'
Does anybody experienced this and knows how to fix it?
Thanks
--
[image: DEIMOS Engenharia, SA] <http://www.deimos.pt>
*Pedro Gracio Silva*
Aerospace Systems / Production Center
*Av. D. Joao II, Lt 1.17.01, 10 • 1998-023 Lisboa, Portugal*
Ph: +351 21 893 3020 • Fax: +351 21 896 9099
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.okfn.org/pipermail/ckan-dev/attachments/20160311/fb66c235/attachment-0002.html>
More information about the ckan-dev
mailing list