Browse Source

fix context usage in ExceptionHandlerControllerWrapper

Bastien Sevajol 6 years ago
parent
commit
7889645081
2 changed files with 8 additions and 2 deletions
  1. 7 1
      hapic/decorator.py
  2. 1 1
      setup.py

+ 7 - 1
hapic/decorator.py View File

@@ -310,9 +310,15 @@ class ExceptionHandlerControllerWrapper(ControllerWrapper):
310 310
         http_code: HTTPStatus=HTTPStatus.INTERNAL_SERVER_ERROR,
311 311
     ) -> None:
312 312
         self.handled_exception_class = handled_exception_class
313
-        self.context = context
313
+        self._context = context
314 314
         self.http_code = http_code
315 315
 
316
+    @property
317
+    def context(self) -> ContextInterface:
318
+        if callable(self._context):
319
+            return self._context()
320
+        return self._context
321
+
316 322
     def _execute_wrapped_function(
317 323
         self,
318 324
         func,

+ 1 - 1
setup.py View File

@@ -23,7 +23,7 @@ setup(
23 23
     # Versions should comply with PEP440.  For a discussion on single-sourcing
24 24
     # the version across setup.py and the project code, see
25 25
     # https://packaging.python.org/en/latest/single_source_version.html
26
-    version='0.0.3.1',
26
+    version='0.0.3.2',
27 27
 
28 28
     description='HTTP api input/output manager',
29 29
     # long_description=long_description,