Closed riccardoerra closed 6 years ago
Routes is installed:
pip show Routes
Name: Routes
Version: 1.13
Summary: Routing Recognition and Generation Tools
Home-page: http://routes.groovie.org/
Author: Ben Bangert
Author-email: ben@groovie.org
License: UNKNOWN
Location: /home/vagrant/lib/python2.7/site-packages
Requires: repoze.lru
Imported routes.mapper like this: https://github.com/smallmedia/iod-ckan/blob/d887292b63a5ffeb20e634cc8aa401ff00dc3dcc/ckanext-iod_theme/ckanext/iod_theme/plugin.py#L6
Changed routes.mapper.SubMapper to mapper (tried also other options): https://github.com/smallmedia/iod-ckan/blob/d887292b63a5ffeb20e634cc8aa401ff00dc3dcc/ckanext-iod_theme/ckanext/iod_theme/plugin.py#L77
But still getting error when I run paster serve /etc/ckan/default/ckan.ini
:
Traceback (most recent call last):
File "/home/vagrant/bin/paster", line 11, in <module>
sys.exit(run())
File "/home/vagrant/local/lib/python2.7/site-packages/paste/script/command.py", line 102, in run
invoke(command, command_name, options, args[1:])
File "/home/vagrant/local/lib/python2.7/site-packages/paste/script/command.py", line 141, in invoke
exit_code = runner.run(args)
File "/home/vagrant/local/lib/python2.7/site-packages/paste/script/command.py", line 236, in run
result = self.command()
File "/home/vagrant/local/lib/python2.7/site-packages/paste/script/serve.py", line 284, in command
relative_to=base, global_conf=vars)
File "/home/vagrant/local/lib/python2.7/site-packages/paste/script/serve.py", line 329, in loadapp
**kw)
File "/home/vagrant/local/lib/python2.7/site-packages/paste/deploy/loadwsgi.py", line 247, in loadapp
return loadobj(APP, uri, name=name, **kw)
File "/home/vagrant/local/lib/python2.7/site-packages/paste/deploy/loadwsgi.py", line 272, in loadobj
return context.create()
File "/home/vagrant/local/lib/python2.7/site-packages/paste/deploy/loadwsgi.py", line 710, in create
return self.object_type.invoke(self)
File "/home/vagrant/local/lib/python2.7/site-packages/paste/deploy/loadwsgi.py", line 146, in invoke
return fix_call(context.object, context.global_conf, **context.local_conf)
File "/home/vagrant/local/lib/python2.7/site-packages/paste/deploy/util.py", line 58, in fix_call
reraise(*exc_info)
File "/home/vagrant/local/lib/python2.7/site-packages/paste/deploy/compat.py", line 23, in reraise
exec('raise t, e, tb', dict(t=t, e=e, tb=tb))
File "/home/vagrant/local/lib/python2.7/site-packages/paste/deploy/util.py", line 55, in fix_call
val = callable(*args, **kw)
File "/vagrant/ckan/config/middleware/__init__.py", line 45, in make_app
load_environment(conf, app_conf)
File "/vagrant/ckan/config/environment.py", line 97, in load_environment
p.load_all()
File "/vagrant/ckan/plugins/core.py", line 139, in load_all
load(*plugins)
File "/vagrant/ckan/plugins/core.py", line 167, in load
plugins_update()
File "/vagrant/ckan/plugins/core.py", line 121, in plugins_update
environment.update_config()
File "/vagrant/ckan/config/environment.py", line 198, in update_config
routes_map = routing.make_map()
File "/vagrant/ckan/config/routing.py", line 106, in make_map
map = plugin.before_map(map)
File "/vagrant/ckanext-iod_theme/ckanext/iod_theme/plugin.py", line 77, in before_map
with mapper(map, controller=group_controller) as m:
TypeError: 'module' object is not callable
You had with mapper(map, controller=group_controller) as m:
rather than with mapper.SubMapper(map, controller=group_controller) as m:
(which works if you import routes.mapper
as mapper
) or with routes.mapper.SubMapper(map, controller=group_controller) as m:
as in the example. I also added the after_map
method, which is missing from the example.
ckan_icon='group'
?
Tried in plugin.py
but no effect.
Depending on the case, it's either in plugin.py or in the template file e.g.
{% link_for _('View showcase'), controller='ckanext.showcase.controller:ShowcaseController', action='read', id=pkg.name, class_='btn', icon='eye-open' %}
{{ h.build_nav_icon('ckanext_showcase_edit', _('Edit showcase'), id=pkg.name) }}
controller='group
' or controller='theme'
, type='group'
or type='theme'
?
For now I left everything as group because changing to theme triggered errors.
group_count
/group_list
???
Wanting to have the stats block in the homepage to output the number of theme created.
Depending on how they're created, either stats.group_count or stats.organization_count
http://iod-ckan-live.aws.smallmedia.org.uk Does not open for me, but an 'Incorrect group type' is related to another question "Override the GroupController with a copy in your plugin that method only returns 'group'"
Copy the GroupController from CKAN core in your code, and make the neccessary changes to only return group type: group (if that fits your use-case with how you use/implement groups/organizations.)
Yes, some of the strings are marked for translation, and therefore appearances of 'Group' also need to be changed in translation files as well. (Or change them directly in the templates, recompile translation files and make changes if they are necessary )
group_create
or similar not present in plugin.py
Everything group_xxx
needs to be added in plugin.py
and then changed to theme_xxx
in the templates?Yes, everything changed in plugin.py (for example group_show to theme_show) needs to be changed in the templates as well. For example instead of:
{{ h.build_nav_icon('group_edit', _('Edit'), id=c.group_dict.name) }}
{{ h.build_nav_icon('theme_edit', _('Edit'), id=c.group_dict.name) }}
(I’m assuming you don't want /group to appear in the slug preview)
Please view the following:
templates/package/snippets/package_basic_fields.html templates/group/snippets/group_form.html templates/organization/snippets/organization_form.html
There are many ways to handle this, the simplest would probably be http://jinja.pocoo.org/docs/2.9/templates/#replace
templates/snippets/facet_list.html Quickest solution would again be http://jinja.pocoo.org/docs/2.9/templates/#replace, if you want to avoid digging up the backend.
Yes, please view: http://docs.ckan.org/en/ckan-2.6.3/api/index.html#ckan.logic.action.delete.group_purge
ckan_icon='group'
? Tried in plugin.py
but no effect.
Depending on the case, it's either in plugin.py or in the template file e.g.
{% link_for _('View showcase'), controller='ckanext.showcase.controller:ShowcaseController', action='read', id=pkg.name, class_='btn', icon='eye-open' %}
{{ h.build_nav_icon('ckanext_showcase_edit', _('Edit showcase'), id=pkg.name) }}
Managed to change icon almost everywhere but can't find a way to change it for activity stream.
The icon for activity stream is defined in routing.py (in CKAN) or plugin.py (in an extension). Whichever icon is defined in plugin.py - for example: m.connect('group_activity', '/group/activity/{id}/{offset}', action='activity', ckan_icon='time'), in the template, the build_nav_icon helper will use the icon defined in plugin.py, (for example group/read_base.html)
will use the 'time' icon defined in plugin.py
controller='group
' or controller='theme'
, type='group'
or type='theme'
?For now I left everything as group because changing to theme triggered errors. Do I need to change every controller and type from group to theme? Would be nice to know/understand which ones need to be changed and which ones don't.
To replace 'group' with 'theme' :
Replace group actions in plugin.py with 'theme' map.redirect('/group', '/theme', _redirect_code='301 Moved Permanently') map.redirect('/group/{url:.*}', '/theme/{url}', _redirect_code='301 Moved Permanently')
group_controller = 'ckanext.yourextension.path.to.controller:ControllerName'
with SubMapper(map, controller=group_controller) as m: m.connect('theme_index', '/theme', action='index') ...etc. in controller.py (or wherever you write your controller classes) import ckan.controllers.group as group
class ThemeController(group.GroupController): group_types = ['group']
def _guess_group_type(self, expecting_name=False): return 'group'
group_count
/group_list
???Wanting to have the stats block in the homepage to output the number of theme created.
Depending on how they're created, either stats.group_count or stats.organization_count
What do I have to change here? Having controller='theme' doesn't do anything.
<a href="{{ h.url_for(controller='group', action='index') }}">
<b>{{ h.SI_number_span(stats.group_count) }}</b>
{{ _('theme') if stats.group_count == 1 else _('themes') }}
</a>
I think implementing the previous point should fix this. stats.group_count outputs the length of the output from the group_list API call.
Not sure I understand what to do here.
Copy the GroupController from CKAN core in your code, and make the neccessary changes to only return group type: group (if that fits your use-case with how you use/implement groups/organizations.)
Found the GroupController in ckan/controller/group.py but not sure what/where to charge. Something to do with _guess_group_type I guess?
To replace 'group' with 'theme' :
Replace group actions in plugin.py with 'theme' map.redirect('/group', '/theme', _redirect_code='301 Moved Permanently') map.redirect('/group/{url:.*}', '/theme/{url}', _redirect_code='301 Moved Permanently')
group_controller = 'ckanext.yourextension.path.to.controller:ControllerName'
with SubMapper(map, controller=group_controller) as m: m.connect('theme_index', '/theme', action='index') ...etc. in controller.py (or wherever you write your controller classes) import ckan.controllers.group as group
class ThemeController(group.GroupController): group_types = ['group']
def _guess_group_type(self, expecting_name=False): return 'group'
(I’m assuming you don't want /group to appear in the slug preview)
Please view the following:
templates/package/snippets/package_basic_fields.html templates/group/snippets/group_form.html templates/organization/snippets/organization_form.html
There are many ways to handle this, the simplest would probably be http://jinja.pocoo.org/docs/2.9/templates/#replace
Managed to change the suffix but can't fine a way to change the suffix of the domain.
Doing |replace("group, "theme) on L15 in group/snippets/group_form.html should replace the "/group" displayed in the URL slug preview
Yes, please view: http://docs.ckan.org/en/ckan-2.6.3/api/index.html#ckan.logic.action.delete.group_purge
Tried to use ckanapi but can't fine any group, maybe because of the changes from groups to theme?
^C(vagrant) vagrant@vagrant-ubuntu-trusty-64:/vagrant$ ckanapaction group_list -j -c /etc/ckan/default/ckan.ini
[]
There is a typo, ^C(vagrant) vagrant@vagrant-ubuntu-trusty-64:/vagrant$ ckanapaction group_list -j -c /etc/ckan/default/ckan.ini
it says ckanapaction instead of ckanapiaction (missing i, I presume?)
Slug and icon are still wrong ones here: http://iod-ckan-live.aws.smallmedia.org.uk/dataset/groups/title
Themes page in Farsi crashes
http://iod-ckan-live.aws.smallmedia.org.uk/theme ✅ http://iod-ckan-live.aws.smallmedia.org.uk/fa_IR/theme ❌ Server Error. An internal server error occurred.
Testing it and seems all good.
One thing I noticed is that if I go to themes page it shows no themes:
But if I try to add a theme to a dataset the dropdown shows some themes:
Maybe some old themes that did not get created correctly. What's the best way to purge themes?
How would someone do the remapping in version 2.9 where IRoutes is now not called? I've seen that i should be using IBlueprint but i don't see how.
Other CKAN websites use the concept of Themes instead of Groups. How to achieve that?
Support received