Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 98
Observer for http requests#154
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| """Utilities for Python OData client""" | ||
| from .request_observer import RequestObserver, RequestObserverLastCall | ||
| __all__ = ["RequestObserver", "RequestObserverLastCall"] |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| """ | ||
| Interface for request observer, which allows to catch odata request processing details | ||
| Author: Michal Nezerka <michal.nezerka@gmail.com> | ||
| Date: 2021-05-14 | ||
| """ | ||
| from abc import ABC, abstractmethod | ||
| class RequestObserver(ABC): | ||
| """ | ||
| The RequestObserver interface declares methods for observing odata request processing. | ||
| """ | ||
| @abstractmethod | ||
| def http_response(self, response, request) -> None: | ||
| """ | ||
| Get http response together with related http request object. | ||
| """ | ||
| class RequestObserverLastCall(RequestObserver): | ||
| """ | ||
| The implementation of RequestObserver that stored request and response of the last call | ||
| """ | ||
| def __init__(self): | ||
| self.response = None | ||
| self.request = None | ||
| def http_response(self, response, request): | ||
| self.response = response | ||
| self.request = request |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1018,6 +1018,8 @@ def association(self, association_name, namespace=None): | ||
| except KeyError: | ||
| pass | ||
| raise KeyError('Association does not exist') | ||
| @property | ||
| def associations(self): | ||
| return list(itertools.chain(*(decl.list_associations() for decl in list(self._decls.values())))) | ||
| @@ -1048,6 +1050,8 @@ def association_set(self, set_name, namespace=None): | ||
| except KeyError: | ||
| pass | ||
| raise KeyError('Association set does not exist') | ||
Contributor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This could be nice, separate PR, immediately merged, unrelated to the new observer class. | ||
| @property | ||
| def association_sets(self): | ||
| return list(itertools.chain(*(decl.list_association_sets() for decl in list(self._decls.values())))) | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could be nice, separate PR, immediately merged.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nah, you update copyright, when you touch the code. This is change is OK.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved to separate commit to make it easier to cherry pick this change.