Home / Function/ register_hook() — requests Function Reference

register_hook() — requests Function Reference

Architecture documentation for the register_hook() function in models.py from the requests codebase.

Entity Profile

Dependency Diagram

graph TD
  744a2df0_df78_c759_c800_b42f7399cee7["register_hook()"]
  95bd3ad9_fc53_a808_b595_bd723df9bdcd["RequestHooksMixin"]
  744a2df0_df78_c759_c800_b42f7399cee7 -->|defined in| 95bd3ad9_fc53_a808_b595_bd723df9bdcd
  a9a27ab4_fcfa_3217_4d25_ed320e4fa77a["__init__()"]
  a9a27ab4_fcfa_3217_4d25_ed320e4fa77a -->|calls| 744a2df0_df78_c759_c800_b42f7399cee7
  a3ee9d20_5f94_9ee9_4c40_009b9b7e5597["prepare_hooks()"]
  a3ee9d20_5f94_9ee9_4c40_009b9b7e5597 -->|calls| 744a2df0_df78_c759_c800_b42f7399cee7
  style 744a2df0_df78_c759_c800_b42f7399cee7 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

src/requests/models.py lines 209–218

    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))

Domain

Subdomains

Frequently Asked Questions

What does register_hook() do?
register_hook() is a function in the requests codebase, defined in src/requests/models.py.
Where is register_hook() defined?
register_hook() is defined in src/requests/models.py at line 209.
What calls register_hook()?
register_hook() is called by 2 function(s): __init__, prepare_hooks.

Analyze Your Own Codebase

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

Try Supermodel Free