Table of Contents
MockProtocolsanic.models.asgiMockTransportsanic.models.asgiREPLContextsanic.models.ctx_typesREPLLocalsanic.models.ctx_typesFutureCommandsanic.models.futuresFutureExceptionsanic.models.futuresFutureListenersanic.models.futuresFutureMiddlewaresanic.models.futuresFutureRegistrysanic.models.futuresFutureRoutesanic.models.futuresFutureSignalsanic.models.futuresFutureStaticsanic.models.futuresCredentialssanic.models.http_typesHTMLProtocolsanic.models.protocol_typesRangesanic.models.protocol_typesTransportProtocolsanic.models.protocol_typesConnInfosanic.models.server_typesSignalsanic.models.server_typessanic.models.asgi.MockProtocol#
class MockProtocol(transport: MockTransport, loop)
complete#
async def complete(self): -> None
drain#
async def drain(self): -> None
is_complete#
@property
def is_complete(self): -> <class 'bool'>
pause_writing#
def pause_writing(self): -> None
push_data#
async def push_data(self, data: <class 'bytes'>): -> None
resume_writing#
def resume_writing(self): -> None
sanic.models.asgi.MockTransport#
Base class for transports.
class MockTransport(scope: collections.abc.MutableMapping[str, typing.Any], receive: typing.Callable[[], collections.abc.Awaitable[collections.abc.MutableMapping[str, typing.Any]]], send: typing.Callable[[collections.abc.MutableMapping[str, typing.Any]], collections.abc.Awaitable[None]]): -> None
add_task#
def add_task(self): -> None
close#
Close the transport.
def close(self)
Buffered data will be flushed asynchronously. No more data will be received. After all buffered data is flushed, the protocol's connection_lost() method will (eventually) be called with None as its argument.
create_websocket_connection#
def create_websocket_connection(self, send: typing.Callable[[collections.abc.MutableMapping[str, typing.Any]], collections.abc.Awaitable[None]], receive: typing.Callable[[], collections.abc.Awaitable[collections.abc.MutableMapping[str, typing.Any]]]): -> <class 'sanic.server.websockets.connection.WebSocketConnection'>
get_extra_info#
Get optional transport information.
def get_extra_info(self, info: <class 'str'>, default = None): -> typing.Union[str, bool, NoneType]
get_protocol#
Return the current protocol.
def get_protocol(self): -> <class 'sanic.models.asgi.MockProtocol'>
get_websocket_connection#
def get_websocket_connection(self): -> <class 'sanic.server.websockets.connection.WebSocketConnection'>
receive#
async def receive(self): -> collections.abc.MutableMapping[str, typing.Any]
send#
async def send(self, data): -> None
sanic.models.ctx_types.REPLContext#
class REPLContext()
add#
Add a local variable to be available in REPL context.
def add(self, var: typing.Any, name: typing.Optional[str] = None, desc: typing.Optional[str] = None)
Parameters
- var
Any A module, class, object or a class.
- name
Optional[str] An alias for the local. Defaults to None.
- desc
Optional[str] A brief description for the local. Defaults to None.
sanic.models.ctx_types.REPLLocal#
REPLLocal(var, name, desc)
class REPLLocal(var: typing.Any, name: <class 'str'>, desc: <class 'str'>)
sanic.models.futures.FutureCommand#
FutureCommand(name, func)
class FutureCommand(name: <class 'str'>, func: typing.Callable)
sanic.models.futures.FutureException#
FutureException(handler, exceptions)
class FutureException(handler: typing.Callable[[~Request, BaseException], typing.Optional[collections.abc.Coroutine[typing.Any, typing.Any, None]]], exceptions: list[BaseException])
sanic.models.futures.FutureListener#
FutureListener(listener, event, priority)
class FutureListener(listener: typing.Union[typing.Callable[[~Sanic], typing.Optional[collections.abc.Coroutine[typing.Any, typing.Any, None]]], typing.Callable[[~Sanic, asyncio.events.AbstractEventLoop], typing.Optional[collections.abc.Coroutine[typing.Any, typing.Any, None]]]], event: <class 'str'>, priority: <class 'int'>)
sanic.models.futures.FutureMiddleware#
FutureMiddleware(middleware, attach_to)
class FutureMiddleware(middleware: typing.Union[typing.Callable[[~Request], typing.Union[sanic.response.types.HTTPResponse, NoneType, collections.abc.Coroutine[typing.Any, typing.Any, typing.Optional[sanic.response.types.HTTPResponse]]]], typing.Callable[[~Request, sanic.response.types.BaseHTTPResponse], typing.Union[sanic.response.types.HTTPResponse, NoneType, collections.abc.Coroutine[typing.Any, typing.Any, typing.Optional[sanic.response.types.HTTPResponse]]]]], attach_to: <class 'str'>)
sanic.models.futures.FutureRegistry#
set() -> new empty set object
class FutureRegistry(self)
set(iterable) -> new set object
Build an unordered collection of unique elements.
sanic.models.futures.FutureRoute#
FutureRoute(handler, uri, methods, host, strict_slashes, stream, version, name, ignore_body, websocket, subprotocols, unquote, static, version_prefix, error_format, route_context)
class FutureRoute(handler: <class 'str'>, uri: <class 'str'>, methods: typing.Optional[collections.abc.Iterable[str]], host: typing.Union[str, list[str]], strict_slashes: <class 'bool'>, stream: <class 'bool'>, version: typing.Optional[int], name: <class 'str'>, ignore_body: <class 'bool'>, websocket: <class 'bool'>, subprotocols: typing.Optional[list[str]], unquote: <class 'bool'>, static: <class 'bool'>, version_prefix: <class 'str'>, error_format: typing.Optional[str], route_context: <class 'sanic.types.hashable_dict.HashableDict'>)
sanic.models.futures.FutureSignal#
FutureSignal(handler, event, condition, exclusive, priority)
class FutureSignal(handler: typing.Callable[..., collections.abc.Coroutine[typing.Any, typing.Any, None]], event: <class 'str'>, condition: typing.Optional[dict[str, str]], exclusive: <class 'bool'>, priority: <class 'int'>)
sanic.models.futures.FutureStatic#
FutureStatic(uri, file_or_directory, pattern, use_modified_since, use_content_range, stream_large_files, name, host, strict_slashes, content_type, resource_type, directory_handler)
class FutureStatic(uri: <class 'str'>, file_or_directory: <class 'pathlib.Path'>, pattern: <class 'str'>, use_modified_since: <class 'bool'>, use_content_range: <class 'bool'>, stream_large_files: typing.Union[bool, int], name: <class 'str'>, host: typing.Optional[str], strict_slashes: typing.Optional[bool], content_type: typing.Optional[str], resource_type: typing.Optional[str], directory_handler: <class 'sanic.handlers.directory.DirectoryHandler'>)
sanic.models.http_types.Credentials#
Credentials(auth_type: 'Optional[str]', token: 'Optional[str]', _username: 'Optional[str]' = None, _password: 'Optional[str]' = None)
class Credentials(auth_type: Optional[str], token: Optional[str], _username: Optional[str] = None, _password: Optional[str] = None): -> None
password#
@property
def password(self)
username#
@property
def username(self)
sanic.models.protocol_types.HTMLProtocol#
Base class for protocol classes.
class HTMLProtocol(args, kwargs)
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
sanic.models.protocol_types.Range#
Base class for protocol classes.
class Range(args, kwargs)
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
sanic.models.protocol_types.TransportProtocol#
Base class for transports.
class TransportProtocol(extra = None)
close#
Close the transport.
def close(self)
Buffered data will be flushed asynchronously. No more data will be received. After all buffered data is flushed, the protocol's connection_lost() method will (eventually) be called with None as its argument.
sanic.models.server_types.ConnInfo#
Local and remote addresses and SSL status info.
class ConnInfo(transport: TransportProtocol, unix = None)
sanic.models.server_types.Signal#
class Signal()