Skip to content
Snippets Groups Projects
Commit 4a69b446 authored by Daniel Lyons's avatar Daniel Lyons
Browse files

Remove Cornice. Not using it is more efficient than using it.

parent db0e5a27
No related branches found
No related tags found
No related merge requests found
......@@ -37,7 +37,6 @@ def find_version(*file_paths):
requires = [
'cornice',
'pycapo',
'pyramid',
'pyramid_beaker',
......
......@@ -13,11 +13,14 @@ def main(global_config, **settings):
with Configurator(settings=settings) as config:
session_factory = session_factory_from_settings(settings)
config.include('cornice')
config.set_session_factory(session_factory)
config.add_renderer('jsonp', JSONP(param_name='callback'))
config.include('pyramid_beaker')
config.add_route('workflows', '/workflows')
config.add_route('workflow', '/workflows/{id}')
config.add_route('submit_workflow', '/workflows/{id}/submit')
config.add_route('workflow_files', '/workflows/{id}/files')
config.include('pyramid_beaker')
config.scan('workflow.workflow')
return config.make_wsgi_app()
from cornice.resource import resource
from pyramid.view import view_config, view_defaults
WORKFLOWS = [{'id': 1, 'name': 'foo', 'files': [{'id': 1, 'name': 'first file'}]}]
WORKFLOWS = [{'id': 1, 'name': 'foo'}]
@resource(collection_path="/workflows", path="/workflows/{id}")
class Workflow:
def __init__(self, request, context=None):
@view_defaults(route_name='workflows', renderer='json')
class Workflows:
def __init__(self, request):
self.request = request
def collection_get(self):
@view_config(request_method='GET')
def list_workflows(self):
return WORKFLOWS
def collection_post(self):
@view_config(request_method='POST')
def create_workflow(self):
WORKFLOWS.append(self.request.json_body)
return True
def get(self):
@view_config(request_method='GET', route_name='workflow')
def get_workflow(self):
return WORKFLOWS[int(self.request.matchdict['id'])]
@view_config(request_method='POST', route_name='submit_workflow')
def submit_workflow(self):
# submit the workflow for processing
print(f"Submitting workflow {self.request.matchdict['id']}")
@view_config(request_method='POST', route_name='workflow_files')
def add_file(self):
# add a file to this workflow request
print('Adding a file')
@view_config(request_method='GET', route_name='workflow_files')
def get_files(self):
return WORKFLOWS[int(self.request.matchdict['id'])]['files']
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment