def register_constructor(cls, extension, constructor):
    """
        Register a function as a constructor.  Registered constructors
        apply to all instances of `URLParser`.

        The extension should have a leading ``.``, or the special
        extensions ``dir`` (for directories) and ``*`` (a catch-all).

        `constructor` must be a callable that takes two arguments:
        ``environ`` and ``filename``, and returns a WSGI application.
        """
    d = cls.global_constructors
    assert extension not in d, 'A constructor already exists for the extension %r (%r) when attemption to register constructor %r' % (
        extension, d[extension], constructor)
    d[extension] = constructor
