Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
S
swh-core
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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Antoine Lambert
swh-core
Commits
36ac7a69
Commit
36ac7a69
authored
5 years ago
by
David Douard
Browse files
Options
Downloads
Patches
Plain Diff
api: make backend_factory argument of RPCServerApp() optional
defaults to calling the backend_class constructor.
parent
f4db00bc
Loading
Loading
Loading
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
swh/core/api/__init__.py
+10
-7
10 additions, 7 deletions
swh/core/api/__init__.py
with
10 additions
and
7 deletions
swh/core/api/__init__.py
+
10
−
7
View file @
36ac7a69
...
...
@@ -301,21 +301,24 @@ class RPCServerApp(Flask):
a function that decodes the request and sends it to the backend object
provided by the factory.
:param Any backend_class: The class of the backend, which will be
analyzed to look for API endpoints.
:param Callable[[], backend_class] backend_factory: A function with no
argument that returns
an instance of
`backend_class`.
"""
:param Any backend_class:
The class of the backend, which will be analyzed to look
for API endpoints.
:param Optional[Callable[[], backend_class]] backend_factory:
A function with no argument that returns an instance of
`backend_class`. If unset, defaults to calling `backend_class`
constructor directly.
"""
request_class
=
BytesRequest
def
__init__
(
self
,
*
args
,
backend_class
=
None
,
backend_factory
=
None
,
**
kwargs
):
super
().
__init__
(
*
args
,
**
kwargs
)
self
.
backend_class
=
backend_class
if
backend_class
is
not
None
:
if
backend_factory
is
None
:
raise
TypeError
(
'
Missing argument backend_factory
'
)
backend_factory
=
backend_class
for
(
meth_name
,
meth
)
in
backend_class
.
__dict__
.
items
():
if
hasattr
(
meth
,
'
_endpoint_path
'
):
self
.
__add_endpoint
(
meth_name
,
meth
,
backend_factory
)
...
...
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