I followed the Ckan example. Customize dataset and resource metadata fields using IDatasetForm here , and I can add some custom data fields.
Then I would like to add a few dictionaries, and I followed the following steps here , and everything works for the first time.
I spent a little time since I realized that dictionaries are created only once.
I added the following function:
def create_country_codes():
user = tk.get_action('get_site_user')({'ignore_auth': True}, {})
context = {'user': user['name']}
try:
data = {'id': 'country_codes'}
tk.get_action('vocabulary_show')(context, data)
except tk.ObjectNotFound:
data = {'name': 'country_codes'}
vocab = tk.get_action('vocabulary_create')(context, data)
for tag in (u'uk', u'ie', u'de', u'fr', u'es'):
data = {'name': tag, 'vocabulary_id': vocab['id']}
tk.get_action('tag_create')(context, data)
For the first time, everything was OK, and I got the result, as expected, as I said. Then I tried to add more countries (tags) to the function, and I got stuck because it didn't seem to update what I changed:
...
for tag in (u'uk', u'ie', u'de', u'fr', u'es', u'aa', u'bb', u'cc', u'dd'):
data = {'name': tag, 'vocabulary_id': vocab['id']}
tk.get_action('tag_create')(context, data)
...
Check out the new tags: u'aa ', u'bb', u'cc ', u'dd'
, , . , .
, , - , - , ( )?
.