def vocabulary_create(context, data_dict): '''Create a new tag vocabulary. You must be a sysadmin to create vocabularies. :param name: the name of the new vocabulary, e.g. ``'Genre'`` :type name: string :param tags: the new tags to add to the new vocabulary, for the format of tag dictionaries see ``tag_create()`` :type tags: list of tag dictionaries :returns: the newly-created vocabulary :rtype: dictionary ''' model = context['model'] schema = context.get( 'schema') or ckan.logic.schema.default_create_vocabulary_schema() _check_access('vocabulary_create', context, data_dict) data, errors = _validate(data_dict, schema, context) if errors: model.Session.rollback() raise ValidationError(errors) vocabulary = model_save.vocabulary_dict_save(data, context) if not context.get('defer_commit'): model.repo.commit() log.debug('Created Vocabulary %s' % vocabulary.name) return model_dictize.vocabulary_dictize(vocabulary, context)
def vocabulary_create(context, data_dict): '''Create a new tag vocabulary. You must be a sysadmin to create vocabularies. :param name: the name of the new vocabulary, e.g. ``'Genre'`` :type name: string :param tags: the new tags to add to the new vocabulary, for the format of tag dictionaries see ``tag_create()`` :type tags: list of tag dictionaries :returns: the newly-created vocabulary :rtype: dictionary ''' model = context['model'] schema = context.get('schema') or ckan.logic.schema.default_create_vocabulary_schema() _check_access('vocabulary_create', context, data_dict) data, errors = _validate(data_dict, schema, context) if errors: model.Session.rollback() raise ValidationError(errors) vocabulary = model_save.vocabulary_dict_save(data, context) if not context.get('defer_commit'): model.repo.commit() log.debug('Created Vocabulary %s' % str(vocabulary.name)) return model_dictize.vocabulary_dictize(vocabulary, context)
def vocabulary_create(context, data_dict): model = context['model'] schema = context.get( 'schema') or ckan.logic.schema.default_create_vocabulary_schema() model.Session.remove() model.Session()._context = context check_access('vocabulary_create', context, data_dict) data, errors = validate(data_dict, schema, context) if errors: model.Session.rollback() raise ValidationError(errors, error_summary(errors)) vocabulary = model_save.vocabulary_dict_save(data, context) if not context.get('defer_commit'): model.repo.commit() log.debug('Created Vocabulary %s' % str(vocabulary.name)) return model_dictize.vocabulary_dictize(vocabulary, context)
def vocabulary_create(context, data_dict): model = context["model"] schema = context.get("schema") or ckan.logic.schema.default_create_vocabulary_schema() model.Session.remove() model.Session()._context = context check_access("vocabulary_create", context, data_dict) data, errors = validate(data_dict, schema, context) if errors: model.Session.rollback() raise ValidationError(errors, error_summary(errors)) vocabulary = model_save.vocabulary_dict_save(data, context) if not context.get("defer_commit"): model.repo.commit() log.debug("Created Vocabulary %s" % str(vocabulary.name)) return model_dictize.vocabulary_dictize(vocabulary, context)
def vocabulary_create(context, data_dict): model = context['model'] schema = context.get('schema') or default_create_vocabulary_schema() model.Session.remove() model.Session()._context = context check_access('vocabulary_create', context, data_dict) data, errors = validate(data_dict, schema, context) if errors: model.Session.rollback() raise ValidationError(errors, package_error_summary(errors)) vocabulary = vocabulary_dict_save(data, context) if not context.get('defer_commit'): model.repo.commit() log.debug('Created Vocabulary %s' % str(vocabulary.name)) return vocabulary_dictize(vocabulary, context)