From 7ab0338a98710046bf107e37b2ed36839af0eb0d Mon Sep 17 00:00:00 2001 From: Sergey Klyuykov Date: Tue, 26 Sep 2017 17:22:29 +1000 Subject: [PATCH] Unregister everything in routers --- .gitlab-ci.yml | 2 +- polemarch/api/routers.py | 15 ++++++++++++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 2a92ae90..7791890d 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -119,7 +119,7 @@ build_zip: script: - make rpm RELEASE=${CI_BUILD_ID} artifacts: - expire_in: 20 minutes + expire_in: 30 minutes paths: - dist/ retry: 2 diff --git a/polemarch/api/routers.py b/polemarch/api/routers.py index b7c086d3..8d670b57 100644 --- a/polemarch/api/routers.py +++ b/polemarch/api/routers.py @@ -36,14 +36,20 @@ def register_view(self, prefix, view, name=None): name = name or view().get_view_name().lower() self.custom_urls.append((prefix, view, name)) - def unregister(self, prefix): + def _unreg(self, prefix, objects_list): index = 0 - for reg_prefix, _, _ in self.registry: + for reg_prefix, _, _ in objects_list: if reg_prefix == prefix: - del self.registry[index] + del objects_list[index] break index += 1 + def unregister_view(self, prefix): + self._unreg(prefix, self.custom_urls) # nocv + + def unregister(self, prefix): + self._unreg(prefix, self.registry) + class APIRouter(_AbstractRouter): root_view_name = 'api-v1' @@ -118,6 +124,9 @@ def register_router(self, prefix, router, name=None): name = name or router.root_view_name self.routers.append((prefix, router, name)) + def unregister_router(self, prefix): + self._unreg(prefix, self.routers) # nocv + def get_urls(self): urls = super(MainRouter, self).get_urls() for prefix, router, _ in self.routers: