Closed tino097 closed 7 years ago
@tino097 In these general use extensions it's worth keeping compatibility for as many versions as possible. Certainly 2.3 would be worth it as it still widely used. In this cases what we do is selectively import stuff from core depending on the CKAN version that is running, like @metaodi suggests here: https://github.com/ckan/ckanext-pages/pull/32#issuecomment-220005372.
To make sure everything works fine let's add the missings versions to .travis.yml as part of this PR as well
@amercader For 2.3 and 2.4 versions still have the same issue:
ImportError: cannot import name DefaultTranslation
Extensions translations were added on 2.5, and you also need to check the CKAN version before importing DefaultTranslation
. Try something like this (untested):
if p.toolkit.check_ckan_version(min_version='2.5'):
from ckan.lib.plugins import DefaultTranslation
class PagesPluginBase(p.SingletonPlugin, DefaultTranslation):
p.implements(p.ITranslation, inherit=True)
else:
class PagesPluginBase(p.SingletonPlugin):
pass
class PagesPlugin(PagesPluginBase):
p.implements(p.IConfigurer, inherit=True)
p.implements(p.ITemplateHelpers, inherit=True)
# ...
@amercader Thanks for the guidance
Looks good @tino097! Congrats on your first CKAN extension contribution, hopefully the first of many to come :)
Translation to German language for ckanext-pages.