[ckan-dev] DatasetForm-Plugin
Adrià Mercader
adria.mercader at okfn.org
Wed Aug 7 09:28:12 UTC 2013
Hi,
Looks like you are using the create schema on your update endpoint:
Instead of this:
def update_package_schema(self):
schema = superDatasetTestPluginself).create_package_schema()
schema = self._modify_package_schema(schema)
return schema
It should be this:
def update_package_schema(self):
schema = superDatasetTestPluginself).update_package_schema()
schema = self._modify_package_schema(schema)
return schema
Adrià
On 4 August 2013 22:44, gr n8 <gr8 at gmx.at> wrote:
> Does no one have any idea?
>
> kind regards!
>
> Gesendet: Mittwoch, 31. Juli 2013 um 23:00 Uhr
> Von: "gr n8" <gr8 at gmx.at>
> An: ckan-dev at lists.okfn.org
> Betreff: [ckan-dev] DatasetForm-Plugin
> Hi,
>
> I tried to develop a plugin which adds some extra fields to the
> package-schema. Once I activate the plugin and edit a dataset, I receive the
> following error when I click the "Next:Add Data" button.
> "The form contains invalid entries:
> - Id: The input field was not expected." -- but there is no more
> information in the log file.
>
> Furthermore, the schema of the package seems to be not affected (so the
> "testfield" is not being displayed in the json-rest-interface).
> My plugin consists only of two files, plugin.py and setup.py. Below you can
> find the code of them:
>
> plugin.py:
> import ckan.plugins as p
> import ckan.plugins.toolkit as tk
> class DatasetTestPlugin(p.SingletonPlugin, tk.DefaultDatasetForm):
> p.implements(p.IDatasetForm, inherit=False)
>
> def package_types(self):
> return []
>
> def is_fallback(self):
> return True
>
> def _modify_package_schema(self, schema):
> schema.update({'testfield':[tk.get_validator('ignore_missing'),
> tk.get_converter('convert_to_extras')]})
> return schema
> def create_package_schema(self):
> schema = superDatasetTestPluginself).create_package_schema()
> schema = self._modify_package_schema(schema)
> return schema
>
> def update_package_schema(self):
> schema = superDatasetTestPluginself).create_package_schema()
> schema = self._modify_package_schema(schema)
> return schema
> def show_package_schema(self):
> schema = superDatasetTestPluginself).show_package_schema()
>
> schema.update({'testfield':[tk.get_converter('convert_from_extras'),
> tk.get_validator('ignore_missing')]})
> return schema
>
> setup.py
>
> from setuptools import setup, find_packages
> import sys, os
> version = '0.1'
> setup(
> name='ckanext-testExtension',
> version=version,
> description="Custom Form Plugin",
> long_description="""\
> """,
> classifiers=[], # Get strings from
> http://pypi.python.org/pypi?%3Aaction=list_classifiers
> keywords='',
> author='',
> author_email='xxx',
> url='',
> license='',
> packages=find_packages(exclude=['ez_setup', 'examples', 'tests']),
> namespace_packages=['ckanext', 'ckanext.testExtension'],
> include_package_data=True,
> zip_safe=False,
> install_requires=[
> # -*- Extra requirements: -*-
> ],
> entry_points=\
> """
> [ckan.plugins]
> testPlugin=ckanext.testExtension.plugin:DatasetTestPlugin
> """,
> )
> Could you possibly tell me what´s wrong with my plugin? Why is the schema
> not affected and why is it raising a form-validation-error?
> kind regards
>
> _______________________________________________
> 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