magpie.adapter.magpieservice¶
Store adapters to read data from magpie.
Attributes¶
Classes¶
This class abstracts handling of a project's versions. |
|
Resource of service type. |
|
Registry for OWS services. |
Functions¶
|
Retrieve the session attached to the request or recreated it to ensure it is open and within scoped transaction. |
|
Invalidates any caching reference to the specified service name. |
|
|
|
Immediately sets the logger level to avoid duplicate log outputs from the root logger and this logger when |
|
Obtains the configured Magpie URL entrypoint based on the various combinations of supported configuration settings. |
|
Retrieve application settings from a supported container. |
|
Obtains the configured Twitcher URL entrypoint based on various combinations of supported configuration settings. |
Module Contents¶
- class magpie.adapter.magpieservice.LooseVersion(version: str)[source]¶
Bases:
packaging.version.Version,VersionInterfaceThis class abstracts handling of a project’s versions.
A
Versioninstance is comparison aware and can be compared and sorted using the standard Python interfaces.>>> v1 = Version("1.0a5") >>> v2 = Version("1.0") >>> v1 <Version('1.0a5')> >>> v2 <Version('1.0')> >>> v1 < v2 True >>> v1 == v2 False >>> v1 > v2 False >>> v1 >= v2 False >>> v1 <= v2 True
Initialize a Version object.
- Parameters:
version – The string representation of a version which will be parsed and normalized before use.
- Raises:
InvalidVersion – If the
versiondoes not conform to PEP 440 in any way then this exception will be raised.
- property version: Tuple[int | str, Ellipsis]¶
- property patch¶
- _cmp(other: LooseVersion | str) int[source]¶
- magpie.adapter.magpieservice.get_connected_session(request: pyramid.request.Request) sqlalchemy.orm.session.Session[source]¶
Retrieve the session attached to the request or recreated it to ensure it is open and within scoped transaction.
- class magpie.adapter.magpieservice.MagpieService¶
Bases:
ResourceResource of service type.
- __tablename__ = 'services'¶
- resource_id¶
- resource_type_name = 'service'¶
- __mapper_args__¶
- property permissions¶
- property url¶
- property type¶
- Identifier matching ``magpie.services.ServiceInterface.service_type``.
- property sync_type¶
- Identifier matching ``magpie.cli.SyncServiceInterface.sync_type``.
- property configuration¶
- Configuration modifiers for parsing access to resources and permissions.
- static by_service_name(service_name, db_session)¶
- magpie.adapter.magpieservice.invalidate_service(service_name: magpie.typedefs.Str) None[source]¶
Invalidates any caching reference to the specified service name.
- magpie.adapter.magpieservice.get_admin_cookies(container: magpie.typedefs.AnySettingsContainer, verify: bool = True, raise_message: magpie.typedefs.Str | None = None) magpie.typedefs.CookiesType[source]¶
- magpie.adapter.magpieservice.get_logger(name: magpie.typedefs.Str, level: int | None = None, force_stdout: bool = None, message_format: magpie.typedefs.Str | None = None, datetime_format: magpie.typedefs.Str | None = None) logging.Logger[source]¶
Immediately sets the logger level to avoid duplicate log outputs from the root logger and this logger when level is
logging.NOTSET.
- magpie.adapter.magpieservice.get_magpie_url(container: magpie.typedefs.AnySettingsContainer | None = None) magpie.typedefs.Str[source]¶
Obtains the configured Magpie URL entrypoint based on the various combinations of supported configuration settings.
See also
Documentation section Application Settings for available setting combinations.
- Parameters:
container – container that provides access to application settings.
- Returns:
resolved Magpie URL
- magpie.adapter.magpieservice.get_settings(container: magpie.typedefs.AnySettingsContainer | None, app: bool = False) magpie.typedefs.SettingsType[source]¶
Retrieve application settings from a supported container.
- Parameters:
container – supported container with a handle to application settings.
app – allow retrieving from current thread registry if no container was defined.
- Returns:
found application settings dictionary.
- Raises:
TypeError – when no application settings could be found or unsupported container.
- magpie.adapter.magpieservice.get_twitcher_url(container: magpie.typedefs.AnySettingsContainer | None = None, hostname: magpie.typedefs.Str | None = None) magpie.typedefs.Str[source]¶
Obtains the configured Twitcher URL entrypoint based on various combinations of supported configuration settings.
See also
Documentation section Twitcher Settings for available setting combinations.
- Parameters:
container – container that provides access to application settings.
hostname – override literal hostname to generate the URL instead of resolving using settings.
- Returns:
resolved Twitcher URL
- class magpie.adapter.magpieservice.MagpieServiceStore(request: pyramid.request.Request)[source]¶
Bases:
twitcher.store.ServiceStoreInterfaceRegistry for OWS services.
Uses magpie to fetch service url and attributes.
- save_service(name: magpie.typedefs.Str, url: magpie.typedefs.Str, *args: Any, **kwargs: Any) NoReturn[source]¶
Store is read-only, use Magpie API to add services.
Note
Multiple redundant parameters are applied to support different Twitcher versions.
Twitcher <=0.5.xuses(service, *args, **kwargs)Twitcher >=0.6.xuses(name, url, *args, **kwargs)Some alternate interfaces also provided extra parameters at some point.
- delete_service(name: magpie.typedefs.Str, *args: Any, **kwargs: Any) NoReturn[source]¶
Store is read-only, use
MagpieAPI to delete services.
- _fetch_by_name_cached(service_name: magpie.typedefs.Str) twitcher.models.Service[source]¶
Cache this method with
beakerbased on the provided caching key parameters.If the cache is not hit (expired timeout or new key entry), calls
fetch_by_name()to retrieve the actualtwitcher.datatype.Servicedefinition. Otherwise, returns the cached item to avoid SQL queries.Note
Function arguments are required to generate caching keys by which cached elements will be retrieved.
Note
Method
fetch_by_name()gets triggered bytwitcher.owsproxy.owsproxy_view()after successful validation of granted access for Logged User to the service / resources following call tomagpie.adapter.magpieowssecurity.MagpieOWSSecurity.check_request()in order to send and retrieve the actual response of that proxied service and forward it back to the requesting user. Caching helps greatly reduce recurrent SQL queries to convert Twitcher to Magpie service.
- fetch_by_name(name: magpie.typedefs.Str) twitcher.models.Service[source]¶
Gets
twitcher.datatype.Servicecorresponding tomagpie.models.Servicebyname.