server/session.py
changeset 7349 43416f63eca9
parent 7330 584907154ce3
child 7350 c2452cd57026
equal deleted inserted replaced
7347:691347c9467b 7349:43416f63eca9
   522         - on HOOKS_DENY_ALL mode, ensure those categories are not enabled
   522         - on HOOKS_DENY_ALL mode, ensure those categories are not enabled
   523         - on HOOKS_ALLOW_ALL mode, ensure those categories are disabled
   523         - on HOOKS_ALLOW_ALL mode, ensure those categories are disabled
   524         """
   524         """
   525         changes = set()
   525         changes = set()
   526         if self.hooks_mode is self.HOOKS_DENY_ALL:
   526         if self.hooks_mode is self.HOOKS_DENY_ALL:
   527             enablecats = self.enabled_hook_categories
   527             enabledcats = self.enabled_hook_categories
   528             for category in categories:
   528             for category in categories:
   529                 if category in enablecats:
   529                 if category in enabledcats:
   530                     enablecats.remove(category)
   530                     enabledcats.remove(category)
   531                     changes.add(category)
   531                     changes.add(category)
   532         else:
   532         else:
   533             disablecats = self.disabled_hook_categories
   533             disabledcats = self.disabled_hook_categories
   534             for category in categories:
   534             for category in categories:
   535                 if category not in disablecats:
   535                 if category not in disabledcats:
   536                     disablecats.add(category)
   536                     disabledcats.add(category)
   537                     changes.add(category)
   537                     changes.add(category)
   538         return tuple(changes)
   538         return tuple(changes)
   539 
   539 
   540     def enable_hook_categories(self, *categories):
   540     def enable_hook_categories(self, *categories):
   541         """enable the given hook categories:
   541         """enable the given hook categories:
   543         - on HOOKS_DENY_ALL mode, ensure those categories are enabled
   543         - on HOOKS_DENY_ALL mode, ensure those categories are enabled
   544         - on HOOKS_ALLOW_ALL mode, ensure those categories are not disabled
   544         - on HOOKS_ALLOW_ALL mode, ensure those categories are not disabled
   545         """
   545         """
   546         changes = set()
   546         changes = set()
   547         if self.hooks_mode is self.HOOKS_DENY_ALL:
   547         if self.hooks_mode is self.HOOKS_DENY_ALL:
   548             enablecats = self.enabled_hook_categories
   548             enabledcats = self.enabled_hook_categories
   549             for category in categories:
   549             for category in categories:
   550                 if category not in enablecats:
   550                 if category not in enabledcats:
   551                     enablecats.add(category)
   551                     enabledcats.add(category)
   552                     changes.add(category)
   552                     changes.add(category)
   553         else:
   553         else:
   554             disablecats = self.disabled_hook_categories
   554             disabledcats = self.disabled_hook_categories
   555             for category in categories:
   555             for category in categories:
   556                 if category in self.disabled_hook_categories:
   556                 if category in disabledcats:
   557                     disablecats.remove(category)
   557                     disabledcats.remove(category)
   558                     changes.add(category)
   558                     changes.add(category)
   559         return tuple(changes)
   559         return tuple(changes)
   560 
   560 
   561     def is_hook_category_activated(self, category):
   561     def is_hook_category_activated(self, category):
   562         """return a boolean telling if the given category is currently activated
   562         """return a boolean telling if the given category is currently activated