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
         http_code: HTTPStatus=HTTPStatus.INTERNAL_SERVER_ERROR,
310
         http_code: HTTPStatus=HTTPStatus.INTERNAL_SERVER_ERROR,
311
     ) -> None:
311
     ) -> None:
312
         self.handled_exception_class = handled_exception_class
312
         self.handled_exception_class = handled_exception_class
313
-        self.context = context
313
+        self._context = context
314
         self.http_code = http_code
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
     def _execute_wrapped_function(
322
     def _execute_wrapped_function(
317
         self,
323
         self,
318
         func,
324
         func,

+ 1 - 1
setup.py View File

23
     # Versions should comply with PEP440.  For a discussion on single-sourcing
23
     # Versions should comply with PEP440.  For a discussion on single-sourcing
24
     # the version across setup.py and the project code, see
24
     # the version across setup.py and the project code, see
25
     # https://packaging.python.org/en/latest/single_source_version.html
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
     description='HTTP api input/output manager',
28
     description='HTTP api input/output manager',
29
     # long_description=long_description,
29
     # long_description=long_description,