okfn/ckan — pull request #1011 by seanh (2013-06-19 14:13:50+00:00)
Title: TemplateNotFound when trying to get RDF version of a package with a non-default package type

For example ckanext-harvest creates a package for each harvest source, the "type" field of these packages is set to "harvest". If you visit the RDF version of the package's page: you get:

```
File '/usr/lib/ckan/src/ckan/ckan/controllers/package.py', line 362 in read
return render(template, loader_class=loader)
...
TemplateNotFound: Template "source/read.rdf" not found
```

The problem is that to get the package read template CKAN calls the `read_template()` method of whatever `IDatasetForm` plugin handles this package type (usually `DefaultDatasetForm`, but in the case of ckanext-harvest's harvest datasets this is ckanext-harvest's IDatasetForm plugin). ckanext-harvest returns `"source/read.html"`, a template file that it provides. CKAN then pops off the ".html" and puts a ".rdf" on!

We could document this as part of the IDatasetForm plugin interface, that any IDatasetForm plugin like ckanext-harvest that provides a read.html template has to also provide a read.rdf template (and any other formats CKAN might decide to ask for) in the same directory. but that seems ridiculous.

I suggest changing this behaviour in CKAN. Either make it call the IDatasetForm's `read_rdf_template()` method when the RDF format is requested (and add this method to the plugin interface) or add a `format` parameter to the `read_template()` method (and add _that_ to the pluing interface).