Python code snippet throw 500 in CKAN

230 Views Asked by At

I'm using CKAN to develop an open data portal. It uses Python as the language and Pylons as the framework

I use the below code snippets the get the API link as mentioned in the question. Please refer this question for more info. But it does not work for me.

Method 1

<b>API: </b><a href="${h.url_for(controller='api', register='package', action='show', id=c.pkg.name, ver='2')}">
${h.url_for(controller='api', register='package', action='show', id=c.pkg.name, ver='2')}
</a>

Method 2

<b>API: </b><a href="{% h.url_for(controller='api', register='package', action='show', id=c.pkg.name, ver='2') %}">
{% h.url_for(controller='api', register='package', action='show', id=c.pkg.name, ver='2') %}
</a>

Both above throw 500 error as shown below in the images.

enter image description here

How could I fix this error?

1

There are 1 best solutions below

0
On BEST ANSWER
<a class="btn btn-primary resource-url-analytics resource-type-{{ res.resource_type }}" href="{{h.url_for(controller='api', register='package', action='show', id=c.pkg.name, ver=2)}}">
    <i class="icon-eye-open"></i> {{ _('API') }}
</a>

Above code works fine for me.