[ckan-dev] Customizing Forms in 2.0a
Kirstein, Fabian
fabian.kirstein at fokus.fraunhofer.de
Fri Dec 28 09:16:19 UTC 2012
The Geo-Plugin works now. But I had to create a new dataset, it didn't adopt to the existing ones.
I have still issues understanding the concept:
In the method setup_template_variables() you can add properties to the c-Object, which are available
In the template. Like in c.country_codes. It seems that this just works in the new_package_form.html template.
In the read template you access the data with c.pkg_dict['country_code']. I really don't get it. Why the difference.
I tried to add some custom data to test the functionality e.g. c.test = 'hallo', but this is not working at all.
So my question: Which data is when passed to the template and how can I access it?
Thanks again.
-----Ursprüngliche Nachricht-----
Von: ckan-dev-bounces at lists.okfn.org [mailto:ckan-dev-bounces at lists.okfn.org] Im Auftrag von Kirstein, Fabian
Gesendet: Donnerstag, 27. Dezember 2012 10:13
An: CKAN Development Discussions
Betreff: Re: [ckan-dev] Customizing Forms in 2.0a
I basically took the complete plugin as it is. I get the following error message when I try to edit a dataset:
UndefinedError: 'dict object' has no attribute 'tracking_summary'
I attached the entire traceback. The plugin is still working with the old template engine. Might that be a problem?
I guess I have some issues understanding the whole concept of adding a form field. I don't want to do any complex stuff, just adding some simple extra fields.
Thank you very much!
File '/home/fki/pyenv/src/ckan/ckan/controllers/package.py', line 327 in read
return render(template, loader_class=loader) File '/home/fki/pyenv/src/ckan/ckan/lib/base.py', line 194 in render
loader_class=loader_class)
File '/home/fki/pyenv/local/lib/python2.7/site-packages/pylons/templating.py', line 249 in cached_template
return render_func()
File '/home/fki/pyenv/src/ckan/ckan/lib/base.py', line 132 in render_template
return render_jinja2(template_name, globs) File '/home/fki/pyenv/src/ckan/ckan/lib/base.py', line 85 in render_jinja2
return template.render(**extra_vars)
File '/home/fki/pyenv/local/lib/python2.7/site-packages/jinja2/environment.py', line 894 in render
return self.environment.handle_exception(exc_info, True) File '/home/fki/pyenv/src/ckan/ckan/templates/package/read.html', line 3 in top-level template code
{% set pkg = c.pkg_dict %}
File '/home/fki/pyenv/src/ckan/ckan/templates/page.html', line 1 in top-level template code
{% extends "base.html" %}
File '/home/fki/pyenv/src/ckan/ckan/templates/base.html', line 104 in top-level template code
{%- block page %}{% endblock -%}
File '/home/fki/pyenv/src/ckan/ckan/templates/page.html', line 15 in block "page"
{%- block content %}
File '/home/fki/pyenv/src/ckan/ckan/templates/page.html', line 18 in block "content"
{% block main_content %}
File '/home/fki/pyenv/src/ckan/ckan/templates/page.html', line 48 in block "main_content"
{% block primary %}
File '/home/fki/pyenv/src/ckan/ckan/templates/page.html', line 61 in block "primary"
{% block primary_content %}{% endblock %} File '/home/fki/pyenv/src/ckan/ckan/templates/package/read.html', line 61 in block "primary_content"
{% block package_content %}
File '/home/fki/pyenv/src/ckan/ckan/templates/package/read.html', line 79 in block "package_content"
{% block package_resources %}
File '/home/fki/pyenv/src/ckan/ckan/templates/package/read.html', line 80 in block "package_resources"
{% snippet "package/snippets/resources_list.html", pkg=pkg, resources=pkg.resources %} File '/home/fki/pyenv/src/ckan/ckan/lib/jinja_extensions.py', line 245 in _call
return base.render_snippet(args[0], **kwargs) File '/home/fki/pyenv/src/ckan/ckan/lib/base.py', line 66 in render_snippet
renderer='snippet')
File '/home/fki/pyenv/src/ckan/ckan/lib/base.py', line 194 in render
loader_class=loader_class)
File '/home/fki/pyenv/local/lib/python2.7/site-packages/pylons/templating.py', line 249 in cached_template
return render_func()
File '/home/fki/pyenv/src/ckan/ckan/lib/base.py', line 132 in render_template
return render_jinja2(template_name, globs) File '/home/fki/pyenv/src/ckan/ckan/lib/base.py', line 85 in render_jinja2
return template.render(**extra_vars)
File '/home/fki/pyenv/local/lib/python2.7/site-packages/jinja2/environment.py', line 894 in render
return self.environment.handle_exception(exc_info, True) File '/home/fki/pyenv/src/ckan/ckan/templates/package/snippets/resources_list.html', line 17 in top-level template code
{% snippet 'package/snippets/resource_item.html', pkg=pkg, res=resource %} File '/home/fki/pyenv/src/ckan/ckan/lib/jinja_extensions.py', line 245 in _call
return base.render_snippet(args[0], **kwargs) File '/home/fki/pyenv/src/ckan/ckan/lib/base.py', line 66 in render_snippet
renderer='snippet')
File '/home/fki/pyenv/src/ckan/ckan/lib/base.py', line 194 in render
loader_class=loader_class)
File '/home/fki/pyenv/local/lib/python2.7/site-packages/pylons/templating.py', line 249 in cached_template
return render_func()
File '/home/fki/pyenv/src/ckan/ckan/lib/base.py', line 132 in render_template
return render_jinja2(template_name, globs) File '/home/fki/pyenv/src/ckan/ckan/lib/base.py', line 85 in render_jinja2
return template.render(**extra_vars)
File '/home/fki/pyenv/local/lib/python2.7/site-packages/jinja2/environment.py', line 894 in render
return self.environment.handle_exception(exc_info, True) File '/home/fki/pyenv/src/ckan/ckan/templates/package/snippets/resource_item.html', line 3 in top-level template code
{% block resource_item_title %}
File '/home/fki/pyenv/src/ckan/ckan/templates/package/snippets/resource_item.html', line 6 in block "resource_item_title"
{{ h.popular('views', res.tracking_summary.total, min=10) }} File '/home/fki/pyenv/local/lib/python2.7/site-packages/jinja2/environment.py', line 372 in getattr
return getattr(obj, attribute)
UndefinedError: 'dict object' has no attribute 'tracking_summary'
-----Ursprüngliche Nachricht-----
Von: ckan-dev-bounces at lists.okfn.org [mailto:ckan-dev-bounces at lists.okfn.org] Im Auftrag von Sean Hammond
Gesendet: Freitag, 21. Dezember 2012 20:21
An: ckan-dev at lists.okfn.org
Betreff: Re: [ckan-dev] Customizing Forms in 2.0a
> I tried this extension now:
> https://github.com/okfn/ckan/tree/7aa0fe2b34a07a4887f46217bd27fb23fef2
> fc69/ckanext/example_idatasetform It is not working as well. It would
> be incredibly great to get an updated Version of this extension.
It should still be working. What problem are you having with it?
_______________________________________________
ckan-dev mailing list
ckan-dev at lists.okfn.org
http://lists.okfn.org/mailman/listinfo/ckan-dev
Unsubscribe: http://lists.okfn.org/mailman/options/ckan-dev
_______________________________________________
ckan-dev mailing list
ckan-dev at lists.okfn.org
http://lists.okfn.org/mailman/listinfo/ckan-dev
Unsubscribe: http://lists.okfn.org/mailman/options/ckan-dev
More information about the ckan-dev
mailing list