Fix filtering skip_patterns (#868)

* Fix filtering skip_patterns

* cache skip actions
This commit is contained in:
Andrey Tikhonov 2022-08-13 23:49:23 +03:00 committed by GitHub
parent 016a8d3c6c
commit d5654068b1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -110,6 +110,19 @@ class LifetimeControllerMiddleware(BaseMiddleware):
# TODO: Rename class
skip_patterns = None
_skip_actions = None
@property
def skip_actions(self):
if self._skip_actions is None:
self._skip_actions = []
if self.skip_patterns:
self._skip_actions.extend([
f"pre_process_{item}",
f"process_{item}",
f"post_process_{item}",
])
return self._skip_actions
async def pre_process(self, obj, data, *args):
pass
@ -118,7 +131,7 @@ class LifetimeControllerMiddleware(BaseMiddleware):
pass
async def trigger(self, action, args):
if self.skip_patterns is not None and any(item in action for item in self.skip_patterns):
if action in self.skip_actions:
return False
obj, *args, data = args