forked from OpenGov-OpenData/ckanext-odata
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[OD-1693] Add ckan 2.9 support (OpenGov-OpenData#5)
* Add ckan 2.9 support * Fix regex, update getting request params, and update responses The ur prefix is not supported anymore. The request params are different in pylons and flask. Toolkit doesn't have a flask response object so we make one
- Loading branch information
Showing
10 changed files
with
261 additions
and
190 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,5 @@ syntax: glob | |
*.pyc | ||
*.sw* | ||
*.egg-info | ||
|
||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,10 @@ | ||
import ckan.plugins as p | ||
from ckan.plugins.toolkit import BaseController | ||
from ckanext.odata import utils | ||
|
||
|
||
class ODataController(p.toolkit.BaseController): | ||
class ODataController(BaseController): | ||
|
||
def odata(self, uri): | ||
data_dict = {'uri': uri} | ||
action = p.toolkit.get_action('ckanext-odata_odata') | ||
result = action({}, data_dict) | ||
return result | ||
return utils.odata(uri) | ||
|
||
def odata_metadata(self): | ||
action = p.toolkit.get_action('ckanext-odata_metadata') | ||
result = action({},{}) | ||
return result | ||
return utils.odata_metadata() |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import ckan.plugins as p | ||
import ckanext.odata.actions as action | ||
|
||
if p.toolkit.check_ckan_version('2.9'): | ||
from ckanext.odata.plugin.flask_plugin import MixinPlugin | ||
else: | ||
from ckanext.odata.plugin.pylons_plugin import MixinPlugin | ||
|
||
|
||
def link(resource_id): | ||
return '{0}{1}'.format(action.base_url(), resource_id) | ||
|
||
|
||
class ODataPlugin(MixinPlugin, p.SingletonPlugin): | ||
p.implements(p.IConfigurer) | ||
p.implements(p.IActions) | ||
p.implements(p.ITemplateHelpers, inherit=True) | ||
|
||
def update_config(self, config): | ||
p.toolkit.add_template_directory(config, '../templates') | ||
p.toolkit.add_resource('../resources', 'odata') | ||
|
||
def get_actions(self): | ||
actions = { | ||
'ckanext-odata_metadata': action.odata_metadata, | ||
'ckanext-odata_odata': action.odata, | ||
} | ||
return actions | ||
|
||
def get_helpers(self): | ||
return { | ||
'ckanext_odata_link': link, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import ckan.plugins as p | ||
import ckanext.odata.views as views | ||
|
||
|
||
class MixinPlugin(p.SingletonPlugin): | ||
p.implements(p.IBlueprint) | ||
|
||
def get_blueprint(self): | ||
return views.get_blueprints() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import ckan.plugins as p | ||
|
||
|
||
class MixinPlugin(p.SingletonPlugin): | ||
p.implements(p.IRoutes, inherit=True) | ||
|
||
def before_map(self, m): | ||
m.connect('/datastore/odata3.0/$metadata', | ||
controller='ckanext.odata.controller:ODataController', | ||
action='odata_metadata') | ||
m.connect('/datastore/odata3.0/{uri:.*?}', | ||
controller='ckanext.odata.controller:ODataController', | ||
action='odata') | ||
return m |
Oops, something went wrong.