[ckan-dev] genshi.template.eval.UndefinedError caused by db_to_form_schema() [SOLVED]
Knud Hinnerk Möller
knud at datalysator.com
Fri Mar 15 11:38:44 UTC 2013
Hi Adrià,
I only get the error on the user profile page, when the package_list template is used to show the user's packages on the left. I have two small changes over the plain 1.8 CKAN:
https://github.com/knudmoeller/ckan/commits/release-v1.8-berlin
However, these changes are translations and a __before__ function in the stats plugin's controller - I'd be surprised if either of these is causing the error.
Anyway, seanh gave me a solution yesterday on IRC:
- apparently, validation strips away any entries in the package dict that are not listed in the schema (correct me if I misunderstood this)
- logic.schema.db_to_form_package_schema() doesn't have an entry for isopen
- the fix was to add a entry for isopen to the schema in my plugin:
def db_to_form_schema(self):
# get base dataset schema
schema = logic.schema.db_to_form_package_schema()
schema.update({
'isopen': [validators.ignore_missing],
})
return schema
- this seems to do it
Cheers,
Knud
On Mar 15, 2013, at 10:56 , Adrià Mercader <adria.mercader at okfn.org> wrote:
> Hi Knud,
> A plain 1.8 install and your extension does not give me any error, so
> I suspect something else is going wrong.
> Do you have any other extensions running which modify the templates or
> the schema?
>
> Adrià
>
>
> On 13 March 2013 22:34, Knud Hinnerk Möller <knud at datalysator.com> wrote:
>> Hi,
>>
>> I'm experiencing a weird bug when implementing the optional db_to_form_schema() function of IDatasetForm in CKAN1.8. There are several places in various templates where model.package.isopen() is called (e.g., in templates/snippets/package_list.html). When I minimally implement db_to_form_schema() as below, these calls fail with a genshi.template.eval.UndefinedError ("… has no member named "isopen").
>>
>> def db_to_form_schema(self):
>>
>> # get base dataset schema
>> schema = logic.schema.db_to_form_package_schema()
>>
>> return schema
>>
>>
>> I'm unsure what is causing this - from what I can tell, the function as defined above is simply returning the default package schema, which shouldn't cause any problems. I have put together a minimal plugin which isn't doing much else than implementing this method, if you want to try to replicate this error:
>>
>> https://github.com/knudmoeller/ckanext-test
>>
>> Any help in figuring out what is happening and how to solve this would be highly appreciated!
>>
>> Cheers,
>> Knud
>> _______________________________________________
>> 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