Skip to content

Commit

Permalink
proxies: adds proxies for current service/resource
Browse files Browse the repository at this point in the history
  • Loading branch information
lnielsen committed Jan 13, 2021
1 parent 341fa46 commit 5d57f1e
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 3 deletions.
1 change: 1 addition & 0 deletions invenio_vocabularies/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
# details.

"""Commands to create and manage vocabulary."""

import csv
from os.path import dirname, join

Expand Down
2 changes: 1 addition & 1 deletion invenio_vocabularies/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# modify it under the terms of the MIT License; see LICENSE file for more
# details.

"""Invenio module for managing vocabularies."""
"""Vocabularies configuration."""

from .resources.resource import VocabulariesResourceConfig
from .services.service import VocabulariesServiceConfig
Expand Down
25 changes: 25 additions & 0 deletions invenio_vocabularies/proxies.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# -*- coding: utf-8 -*-
#
# Copyright (C) 2021 CERN.
#
# Invenio-Vocabularies is free software; you can redistribute it and/or
# modify it under the terms of the MIT License; see LICENSE file for more
# details.

"""Proxies to the service and resource."""

from flask import current_app
from werkzeug.local import LocalProxy


def _ext_proxy(attr):
return LocalProxy(
lambda: getattr(current_app.extensions['invenio-vocabularies'], attr))


current_service = _ext_proxy('service')
"""Proxy to the instantiated vocabulary service."""


current_resource = _ext_proxy('resource')
"""Proxy to the instantiated vocabulary resource."""
5 changes: 3 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

extras_require = {
"docs": [
"Sphinx>=3",
"Sphinx>=3,<4",
],
"elasticsearch6": [
"invenio-search[elasticsearch6]{}".format(invenio_search_version),
Expand Down Expand Up @@ -125,6 +125,7 @@
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Development Status :: 1 - Planning",
"Programming Language :: Python :: 3.9",
"Development Status :: 3 - Alpha",
],
)

0 comments on commit 5d57f1e

Please sign in to comment.