Spring Boot vs Quarkus the ultimate battle - DevoxxUK
FIWARE Tech Summit - Empower Your CKAN
1. Empower Your CKAN:
How to Implement CKAN Extensions
Burak Karaboga – Atos Research & Innovation
2. CKAN Extensions?
§ A Python package that modifies or extends CKAN
§ Extension = One or more plugins
§ For example: datastore, datapusher, disqus etc.
§ Extension catalogue¹
[1] http://extensions.ckan.org
1
4. Our goals
§ Modify a core functionality
§ Change and restrict group creation process
§ Extend the default application
§ Add a new UI element to the organizations page
3
5. Assumptions
4
§ By default, only system admins can create groups
§ For the sake of this tutorial, we assume everyone can
§ If you like, you can configure your CKAN to reflect this
ckan.auth.user_create_groups = true
6. Let’s start
§ Run the paster command
§ Creates an empty extension from template
5
$ . /usr/lib/ckan/default/bin/activate
$ cd /usr/lib/ckan/default/src
$ paster --plugin=ckan create -t ckanext ckanext-fiwaredemo
9. Modifying group logic
§ We have 2 steps:
1) Disallow creation of CKAN groups
2) Only allow the members of a group called “Curators” to create
CKAN groups
8
10. plugin.py | initial state
9
class FiwaredemoPlugin(plugins.SingletonPlugin):
plugins.implements(plugins.IConfigurer)
# IConfigurer
def update_config(self, config_):
toolkit.add_template_directory(config_, 'templates')
toolkit.add_public_directory(config_, 'public')
toolkit.add_resource('fanstatic', 'fiwaredemo')
12. plugin.py | getting smarter
11
def group_create(context, data_dict=None):
user_name = context['user']
members = toolkit.get_action('member_list')(data_dict={'id': 'curators', 'object_type': 'user'})
member_ids = [member_tuple[0] for member_tuple in members]
convert_user_name_or_id_to_id = toolkit.get_converter('convert_user_name_or_id_to_id')
user_id = convert_user_name_or_id_to_id(user_name, context)
if user_id in member_ids:
return {'success': True}
else:
return {'success': False,
'msg': 'Only curators are allowed to create groups'}
13. Extending Organizations Page
12
§ We have 4 steps:
1) Create the route for the new page
2) Extend the existing CKAN template
3) Add a new template
4) Create a controller