##// END OF EJS Templates
hooks: use safer way to validate kwargs. If rcextensions are disable we shouldn't...
marcink -
r3200:1ac5d1f8 stable
parent child Browse files
Show More
@@ -339,7 +339,12 b' class ExtensionCallback(object):'
339 self._kwargs_keys = set(kwargs_keys)
339 self._kwargs_keys = set(kwargs_keys)
340
340
341 def __call__(self, *args, **kwargs):
341 def __call__(self, *args, **kwargs):
342 log.debug('Calling extension callback for %s', self._hook_name)
342 log.debug('Calling extension callback for `%s`', self._hook_name)
343 callback = self._get_callback()
344 if not callback:
345 log.debug('extension callback `%s` not found, skipping...', self._hook_name)
346 return
347
343 kwargs_to_pass = {}
348 kwargs_to_pass = {}
344 for key in self._kwargs_keys:
349 for key in self._kwargs_keys:
345 try:
350 try:
@@ -349,16 +354,11 b' class ExtensionCallback(object):'
349 key, self._kwargs_keys)
354 key, self._kwargs_keys)
350 raise
355 raise
351
356
352 # backward compat for removed api_key for old hooks. THis was it works
357 # backward compat for removed api_key for old hooks. This was it works
353 # with older rcextensions that require api_key present
358 # with older rcextensions that require api_key present
354 if self._hook_name in ['CREATE_USER_HOOK', 'DELETE_USER_HOOK']:
359 if self._hook_name in ['CREATE_USER_HOOK', 'DELETE_USER_HOOK']:
355 kwargs_to_pass['api_key'] = '_DEPRECATED_'
360 kwargs_to_pass['api_key'] = '_DEPRECATED_'
356
357 callback = self._get_callback()
358 if callback:
359 return callback(**kwargs_to_pass)
361 return callback(**kwargs_to_pass)
360 else:
361 log.debug('extensions callback not found skipping...')
362
362
363 def is_active(self):
363 def is_active(self):
364 return hasattr(rhodecode.EXTENSIONS, self._hook_name)
364 return hasattr(rhodecode.EXTENSIONS, self._hook_name)
General Comments 0
You need to be logged in to leave comments. Login now