Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
workspaces
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ssa
workspaces
Commits
b78eabff
Commit
b78eabff
authored
4 years ago
by
Daniel Lyons
Browse files
Options
Downloads
Patches
Plain Diff
Move some of the processing into the route manipulations
parent
efbb7d68
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
services/workflow/src/workflow/__init__.py
+6
-3
6 additions, 3 deletions
services/workflow/src/workflow/__init__.py
services/workflow/src/workflow/workflow.py
+21
-4
21 additions, 4 deletions
services/workflow/src/workflow/workflow.py
with
27 additions
and
7 deletions
services/workflow/src/workflow/__init__.py
+
6
−
3
View file @
b78eabff
...
...
@@ -5,6 +5,8 @@ from sqlalchemy.orm import scoped_session, sessionmaker
from
zope.sqlalchemy
import
ZopeTransactionExtension
from
pyramid.renderers
import
JSONP
from
workflow.workflow
import
lookup_workflow
,
lookup_file
DB
=
{}
...
...
@@ -17,9 +19,10 @@ def main(global_config, **settings):
config
.
add_renderer
(
'
jsonp
'
,
JSONP
(
param_name
=
'
callback
'
))
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
.
add_route
(
'
workflow
'
,
'
/workflows/{id}
'
,
factory
=
lookup_workflow
)
config
.
add_route
(
'
submit_workflow
'
,
'
/workflows/{id}/submit
'
,
factory
=
lookup_workflow
)
config
.
add_route
(
'
workflow_files
'
,
'
/workflows/{id}/files
'
,
factory
=
lookup_workflow
)
config
.
add_route
(
'
workflow_file
'
,
'
/workflows/{id}/files/{filename}
'
,
factory
=
lookup_file
)
config
.
include
(
'
pyramid_beaker
'
)
config
.
scan
(
'
workflow.workflow
'
)
...
...
This diff is collapsed.
Click to expand it.
services/workflow/src/workflow/workflow.py
+
21
−
4
View file @
b78eabff
from
pyramid.response
import
Response
from
pyramid.view
import
view_config
,
view_defaults
WORKFLOWS
=
[{
'
id
'
:
1
,
'
name
'
:
'
foo
'
,
'
files
'
:
[{
'
id
'
:
1
,
'
name
'
:
'
first file
'
}]}]
WORKFLOWS
=
[{
'
id
'
:
1
,
'
name
'
:
'
foo
'
,
'
files
'
:
{
'
file.txt
'
:
{
'
id
'
:
1
,
'
name
'
:
'
file.txt
'
,
'
content
'
:
'
Hello, world!
'
}}}]
def
lookup_workflow
(
request
):
return
WORKFLOWS
[
int
(
request
.
matchdict
[
'
id
'
])]
def
lookup_file
(
request
):
return
lookup_workflow
(
request
)[
'
files
'
][
request
.
matchdict
[
'
filename
'
]]
@view_defaults
(
route_name
=
'
workflows
'
,
renderer
=
'
json
'
)
...
...
@@ -19,12 +28,12 @@ class WorkflowService:
@view_config
(
request_method
=
'
GET
'
,
route_name
=
'
workflow
'
)
def
get_workflow
(
self
):
return
WORKFLOWS
[
int
(
self
.
request
.
matchdict
[
'
id
'
])]
return
self
.
request
.
context
@view_config
(
request_method
=
'
POST
'
,
route_name
=
'
submit_workflow
'
)
def
submit_workflow
(
self
):
# submit the workflow for processing
print
(
f
"
Submitting workflow
{
self
.
request
.
matchdic
t
[
'
id
'
]
}
"
)
print
(
f
"
Submitting workflow
{
self
.
request
.
contex
t
[
'
id
'
]
}
"
)
@view_config
(
request_method
=
'
POST
'
,
route_name
=
'
workflow_files
'
)
def
add_file
(
self
):
...
...
@@ -33,4 +42,12 @@ class WorkflowService:
@view_config
(
request_method
=
'
GET
'
,
route_name
=
'
workflow_files
'
)
def
get_files
(
self
):
return
WORKFLOWS
[
int
(
self
.
request
.
matchdict
[
'
id
'
])][
'
files
'
]
return
self
.
request
.
context
[
'
files
'
]
@view_config
(
request_method
=
'
GET
'
,
route_name
=
'
workflow_file
'
,
accept
=
'
text/plain
'
,
renderer
=
'
string
'
)
def
get_file_text
(
self
):
return
self
.
request
.
context
[
'
content
'
]
@view_config
(
request_method
=
'
GET
'
,
route_name
=
'
workflow_file
'
,
accept
=
'
application/json
'
)
def
get_file_json
(
self
):
return
self
.
request
.
context
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment