Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] 2750 add docs and examples for idatasetform and igroupform #295

Closed

Conversation

seanh
Copy link
Contributor

@seanh seanh commented Jan 23, 2013

I've updated example_idatasetform for CKAN 2.0, but not example_igroupform yet.

example_idatasetform is still not working because of bugs in CKAN that break IDatasetForm example_idatasetform on this branch is updated for CKAN 2.0 and working, but only tested manually, haven't got the unit tests running yet. example_igroupform is not updated for CKAN 2.0 yet.

Also I cannot get it to load the plugin when running the tests.

Sean Hammond added 15 commits July 28, 2012 18:51
The form_to_db_schema() methods of IGroupForm plugins were not being
called if those plugins inherited from DefaultGroupForm. Refactor it in
the same way as DefaultDatasetForm's form_to_db_schema_options() method
was recently refactored.  Make it call self.form_to_db_schema so that
the form_to_db_schema() methods of IGroupForm extensions get called.
Also make it call new form_to_db_schema_api_create() and
form_to_db_schema_api_update() methods which could potentially be
overridden by extensions also.
Fix group controller calling form_to_db_schema() from IGroupForm plugin
when it should be using db_to_form_schema()
Make group_create() and group_update() call the check_data_dict()
methods of IGroupForm plugins, like package_create() and
package_update() do with IDatasetForm plugins.
" ... {} ... ".format(foo) is not supported in Python 2.6, you have to
use {0}.
…examples-for-idatasetform-and-igroupform

Conflicts:
	setup.py
Update the ckanext/example_idatasetform templates for CKAN 2.0.
Implement do_to_form_schema_options() and form_to_db_schema_options() so
that ckanext-exampleidatasetform's db_to_form_schema() and
form_to_db_schema() methods actually get called.

This is a temporary fix, this needs to be sorted out in CKAN core.
@seanh
Copy link
Contributor Author

seanh commented Feb 6, 2013

Skype with @kindly about this, some possibilities to investigate for why the tests aren't working:

  • Need to turn off legacy templates when the tests run, since the extension uses jinja template overriding. We agreed to remove the legacy templates from ckan before the 2.0 release anyway, so maybe just do that.
  • ckan/config/environment.py, this is where plugins are loaded, there may be some global caching going on here, i.e. things in dicts etc that get registered only once and not each time you call plugins.load(), if so this would have to be fixed in ckan
  • Make sure the tests don't run setup() for each test
  • ckan.lib.plugins.py:register_package_plugins(), lookup_package_plugin(), looks like possibly some global caching happening here as well (in _package_plugins dict)
  • Also see this pull request [WIP] All tests are passing in travis, even when running ckan and ckanext together #363 which contains similar ckan fixes to what is needed here (but for other plugin interfaces)

@ghost ghost assigned seanh Feb 6, 2013
@seanh
Copy link
Contributor Author

seanh commented Feb 11, 2013

That's test_example_idatasetform_plugin.py updated for CKAN 2.0. Not the best or most thorough test case ever but it exercises the plugin's main functionality and it passes.

Currently you need to put ckan.legacy_templates = no in your test-core.ini file, and add example_idatasetform to the plugins in the same file, then run: nosetests --ckan ckanext/example_idatasetform/tests.

Sean Hammond added 4 commits February 13, 2013 17:06
It was causing problems, is not supposed to be overridden.
Is not supposed to be overridden, not part of the IDatasetForm
interface.
It had the wrong number of params, this was probably causing some crashes and test fails.
…orm' of github.com:okfn/ckan into 2750-add-docs-and-examples-for-idatasetform-and-igroupform
@seanh
Copy link
Contributor Author

seanh commented Feb 18, 2013

@wardi You're right, something's broken, I'll look into it

@wardi
Copy link
Contributor

wardi commented Feb 18, 2013

I think this is why I took the approach I did with these:
wardi@110792f
wardi@6735961

It makes sense that the schema for creation/editing is a little different, and in each case we just need to modify the schema by adding some fields.

It might be better for the idatasetform to have a method that is just called to update a schema instead creating it from scratch.

@seanh
Copy link
Contributor Author

seanh commented Feb 18, 2013

@wardi I think the latest commit on #377 fixes it

@seanh seanh mentioned this pull request Feb 19, 2013
…examples-for-idatasetform-and-igroupform

Conflicts:
	ckan/logic/schema.py
@seanh
Copy link
Contributor Author

seanh commented Feb 19, 2013

@wardi ExampleIDatasetForm on this branch works with the ckan master branch now (or with this branch, for that matter). The tests on this branch are broken though. I'll come back and tidy it up later

@seanh
Copy link
Contributor Author

seanh commented Feb 26, 2013

I've broken this up into separate pull requests and issues: #478, #479, #481, closing this pr

@seanh seanh closed this Feb 26, 2013
@smotornyuk smotornyuk deleted the 2750-add-docs-and-examples-for-idatasetform-and-igroupform branch December 19, 2018 15:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants