mdvtools.project_router#

Attributes#

logger

This should work as a drop-in replacement for Blueprint in the context

Classes#

ProjectBlueprintProtocol

Base class for protocol classes.

ProjectBlueprint

Base class for protocol classes.

SingleProjectShim

Base class for protocol classes.

Module Contents#

mdvtools.project_router.logger[source]#

This should work as a drop-in replacement for Blueprint in the context of a Flask app that can add (and remove) MDVProjects dynamically at runtime.

class mdvtools.project_router.ProjectBlueprintProtocol[source]#

Bases: Protocol

Base class for protocol classes.

Protocol classes are defined as:

class Proto(Protocol):
    def meth(self) -> int:
        ...

Such classes are primarily used with static type checkers that recognize structural subtyping (static duck-typing).

For example:

class C:
    def meth(self) -> int:
        return 0

def func(x: Proto) -> int:
    return x.meth()

func(C())  # Passes static type check

See PEP 544 for details. Protocol classes decorated with @typing.runtime_checkable act as simple-minded runtime protocols that check only the presence of given attributes, ignoring their type signatures. Protocol classes can be generic, they are defined as:

class GenProto[T](Protocol):
    def meth(self) -> T:
        ...
route(rule: str, **options: Any) Callable[source]#
before_request(f: Callable) Callable[source]#
class mdvtools.project_router.ProjectBlueprint(name: str, _ignored: str, url_prefix: str)[source]#

Bases: ProjectBlueprintProtocol

Base class for protocol classes.

Protocol classes are defined as:

class Proto(Protocol):
    def meth(self) -> int:
        ...

Such classes are primarily used with static type checkers that recognize structural subtyping (static duck-typing).

For example:

class C:
    def meth(self) -> int:
        return 0

def func(x: Proto) -> int:
    return x.meth()

func(C())  # Passes static type check

See PEP 544 for details. Protocol classes decorated with @typing.runtime_checkable act as simple-minded runtime protocols that check only the presence of given attributes, ignoring their type signatures. Protocol classes can be generic, they are defined as:

class GenProto[T](Protocol):
    def meth(self) -> T:
        ...
blueprints: Dict[str, ProjectBlueprint][source]#
static register_app(app: flask.Flask) None[source]#
name[source]#
url_prefix[source]#
routes: Dict[re.Pattern[str], Tuple[Callable, Dict[str, Any]]][source]#
before_request_funcs: List[Callable] = [][source]#
before_request(f: Callable) Callable[source]#

Register a function to run before each request for this blueprint.

route(rule: str, **options: Any) Callable[source]#
dispatch_request(subpath: str, project_id) flask.typing.ResponseReturnValue[source]#

We need to parse subpath so that we can route in a compatible way: Currently, we have regex patterns as keys in self.routes that match the subpath, with groups for any dynamic parts, so ‘/tracks/<path:path>’ becomes ‘/tracks/(.*)’. If we get a request for ‘/tracks/mytrack’, it will match the rule and call the method with ‘mytrack’ as the argument.

class mdvtools.project_router.SingleProjectShim(app: flask.Flask)[source]#

Bases: ProjectBlueprintProtocol

Base class for protocol classes.

Protocol classes are defined as:

class Proto(Protocol):
    def meth(self) -> int:
        ...

Such classes are primarily used with static type checkers that recognize structural subtyping (static duck-typing).

For example:

class C:
    def meth(self) -> int:
        return 0

def func(x: Proto) -> int:
    return x.meth()

func(C())  # Passes static type check

See PEP 544 for details. Protocol classes decorated with @typing.runtime_checkable act as simple-minded runtime protocols that check only the presence of given attributes, ignoring their type signatures. Protocol classes can be generic, they are defined as:

class GenProto[T](Protocol):
    def meth(self) -> T:
        ...
app[source]#
before_request(f: Callable) Callable[source]#
route(rule: str, **options: Any) Callable[source]#