Home / Class/ RequestHooksMixin Class — requests Architecture

RequestHooksMixin Class — requests Architecture

Architecture documentation for the RequestHooksMixin class in models.py from the requests codebase.

Entity Profile

Dependency Diagram

graph TD
  95bd3ad9_fc53_a808_b595_bd723df9bdcd["RequestHooksMixin"]
  461bc6e0_32e7_8eab_ec87_7226e7be0d13["models.py"]
  95bd3ad9_fc53_a808_b595_bd723df9bdcd -->|defined in| 461bc6e0_32e7_8eab_ec87_7226e7be0d13
  744a2df0_df78_c759_c800_b42f7399cee7["register_hook()"]
  95bd3ad9_fc53_a808_b595_bd723df9bdcd -->|method| 744a2df0_df78_c759_c800_b42f7399cee7
  7e96691e_86d6_5726_8c90_629aa4ea9a52["deregister_hook()"]
  95bd3ad9_fc53_a808_b595_bd723df9bdcd -->|method| 7e96691e_86d6_5726_8c90_629aa4ea9a52

Relationship Graph

Source Code

src/requests/models.py lines 208–229

class RequestHooksMixin:
    def register_hook(self, event, hook):
        """Properly register a hook."""

        if event not in self.hooks:
            raise ValueError(f'Unsupported event specified, with event name "{event}"')

        if isinstance(hook, Callable):
            self.hooks[event].append(hook)
        elif hasattr(hook, "__iter__"):
            self.hooks[event].extend(h for h in hook if isinstance(h, Callable))

    def deregister_hook(self, event, hook):
        """Deregister a previously registered hook.
        Returns True if the hook existed, False if not.
        """

        try:
            self.hooks[event].remove(hook)
            return True
        except ValueError:
            return False

Domain

Frequently Asked Questions

What is the RequestHooksMixin class?
RequestHooksMixin is a class in the requests codebase, defined in src/requests/models.py.
Where is RequestHooksMixin defined?
RequestHooksMixin is defined in src/requests/models.py at line 208.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free