sdkagent

tornado API reference

306 public APIs from tornado (tornadoweb/tornado) — 84 classes, 48 functions, 174 methods. Signatures extracted by static analysis of the actual source.

Repository: tornadoweb/tornado

KindCount
Classes84
Functions48
Methods174

API list

classtornado.auth.FacebookGraphMixin
Facebook authentication using the new Graph API and OAuth2.
classtornado.auth.GoogleOAuth2Mixin
Google authentication using OAuth2.
classtornado.auth.OAuth2Mixin
Abstract implementation of OAuth 2.0.
methodtornado.auth.OAuth2Mixin.oauth2_request(url:str, access_token:str | None=None, post_args:dict[str, Any] | None=None, **args:Any) -> Any
Fetches the given URL auth an OAuth2 access token.
classtornado.auth.OAuthMixin
Abstract implementation of OAuth 1.0 and 1.0a.
methodtornado.auth.OAuthMixin.get_authenticated_user(http_client:httpclient.AsyncHTTPClient | None=None) -> dict[str, Any]
Gets the OAuth authorized user and access token.
classtornado.auth.OpenIdMixin
Abstract implementation of OpenID and Attribute Exchange.
methodtornado.auth.OpenIdMixin.get_authenticated_user(http_client:httpclient.AsyncHTTPClient | None=None) -> dict[str, Any]
Fetches the authenticated user data upon redirect.
classtornado.auth.TwitterMixin
Twitter OAuth authentication.
functornado.autoreload.add_reload_hook(fn:Callable[[], None]) -> None
Add a function to be called before reloading the process.
functornado.autoreload.start(check_time:int=500) -> None
Begins watching source files for changes.
functornado.autoreload.wait() -> None
Wait for a watched file to change, then restart the process.
functornado.autoreload.watch(filename:str) -> None
Add a file to the watch list.
functornado.concurrent.future_set_exception_unless_cancelled(future:'Union[futures.Future[_T], Future[_T]]', exc:BaseException) -> None
Set the given ``exc`` as the `Future`'s exception.
functornado.escape.json_decode(value:str | bytes) -> Any
Returns Python objects for the given JSON string.
functornado.escape.json_encode(value:Any) -> str
JSON-encodes the given Python object.
functornado.escape.recursive_unicode(obj:Any) -> Any
Walks a simple data structure, converting byte strings to unicode.
functornado.escape.squeeze(value:str) -> str
Replace all sequences of whitespace chars with a single space.
functornado.escape.url_escape(value:str | bytes, plus:bool=True) -> str
Returns a URL-encoded version of the given value.
functornado.escape.xhtml_escape(value:str | bytes) -> str
Escapes a string so it is valid within HTML or XML.
functornado.escape.xhtml_unescape(value:str | bytes) -> str
Un-escapes an XML-escaped string.
classtornado.gen.Return
Special exception to return a value from a `coroutine`.
classtornado.gen.Runner
Internal implementation of `tornado.gen.coroutine`.
functornado.gen.convert_yielded(yielded:_Yieldable) -> Future
Convert a yielded object into a `.Future`.
functornado.gen.is_coroutine_function(func:Any) -> bool
Return whether *func* is a coroutine function, i.e.
functornado.gen.maybe_future(x:Any) -> Future
Converts ``x`` into a `.Future`.
functornado.gen.sleep(duration:float) -> 'Future[None]'
Return a `.Future` that resolves after the given number of seconds.
classtornado.http1connection.HTTP1Connection
Implements the HTTP/1.x protocol.
methodtornado.http1connection.HTTP1Connection.detach() -> iostream.IOStream
Take control of the underlying stream.
methodtornado.http1connection.HTTP1Connection.finish() -> None
Implements `.HTTPConnection.finish`.
methodtornado.http1connection.HTTP1Connection.read_response(delegate:httputil.HTTPMessageDelegate) -> Awaitable[bool]
Read a single HTTP response.
methodtornado.http1connection.HTTP1Connection.set_body_timeout(timeout:float) -> None
Sets the body timeout for a single request.
methodtornado.http1connection.HTTP1Connection.set_max_body_size(max_body_size:int) -> None
Sets the body size limit for a single request.
methodtornado.http1connection.HTTP1Connection.write(chunk:bytes) -> 'Future[None]'
Implements `.HTTPConnection.write`.
classtornado.http1connection.HTTP1ServerConnection
An HTTP/1.x server.
methodtornado.http1connection.HTTP1ServerConnection.close() -> None
Closes the connection.
methodtornado.http1connection.HTTP1ServerConnection.start_serving(delegate:httputil.HTTPServerConnectionDelegate) -> None
Starts serving requests on this connection.
functornado.http1connection.parse_hex_int(s:str) -> int
Parse a non-negative hexadecimal integer from a string.
functornado.http1connection.parse_int(s:str) -> int
Parse a non-negative integer from a string.
classtornado.httpclient.AsyncHTTPClient
An non-blocking HTTP client.
methodtornado.httpclient.AsyncHTTPClient.configure(impl:'Union[None, str, Type[Configurable]]', **kwargs:Any) -> None
Configures the `AsyncHTTPClient` subclass to use.
classtornado.httpclient.HTTPClient
A blocking HTTP client.
methodtornado.httpclient.HTTPClient.close() -> None
Closes the HTTPClient, freeing any resources used.
methodtornado.httpclient.HTTPClient.fetch(request:Union['HTTPRequest', str], **kwargs:Any) -> 'HTTPResponse'
Executes a request, returning an `HTTPResponse`.
classtornado.httpclient.HTTPClientError
Exception thrown for an unsuccessful HTTP request.
classtornado.httpclient.HTTPRequest
HTTP client request object.
classtornado.httpclient.HTTPResponse
HTTP Response object.
classtornado.httpserver.HTTPServer
A non-blocking, single-threaded HTTP server.
classtornado.httputil.HTTPConnection
Applications use this interface to write their responses.
methodtornado.httputil.HTTPConnection.finish() -> None
Indicates that the last body data has been written.
methodtornado.httputil.HTTPConnection.write(chunk:bytes) -> Future[None]
Writes a chunk of body data.
methodtornado.httputil.HTTPConnection.write_headers(start_line:RequestStartLine | ResponseStartLine, headers:HTTPHeaders, chunk:bytes | None=None) -> Future[None]
Write an HTTP header block.
classtornado.httputil.HTTPFile
Represents a file uploaded via a form.
classtornado.httputil.HTTPHeaders
A dictionary that maintains ``Http-Header-Case`` for all keys.
methodtornado.httputil.HTTPHeaders.add(name:str, value:str, *_chars_are_bytes:bool=True) -> None
Adds a new value for the given key.
methodtornado.httputil.HTTPHeaders.get_all() -> Iterable[tuple[str, str]]
Returns an iterable of all (name, value) pairs.
methodtornado.httputil.HTTPHeaders.get_list(name:str) -> list[str]
Returns all values for the given header as a list.
methodtornado.httputil.HTTPHeaders.parse(headers:str, *_chars_are_bytes:bool=True) -> HTTPHeaders
Returns a dictionary from HTTP header text.
methodtornado.httputil.HTTPHeaders.parse_line(line:str, *_chars_are_bytes:bool=True) -> None
Updates the dictionary with a single header line.
classtornado.httputil.HTTPOutputError
Exception class for errors in HTTP output.
classtornado.httputil.HTTPServerRequest
A single HTTP request.
methodtornado.httputil.HTTPServerRequest.cookies() -> dict[str, http.cookies.Morsel]
A dictionary of ``http.cookies.Morsel`` objects.
methodtornado.httputil.HTTPServerRequest.full_url() -> str
Reconstructs the full URL for this request.
methodtornado.httputil.HTTPServerRequest.get_ssl_certificate(binary_form:bool=False) -> None | dict | bytes
Returns the client's SSL certificate, if any.
classtornado.httputil.ParseBodyConfig
This class configures the parsing of request bodies.
functornado.httputil.format_timestamp(ts:int | float | tuple | time.struct_time | datetime.datetime) -> str
Formats a timestamp in the format used by HTTP.
functornado.httputil.parse_body_arguments(content_type:str, body:bytes, arguments:dict[str, list[bytes]], files:dict[str, list[HTTPFile]], headers:HTTPHeaders | None=None, *config:ParseBodyConfig | None=None) -> None
Parses a form request body.
functornado.httputil.parse_cookie(cookie:str) -> dict[str, str]
Parse a ``Cookie`` HTTP header into a dict of name/value pairs.
functornado.httputil.parse_multipart_form_data(boundary:bytes, data:bytes, arguments:dict[str, list[bytes]], files:dict[str, list[HTTPFile]], *config:ParseMultipartConfig | None=None) -> None
Parses a ``multipart/form-data`` body.
functornado.httputil.split_host_and_port(netloc:str) -> tuple[str, int | None]
Returns ``(host, port)`` tuple from ``netloc``.
classtornado.ioloop.IOLoop
An I/O event loop.
methodtornado.ioloop.IOLoop.add_callback(callback:Callable, *args:Any, **kwargs:Any) -> None
Calls the given callback on the next I/O loop iteration.
methodtornado.ioloop.IOLoop.add_callback_from_signal(callback:Callable, *args:Any, **kwargs:Any) -> None
Calls the given callback on the next I/O loop iteration.
methodtornado.ioloop.IOLoop.add_timeout(deadline:float | datetime.timedelta, callback:Callable, *args:Any, **kwargs:Any) -> object
Runs the ``callback`` at the time ``deadline`` from the I/O loop.
methodtornado.ioloop.IOLoop.call_at(when:float, callback:Callable, *args:Any, **kwargs:Any) -> object
Runs the ``callback`` at the absolute time designated by ``when``.
methodtornado.ioloop.IOLoop.call_later(delay:float, callback:Callable, *args:Any, **kwargs:Any) -> object
Runs the ``callback`` after ``delay`` seconds have passed.
methodtornado.ioloop.IOLoop.clear_current() -> None
Clears the `IOLoop` for the current thread.
methodtornado.ioloop.IOLoop.clear_instance() -> None
Deprecated alias for `clear_current()`.
methodtornado.ioloop.IOLoop.close(all_fds:bool=False) -> None
Closes the `IOLoop`, freeing any resources used.
methodtornado.ioloop.IOLoop.install() -> None
Deprecated alias for `make_current()`.
methodtornado.ioloop.IOLoop.instance() -> IOLoop
Deprecated alias for `IOLoop.current()`.
methodtornado.ioloop.IOLoop.make_current() -> None
Makes this the `IOLoop` for the current thread.
methodtornado.ioloop.IOLoop.remove_handler(fd:int | _Selectable) -> None
Stop listening for events on ``fd``.
methodtornado.ioloop.IOLoop.remove_timeout(timeout:object) -> None
Cancels a pending timeout.
methodtornado.ioloop.IOLoop.run_sync(func:Callable, timeout:float | None=None) -> Any
Starts the `IOLoop`, runs the given function, and stops the loop.
methodtornado.ioloop.IOLoop.spawn_callback(callback:Callable, *args:Any, **kwargs:Any) -> None
Calls the given callback on the next IOLoop iteration.
methodtornado.ioloop.IOLoop.start() -> None
Starts the I/O loop.
methodtornado.ioloop.IOLoop.stop() -> None
Stop the I/O loop.
methodtornado.ioloop.IOLoop.time() -> float
Returns the current time according to the `IOLoop`'s clock.
methodtornado.ioloop.IOLoop.update_handler(fd:int | _Selectable, events:int) -> None
Changes the events we listen for ``fd``.
classtornado.ioloop.PeriodicCallback
Schedules the given callback to be called periodically.
methodtornado.ioloop.PeriodicCallback.start() -> None
Starts the timer.
methodtornado.ioloop.PeriodicCallback.stop() -> None
Stops the timer.
classtornado.iostream.IOStream
Socket-based `IOStream` implementation.
methodtornado.iostream.IOStream.connect(address:Any, server_hostname:str | None=None) -> 'Future[_IOStreamType]'
Connects the socket to a remote address without blocking.
classtornado.iostream.PipeIOStream
Pipe-based `IOStream` implementation.
classtornado.iostream.StreamClosedError
Exception raised by `IOStream` methods when the stream is closed.
classtornado.iostream.UnsatisfiableReadError
Exception raised when a read cannot be satisfied.
classtornado.locale.CSVLocale
Locale implementation using tornado's CSV translation format.
classtornado.locale.GettextLocale
Locale implementation using the `gettext` module.
classtornado.locale.Locale
Object representing a locale.
methodtornado.locale.Locale.format_date(date:int | float | datetime.datetime, gmt_offset:int=0, relative:bool=True, shorter:bool=False, full_format:bool=False) -> str
Formats the given date.
methodtornado.locale.Locale.format_day(date:datetime.datetime, gmt_offset:int=0, dow:bool=True) -> str
Formats the given date as a day of week.
methodtornado.locale.Locale.friendly_number(value:int) -> str
Returns a comma-separated number for the given integer.
methodtornado.locale.Locale.get(code:str) -> Locale
Returns the Locale for the given locale code.
methodtornado.locale.Locale.get_closest(*locale_codes:str) -> Locale
Returns the closest match for the given locale code.
methodtornado.locale.Locale.list(parts:Any) -> str
Returns a comma-separated list for the given list of parts.
functornado.locale.get(*locale_codes:str) -> Locale
Returns the closest match for the given locale codes.
functornado.locale.get_supported_locales() -> Iterable[str]
Returns a list of all the supported locale codes.
functornado.locale.load_translations(directory:str, encoding:str | None=None) -> None
Loads translations from CSV files in a directory.
functornado.locale.set_default_locale(code:str) -> None
Sets the default locale.
methodtornado.locks.BoundedSemaphore.release() -> None
Increment the counter and wake one waiter.
methodtornado.locks.Condition.notify(n:int=1) -> None
Wake ``n`` waiters.
methodtornado.locks.Condition.notify_all() -> None
Wake all waiters.
methodtornado.locks.Condition.wait(timeout:float | datetime.timedelta | None=None) -> Awaitable[bool]
Wait for `.notify`.
classtornado.locks.Event
An event blocks coroutines until its internal flag is set to True.
methodtornado.locks.Event.clear() -> None
Reset the internal flag to ``False``.
methodtornado.locks.Event.is_set() -> bool
Return ``True`` if the internal flag is true.
methodtornado.locks.Event.set() -> None
Set the internal flag to ``True``.
methodtornado.locks.Event.wait(timeout:float | datetime.timedelta | None=None) -> Awaitable[None]
Block until the internal flag is true.
classtornado.locks.Lock
A lock for coroutines.
methodtornado.locks.Lock.acquire(timeout:float | datetime.timedelta | None=None) -> Awaitable[_ReleasingContextManager]
Attempt to lock.
methodtornado.locks.Lock.release() -> None
Unlock.
methodtornado.locks.Semaphore.acquire(timeout:float | datetime.timedelta | None=None) -> Awaitable[_ReleasingContextManager]
Decrement the counter.
methodtornado.locks.Semaphore.release() -> None
Increment the counter and wake one waiter.
classtornado.log.LogFormatter
Log formatter used in Tornado.
functornado.log.define_logging_options(options:Any=None) -> None
Add logging-related flags to ``options``.
functornado.log.enable_pretty_logging(options:Any=None, logger:logging.Logger | None=None) -> None
Turns on formatted logging output as configured.
classtornado.netutil.DefaultExecutorResolver
Resolver implementation using `.IOLoop.run_in_executor`.
classtornado.netutil.DefaultLoopResolver
Resolver implementation using `asyncio.loop.getaddrinfo`.
classtornado.netutil.ExecutorResolver
Resolver implementation using a `concurrent.futures.Executor`.
classtornado.netutil.OverrideResolver
Wraps a resolver with a mapping of overrides.
classtornado.netutil.Resolver
Configurable asynchronous DNS resolver interface.
methodtornado.netutil.Resolver.close() -> None
Closes the `Resolver`, freeing any resources used.
methodtornado.netutil.Resolver.resolve(host:str, port:int, family:socket.AddressFamily=socket.AF_UNSPEC) -> Awaitable[list[tuple[int, Any]]]
Resolves an address.
classtornado.netutil.ThreadedResolver
Multithreaded non-blocking `Resolver` implementation.
functornado.netutil.bind_unix_socket(file:str, mode:int=384, backlog:int=_DEFAULT_BACKLOG) -> socket.socket
Creates a listening unix socket.
functornado.netutil.is_valid_ip(ip:str) -> bool
Returns ``True`` if the given string is a well-formed IP address.
classtornado.options.Error
Exception raised by errors in the options module.
classtornado.options.OptionParser
A collection of options, a dictionary with object-like access.
methodtornado.options.OptionParser.as_dict() -> dict[str, Any]
The names and values of all options.
methodtornado.options.OptionParser.group_dict(group:str) -> dict[str, Any]
The names and values of options in a group.
methodtornado.options.OptionParser.groups() -> set[str]
The set of option-groups created by ``define``.
methodtornado.options.OptionParser.items() -> Iterable[tuple[str, Any]]
An iterable of (name, value) pairs.
methodtornado.options.OptionParser.parse_config_file(path:str, final:bool=True) -> None
Parses and loads the config file at the given path.
methodtornado.options.OptionParser.print_help(file:TextIO | None=None) -> None
Prints all the command line options to stderr (or another file).
functornado.options.add_parse_callback(callback:Callable[[], None]) -> None
Adds a parse callback, to be invoked when option parsing is done.
functornado.options.parse_command_line(args:list[str] | None=None, final:bool=True) -> list[str]
Parses global options from the command line.
functornado.options.parse_config_file(path:str, final:bool=True) -> None
Parses global options from a config file.
functornado.options.print_help(file:TextIO | None=None) -> None
Prints all the command line options to stderr (or another file).
functornado.platform.asyncio.to_asyncio_future(tornado_future:asyncio.Future) -> asyncio.Future
Convert a Tornado yieldable object to an `asyncio.Future`.
classtornado.platform.caresresolver.CaresResolver
Name resolver based on the c-ares library.
classtornado.process.Subprocess
Wraps ``subprocess.Popen`` with IOStream support.
methodtornado.process.Subprocess.initialize() -> None
Initializes the ``SIGCHLD`` handler.
methodtornado.process.Subprocess.set_exit_callback(callback:Callable[[int], None]) -> None
Runs ``callback`` when this process exits.
methodtornado.process.Subprocess.uninitialize() -> None
Removes the ``SIGCHLD`` handler.
methodtornado.process.Subprocess.wait_for_exit(raise_error:bool=True) -> 'Future[int]'
Returns a `.Future` which resolves when the process exits.
functornado.process.cpu_count() -> int
Returns the number of processors on this machine.
functornado.process.fork_processes(num_processes:int | None, max_restarts:int | None=None) -> int
Starts multiple worker processes.
functornado.process.task_id() -> int | None
Returns the current task id, if any.
classtornado.queues.LifoQueue
A `.Queue` that retrieves the most recently put items first.
classtornado.queues.Queue
Coordinate producer and consumer coroutines.
methodtornado.queues.Queue.get(timeout:float | datetime.timedelta | None=None) -> Awaitable[_T]
Remove and return an item from the queue.
methodtornado.queues.Queue.get_nowait() -> _T
Remove and return an item from the queue without blocking.
methodtornado.queues.Queue.join(timeout:float | datetime.timedelta | None=None) -> Awaitable[None]
Block until all items in the queue are processed.
methodtornado.queues.Queue.maxsize() -> int
Number of items allowed in the queue.
methodtornado.queues.Queue.put_nowait(item:_T) -> None
Put an item into the queue without blocking.
methodtornado.queues.Queue.qsize() -> int
Number of items in the queue.
methodtornado.queues.Queue.task_done() -> None
Indicate that a formerly enqueued task is complete.
classtornado.queues.QueueEmpty
Raised by `.Queue.get_nowait` when the queue has no items.
classtornado.routing.AnyMatches
Matches any request.
classtornado.routing.Matcher
Represents a matcher for request features.
methodtornado.routing.Matcher.match(request:httputil.HTTPServerRequest) -> dict[str, Any] | None
Matches current instance against the request.
methodtornado.routing.Matcher.reverse(*args:Any) -> str | None
Reconstructs full url from matcher instance and additional arguments.
classtornado.routing.PathMatches
Matches requests with paths specified by ``path_pattern`` regex.
classtornado.routing.ReversibleRuleRouter
A rule-based router that implements ``reverse_url`` method.
classtornado.routing.Router
Abstract router interface.
classtornado.routing.Rule
A routing rule.
classtornado.routing.RuleRouter
Rule-based router implementation.
methodtornado.routing.RuleRouter.add_rules(rules:_RuleList) -> None
Appends new rules to the router.
methodtornado.routing.RuleRouter.process_rule(rule:'Rule') -> 'Rule'
Override this method for additional preprocessing of each rule.
classtornado.routing.URLSpec
Specifies mappings between URLs and handlers.
classtornado.simple_httpclient.HTTPTimeoutError
Error raised by SimpleAsyncHTTPClient on timeout.
classtornado.simple_httpclient.SimpleAsyncHTTPClient
Non-blocking HTTP client with no external dependencies.
classtornado.tcpclient.TCPClient
A non-blocking TCP connection factory.
classtornado.tcpserver.TCPServer
A non-blocking, single-threaded TCP server.
methodtornado.tcpserver.TCPServer.add_socket(socket:socket.socket) -> None
Singular version of `add_sockets`.
methodtornado.tcpserver.TCPServer.add_sockets(sockets:Iterable[socket.socket]) -> None
Makes this server start accepting connections on the given sockets.
methodtornado.tcpserver.TCPServer.start(num_processes:int | None=1, max_restarts:int | None=None) -> None
Starts this server in the `.IOLoop`.
methodtornado.tcpserver.TCPServer.stop() -> None
Stops listening for new connections.
classtornado.template.BaseLoader
Base class for template loaders.
methodtornado.template.BaseLoader.load(name:str, parent_path:str | None=None) -> Template
Loads a template.
methodtornado.template.BaseLoader.reset() -> None
Resets the cache of compiled templates.
methodtornado.template.BaseLoader.resolve_path(name:str, parent_path:str | None=None) -> str
Converts a possibly-relative path to absolute (used internally).
classtornado.template.DictLoader
A template loader that loads from a dictionary.
classtornado.template.Loader
A template loader that loads from a single root directory.
classtornado.template.ParseError
Raised for template syntax errors.
classtornado.template.Template
A compiled template.
methodtornado.template.Template.generate(**kwargs:Any) -> bytes
Generate this template with the given arguments.
functornado.template.filter_whitespace(mode:str, text:str) -> str
Transform whitespace in ``text`` according to ``mode``.
classtornado.testing.AsyncHTTPSTestCase
A test case that starts an HTTPS server.
classtornado.testing.AsyncHTTPTestCase
A test case that starts up an HTTP server.
methodtornado.testing.AsyncHTTPTestCase.fetch(path:str, raise_error:bool=False, **kwargs:Any) -> HTTPResponse
Convenience method to synchronously fetch a URL.
methodtornado.testing.AsyncHTTPTestCase.get_http_port() -> int
Returns the port used by the server.
methodtornado.testing.AsyncHTTPTestCase.get_url(path:str) -> str
Returns an absolute url for the given path on the test server.
classtornado.testing.ExpectLog
Context manager to capture and suppress expected log output.
functornado.testing.bind_unused_port(reuse_port:bool=False, address:str='127.0.0.1') -> tuple[socket.socket, int]
Binds a server socket to an available port on localhost.
functornado.testing.get_async_test_timeout() -> float
Get the global timeout setting for async tests.
functornado.testing.main(**kwargs:Any) -> None
A simple test runner.
functornado.testing.setup_with_context_manager(testcase:unittest.TestCase, cm:Any) -> Any
Use a context manager to setUp a test case.
classtornado.util.ArgReplacer
Replaces one value in an ``args, kwargs`` pair.
methodtornado.util.ArgReplacer.replace(new_value:Any, args:Sequence[Any], kwargs:dict[str, Any]) -> tuple[Any, Sequence[Any], dict[str, Any]]
Replace the named argument in ``args, kwargs`` with ``new_value``.
classtornado.util.Configurable
Base class for configurable interfaces.
methodtornado.util.Configurable.configurable_base() -> type[Configurable]
Returns the base class of a configurable hierarchy.
methodtornado.util.Configurable.configure(impl:None | str | type[Configurable], **kwargs:Any) -> None
Sets the class to use when the base class is instantiated.
methodtornado.util.Configurable.configured_class() -> type[Configurable]
Returns the currently configured class.
classtornado.util.GzipDecompressor
Streaming gzip decompressor.
methodtornado.util.GzipDecompressor.decompress(value:bytes, max_length:int=0) -> bytes
Decompress a chunk, returning newly-available data.
methodtornado.util.GzipDecompressor.unconsumed_tail() -> bytes
Returns the unconsumed portion left over
functornado.util.errno_from_exception(e:BaseException) -> int | None
Provides the errno from an Exception object.
functornado.util.import_object(name:str) -> Any
Imports an object by name.
functornado.util.re_unescape(s:str) -> str
Unescape a string escaped by `re.escape`.
functornado.util.timedelta_to_seconds(td:datetime.timedelta) -> float
Equivalent to ``td.total_seconds()`` (introduced in Python 2.7).
classtornado.web.Application
A collection of request handlers that make up a web application.
methodtornado.web.Application.add_handlers(host_pattern:str, host_handlers:_RuleList) -> None
Appends the given handlers to our handler list.
methodtornado.web.Application.log_request(handler:RequestHandler) -> None
Writes a completed HTTP request to the logs.
classtornado.web.FallbackHandler
A `RequestHandler` that wraps another HTTP server callback.
classtornado.web.GZipContentEncoding
Applies the gzip content encoding to the response.
classtornado.web.HTTPError
An exception that will turn into an HTTP error response.
methodtornado.web.HTTPError.log_message() -> str | None
A backwards compatible way of accessing log_message.
classtornado.web.MissingArgumentError
Exception raised by `RequestHandler.get_argument`.
classtornado.web.RedirectHandler
Redirects the client to the given URL for all GET requests.
classtornado.web.RequestHandler
Base class for HTTP request handlers.
methodtornado.web.RequestHandler.add_header(name:str, value:_HeaderTypes) -> None
Adds the given response header and value.
methodtornado.web.RequestHandler.clear() -> None
Resets all headers and content for this response.
methodtornado.web.RequestHandler.clear_all_cookies(**kwargs:Any) -> None
Attempt to delete all the cookies the user sent with this request.
methodtornado.web.RequestHandler.clear_cookie(name:str, **kwargs:Any) -> None
Deletes the cookie with the given name.
methodtornado.web.RequestHandler.clear_header(name:str) -> None
Clears an outgoing header, undoing a previous `set_header` call.
methodtornado.web.RequestHandler.compute_etag() -> str | None
Computes the etag header to be used for this request.
methodtornado.web.RequestHandler.create_signed_value(name:str, value:str | bytes, version:int | None=None) -> bytes
Signs and timestamps a string so it cannot be forged.
methodtornado.web.RequestHandler.create_template_loader(template_path:str) -> template.BaseLoader
Returns a new template loader for the given path.
methodtornado.web.RequestHandler.current_user() -> Any
The authenticated user for this request.
methodtornado.web.RequestHandler.data_received(chunk:bytes) -> Awaitable[None] | None
Implement this method to handle streamed request data.
methodtornado.web.RequestHandler.decode_argument(value:bytes, name:str | None=None) -> str
Decodes an argument from the request.
methodtornado.web.RequestHandler.detach() -> iostream.IOStream
Take control of the underlying stream.
methodtornado.web.RequestHandler.finish(chunk:str | bytes | dict | None=None) -> 'Future[None]'
Finishes this response, ending the HTTP request.
methodtornado.web.RequestHandler.flush(include_footers:bool=False) -> 'Future[None]'
Flushes the current output buffer to the network.
methodtornado.web.RequestHandler.get_arguments(name:str, strip:bool=True) -> list[str]
Returns a list of the arguments with the given name.
methodtornado.web.RequestHandler.get_body_arguments(name:str, strip:bool=True) -> list[str]
Returns a list of the body arguments with the given name.
methodtornado.web.RequestHandler.get_browser_locale(default:str='en_US') -> tornado.locale.Locale
Determines the user's locale from ``Accept-Language`` header.
methodtornado.web.RequestHandler.get_login_url() -> str
Override to customize the login URL based on the request.
methodtornado.web.RequestHandler.get_query_arguments(name:str, strip:bool=True) -> list[str]
Returns a list of the query arguments with the given name.
methodtornado.web.RequestHandler.get_signed_cookie_key_version(name:str, value:str | None=None) -> int | None
Returns the signing key version of the secure cookie.
methodtornado.web.RequestHandler.get_status() -> int
Returns the status code for our response.
methodtornado.web.RequestHandler.get_template_path() -> str | None
Override to customize template path for each handler.
methodtornado.web.RequestHandler.locale() -> tornado.locale.Locale
The locale for the current session.
methodtornado.web.RequestHandler.on_finish() -> None
Called after the end of a request.
methodtornado.web.RequestHandler.redirect(url:str, permanent:bool=False, status:int | None=None) -> None
Sends a redirect to the given (optionally relative) URL.
methodtornado.web.RequestHandler.render(template_name:str, **kwargs:Any) -> 'Future[None]'
Renders the template with the given arguments as the response.
methodtornado.web.RequestHandler.render_string(template_name:str, **kwargs:Any) -> bytes
Generate the given template with the given arguments.
methodtornado.web.RequestHandler.require_setting(name:str, feature:str='this feature') -> None
Raises an exception if the given app setting is not defined.
methodtornado.web.RequestHandler.reverse_url(name:str, *args:Any) -> str
Alias for `Application.reverse_url`.
methodtornado.web.RequestHandler.send_error(status_code:int=500, **kwargs:Any) -> None
Sends the given HTTP error code to the browser.
methodtornado.web.RequestHandler.set_header(name:str, value:_HeaderTypes) -> None
Sets the given response header name and value.
methodtornado.web.RequestHandler.set_status(status_code:int, reason:str | None=None) -> None
Sets the status code for our response.
methodtornado.web.RequestHandler.write(chunk:str | bytes | dict) -> None
Writes the given chunk to the output buffer.
methodtornado.web.RequestHandler.write_error(status_code:int, **kwargs:Any) -> None
Override to implement custom error pages.
methodtornado.web.RequestHandler.xsrf_token() -> bytes
The XSRF-prevention token for the current user/session.
methodtornado.web.StaticFileHandler.compute_etag() -> str | None
Sets the ``Etag`` header based on static url version.
methodtornado.web.StaticFileHandler.get_absolute_path(root:str, path:str) -> str
Returns the absolute location of ``path`` relative to ``root``.
methodtornado.web.StaticFileHandler.get_cache_time(path:str, modified:datetime.datetime | None, mime_type:str) -> int
Override to customize cache control behavior.
methodtornado.web.StaticFileHandler.get_content_version(abspath:str) -> str
Returns a version string for the resource at the given path.
methodtornado.web.StaticFileHandler.get_version(settings:dict[str, Any], path:str) -> str | None
Generate the version string to be used in static URLs.
methodtornado.web.StaticFileHandler.make_static_url(settings:dict[str, Any], path:str, include_version:bool=True) -> str
Constructs a versioned url for the given path.
methodtornado.web.StaticFileHandler.parse_url_path(url_path:str) -> str
Converts a static URL path into a filesystem path.
methodtornado.web.StaticFileHandler.set_extra_headers(path:str) -> None
For subclass to add extra headers to the response
methodtornado.web.StaticFileHandler.set_headers() -> None
Sets the content and caching headers on the response.
methodtornado.web.StaticFileHandler.validate_absolute_path(root:str, absolute_path:str) -> str | None
Validate and return the absolute path.
classtornado.web.TemplateModule
UIModule that simply renders the given template.
classtornado.web.UIModule
A re-usable, modular UI unit on a page.
methodtornado.web.UIModule.render(*args:Any, **kwargs:Any) -> str | bytes
Override in subclasses to return this module's output.
methodtornado.web.UIModule.render_string(path:str, **kwargs:Any) -> bytes
Renders a template and returns it as a string.
classtornado.websocket.WebSocketClientConnection
WebSocket client connection.
methodtornado.websocket.WebSocketClientConnection.close(code:int | None=None, reason:str | None=None) -> None
Closes the websocket connection.
methodtornado.websocket.WebSocketClientConnection.ping(data:bytes=b'') -> None
Send ping frame to the remote end.
methodtornado.websocket.WebSocketClientConnection.selected_subprotocol() -> str | None
The subprotocol selected by the server.
methodtornado.websocket.WebSocketClientConnection.write_message(message:str | bytes | dict[str, Any], binary:bool=False) -> 'Future[None]'
Sends a message to the WebSocket server.
classtornado.websocket.WebSocketClosedError
Raised by operations on a closed connection.
classtornado.websocket.WebSocketHandler
Subclass this class to create a basic WebSocket handler.
methodtornado.websocket.WebSocketHandler.check_origin(origin:str) -> bool
Override to enable support for allowing alternate origins.
methodtornado.websocket.WebSocketHandler.close(code:int | None=None, reason:str | None=None) -> None
Closes this Web Socket.
methodtornado.websocket.WebSocketHandler.max_message_size() -> int
Maximum allowed message size.
methodtornado.websocket.WebSocketHandler.on_close() -> None
Invoked when the WebSocket is closed.
methodtornado.websocket.WebSocketHandler.on_ping(data:bytes) -> None
Invoked when the a ping frame is received.
methodtornado.websocket.WebSocketHandler.on_pong(data:bytes) -> None
Invoked when the response to a ping frame is received.
methodtornado.websocket.WebSocketHandler.ping(data:str | bytes=b'') -> None
Send ping frame to the remote end.
methodtornado.websocket.WebSocketHandler.ping_interval() -> float | None
The interval for sending websocket pings.
methodtornado.websocket.WebSocketHandler.ping_timeout() -> float | None
Timeout if no pong is received in this many seconds.
methodtornado.websocket.WebSocketHandler.select_subprotocol(subprotocols:list[str]) -> str | None
Override to implement subprotocol negotiation.
methodtornado.websocket.WebSocketHandler.selected_subprotocol() -> str | None
The subprotocol returned by `select_subprotocol`.
methodtornado.websocket.WebSocketHandler.set_nodelay(value:bool) -> None
Set the no-delay flag for this stream.
classtornado.websocket.WebSocketProtocol
Base class for WebSocket protocol versions.
classtornado.websocket.WebSocketProtocol13
Implementation of the WebSocket protocol from RFC 6455.
methodtornado.websocket.WebSocketProtocol13.close(code:int | None=None, reason:str | None=None) -> None
Closes the WebSocket connection.
methodtornado.websocket.WebSocketProtocol13.is_closing() -> bool
Return ``True`` if this connection is closing.
methodtornado.websocket.WebSocketProtocol13.write_ping(data:bytes) -> None
Send ping frame.

About this data

These signatures were extracted from the public source of tornadoweb/tornado using Python's ast module. Argument names, default values, type annotations and return types are taken verbatim from the code. Implementation bodies are never stored. See how it works for details.

Back to all 805 libraries