partition
stringclasses
3 values
func_name
stringlengths
1
134
docstring
stringlengths
1
46.9k
path
stringlengths
4
223
original_string
stringlengths
75
104k
code
stringlengths
75
104k
docstring_tokens
listlengths
1
1.97k
repo
stringlengths
7
55
language
stringclasses
1 value
url
stringlengths
87
315
code_tokens
listlengths
19
28.4k
sha
stringlengths
40
40
train
main
Command-line wrapper to re-run a script whenever its source changes. Scripts may be specified by filename or module name:: python -m tornado.autoreload -m tornado.test.runtests python -m tornado.autoreload tornado/test/runtests.py Running a script with this wrapper is similar to calling `...
tornado/autoreload.py
def main() -> None: """Command-line wrapper to re-run a script whenever its source changes. Scripts may be specified by filename or module name:: python -m tornado.autoreload -m tornado.test.runtests python -m tornado.autoreload tornado/test/runtests.py Running a script with this wrapper ...
def main() -> None: """Command-line wrapper to re-run a script whenever its source changes. Scripts may be specified by filename or module name:: python -m tornado.autoreload -m tornado.test.runtests python -m tornado.autoreload tornado/test/runtests.py Running a script with this wrapper ...
[ "Command", "-", "line", "wrapper", "to", "re", "-", "run", "a", "script", "whenever", "its", "source", "changes", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/autoreload.py#L272-L358
[ "def", "main", "(", ")", "->", "None", ":", "# Remember that we were launched with autoreload as main.", "# The main module can be tricky; set the variables both in our globals", "# (which may be __main__) and the real importable version.", "import", "tornado", ".", "autoreload", "global...
b8b481770bcdb333a69afde5cce7eaa449128326
train
_Connector.split
Partition the ``addrinfo`` list by address family. Returns two lists. The first list contains the first entry from ``addrinfo`` and all others with the same family, and the second list contains all other addresses (normally one list will be AF_INET and the other AF_INET6, although non-...
tornado/tcpclient.py
def split( addrinfo: List[Tuple] ) -> Tuple[ List[Tuple[socket.AddressFamily, Tuple]], List[Tuple[socket.AddressFamily, Tuple]], ]: """Partition the ``addrinfo`` list by address family. Returns two lists. The first list contains the first entry from ``addrinfo``...
def split( addrinfo: List[Tuple] ) -> Tuple[ List[Tuple[socket.AddressFamily, Tuple]], List[Tuple[socket.AddressFamily, Tuple]], ]: """Partition the ``addrinfo`` list by address family. Returns two lists. The first list contains the first entry from ``addrinfo``...
[ "Partition", "the", "addrinfo", "list", "by", "address", "family", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/tcpclient.py#L81-L103
[ "def", "split", "(", "addrinfo", ":", "List", "[", "Tuple", "]", ")", "->", "Tuple", "[", "List", "[", "Tuple", "[", "socket", ".", "AddressFamily", ",", "Tuple", "]", "]", ",", "List", "[", "Tuple", "[", "socket", ".", "AddressFamily", ",", "Tuple",...
b8b481770bcdb333a69afde5cce7eaa449128326
train
TCPClient.connect
Connect to the given host and port. Asynchronously returns an `.IOStream` (or `.SSLIOStream` if ``ssl_options`` is not None). Using the ``source_ip`` kwarg, one can specify the source IP address to use when establishing the connection. In case the user needs to resolve and ...
tornado/tcpclient.py
async def connect( self, host: str, port: int, af: socket.AddressFamily = socket.AF_UNSPEC, ssl_options: Union[Dict[str, Any], ssl.SSLContext] = None, max_buffer_size: int = None, source_ip: str = None, source_port: int = None, timeout: Union[float...
async def connect( self, host: str, port: int, af: socket.AddressFamily = socket.AF_UNSPEC, ssl_options: Union[Dict[str, Any], ssl.SSLContext] = None, max_buffer_size: int = None, source_ip: str = None, source_port: int = None, timeout: Union[float...
[ "Connect", "to", "the", "given", "host", "and", "port", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/tcpclient.py#L222-L296
[ "async", "def", "connect", "(", "self", ",", "host", ":", "str", ",", "port", ":", "int", ",", "af", ":", "socket", ".", "AddressFamily", "=", "socket", ".", "AF_UNSPEC", ",", "ssl_options", ":", "Union", "[", "Dict", "[", "str", ",", "Any", "]", "...
b8b481770bcdb333a69afde5cce7eaa449128326
train
HTTPServer.close_all_connections
Close all open connections and asynchronously wait for them to finish. This method is used in combination with `~.TCPServer.stop` to support clean shutdowns (especially for unittests). Typical usage would call ``stop()`` first to stop accepting new connections, then ``await close_all_co...
tornado/httpserver.py
async def close_all_connections(self) -> None: """Close all open connections and asynchronously wait for them to finish. This method is used in combination with `~.TCPServer.stop` to support clean shutdowns (especially for unittests). Typical usage would call ``stop()`` first to stop ac...
async def close_all_connections(self) -> None: """Close all open connections and asynchronously wait for them to finish. This method is used in combination with `~.TCPServer.stop` to support clean shutdowns (especially for unittests). Typical usage would call ``stop()`` first to stop ac...
[ "Close", "all", "open", "connections", "and", "asynchronously", "wait", "for", "them", "to", "finish", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/httpserver.py#L204-L221
[ "async", "def", "close_all_connections", "(", "self", ")", "->", "None", ":", "while", "self", ".", "_connections", ":", "# Peek at an arbitrary element of the set", "conn", "=", "next", "(", "iter", "(", "self", ".", "_connections", ")", ")", "await", "conn", ...
b8b481770bcdb333a69afde5cce7eaa449128326
train
_HTTPRequestContext._apply_xheaders
Rewrite the ``remote_ip`` and ``protocol`` fields.
tornado/httpserver.py
def _apply_xheaders(self, headers: httputil.HTTPHeaders) -> None: """Rewrite the ``remote_ip`` and ``protocol`` fields.""" # Squid uses X-Forwarded-For, others use X-Real-Ip ip = headers.get("X-Forwarded-For", self.remote_ip) # Skip trusted downstream hosts in X-Forwarded-For list ...
def _apply_xheaders(self, headers: httputil.HTTPHeaders) -> None: """Rewrite the ``remote_ip`` and ``protocol`` fields.""" # Squid uses X-Forwarded-For, others use X-Real-Ip ip = headers.get("X-Forwarded-For", self.remote_ip) # Skip trusted downstream hosts in X-Forwarded-For list ...
[ "Rewrite", "the", "remote_ip", "and", "protocol", "fields", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/httpserver.py#L332-L352
[ "def", "_apply_xheaders", "(", "self", ",", "headers", ":", "httputil", ".", "HTTPHeaders", ")", "->", "None", ":", "# Squid uses X-Forwarded-For, others use X-Real-Ip", "ip", "=", "headers", ".", "get", "(", "\"X-Forwarded-For\"", ",", "self", ".", "remote_ip", "...
b8b481770bcdb333a69afde5cce7eaa449128326
train
_HTTPRequestContext._unapply_xheaders
Undo changes from `_apply_xheaders`. Xheaders are per-request so they should not leak to the next request on the same connection.
tornado/httpserver.py
def _unapply_xheaders(self) -> None: """Undo changes from `_apply_xheaders`. Xheaders are per-request so they should not leak to the next request on the same connection. """ self.remote_ip = self._orig_remote_ip self.protocol = self._orig_protocol
def _unapply_xheaders(self) -> None: """Undo changes from `_apply_xheaders`. Xheaders are per-request so they should not leak to the next request on the same connection. """ self.remote_ip = self._orig_remote_ip self.protocol = self._orig_protocol
[ "Undo", "changes", "from", "_apply_xheaders", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/httpserver.py#L354-L361
[ "def", "_unapply_xheaders", "(", "self", ")", "->", "None", ":", "self", ".", "remote_ip", "=", "self", ".", "_orig_remote_ip", "self", ".", "protocol", "=", "self", ".", "_orig_protocol" ]
b8b481770bcdb333a69afde5cce7eaa449128326
train
set_default_locale
Sets the default locale. The default locale is assumed to be the language used for all strings in the system. The translations loaded from disk are mappings from the default locale to the destination locale. Consequently, you don't need to create a translation file for the default locale.
tornado/locale.py
def set_default_locale(code: str) -> None: """Sets the default locale. The default locale is assumed to be the language used for all strings in the system. The translations loaded from disk are mappings from the default locale to the destination locale. Consequently, you don't need to create a tran...
def set_default_locale(code: str) -> None: """Sets the default locale. The default locale is assumed to be the language used for all strings in the system. The translations loaded from disk are mappings from the default locale to the destination locale. Consequently, you don't need to create a tran...
[ "Sets", "the", "default", "locale", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/locale.py#L77-L88
[ "def", "set_default_locale", "(", "code", ":", "str", ")", "->", "None", ":", "global", "_default_locale", "global", "_supported_locales", "_default_locale", "=", "code", "_supported_locales", "=", "frozenset", "(", "list", "(", "_translations", ".", "keys", "(", ...
b8b481770bcdb333a69afde5cce7eaa449128326
train
load_translations
Loads translations from CSV files in a directory. Translations are strings with optional Python-style named placeholders (e.g., ``My name is %(name)s``) and their associated translations. The directory should have translation files of the form ``LOCALE.csv``, e.g. ``es_GT.csv``. The CSV files should h...
tornado/locale.py
def load_translations(directory: str, encoding: str = None) -> None: """Loads translations from CSV files in a directory. Translations are strings with optional Python-style named placeholders (e.g., ``My name is %(name)s``) and their associated translations. The directory should have translation file...
def load_translations(directory: str, encoding: str = None) -> None: """Loads translations from CSV files in a directory. Translations are strings with optional Python-style named placeholders (e.g., ``My name is %(name)s``) and their associated translations. The directory should have translation file...
[ "Loads", "translations", "from", "CSV", "files", "in", "a", "directory", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/locale.py#L91-L175
[ "def", "load_translations", "(", "directory", ":", "str", ",", "encoding", ":", "str", "=", "None", ")", "->", "None", ":", "global", "_translations", "global", "_supported_locales", "_translations", "=", "{", "}", "for", "path", "in", "os", ".", "listdir", ...
b8b481770bcdb333a69afde5cce7eaa449128326
train
load_gettext_translations
Loads translations from `gettext`'s locale tree Locale tree is similar to system's ``/usr/share/locale``, like:: {directory}/{lang}/LC_MESSAGES/{domain}.mo Three steps are required to have your app translated: 1. Generate POT translation file:: xgettext --language=Python --keyword=_:1,2...
tornado/locale.py
def load_gettext_translations(directory: str, domain: str) -> None: """Loads translations from `gettext`'s locale tree Locale tree is similar to system's ``/usr/share/locale``, like:: {directory}/{lang}/LC_MESSAGES/{domain}.mo Three steps are required to have your app translated: 1. Generate...
def load_gettext_translations(directory: str, domain: str) -> None: """Loads translations from `gettext`'s locale tree Locale tree is similar to system's ``/usr/share/locale``, like:: {directory}/{lang}/LC_MESSAGES/{domain}.mo Three steps are required to have your app translated: 1. Generate...
[ "Loads", "translations", "from", "gettext", "s", "locale", "tree" ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/locale.py#L178-L218
[ "def", "load_gettext_translations", "(", "directory", ":", "str", ",", "domain", ":", "str", ")", "->", "None", ":", "global", "_translations", "global", "_supported_locales", "global", "_use_gettext", "_translations", "=", "{", "}", "for", "lang", "in", "os", ...
b8b481770bcdb333a69afde5cce7eaa449128326
train
Locale.get_closest
Returns the closest match for the given locale code.
tornado/locale.py
def get_closest(cls, *locale_codes: str) -> "Locale": """Returns the closest match for the given locale code.""" for code in locale_codes: if not code: continue code = code.replace("-", "_") parts = code.split("_") if len(parts) > 2: ...
def get_closest(cls, *locale_codes: str) -> "Locale": """Returns the closest match for the given locale code.""" for code in locale_codes: if not code: continue code = code.replace("-", "_") parts = code.split("_") if len(parts) > 2: ...
[ "Returns", "the", "closest", "match", "for", "the", "given", "locale", "code", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/locale.py#L236-L251
[ "def", "get_closest", "(", "cls", ",", "*", "locale_codes", ":", "str", ")", "->", "\"Locale\"", ":", "for", "code", "in", "locale_codes", ":", "if", "not", "code", ":", "continue", "code", "=", "code", ".", "replace", "(", "\"-\"", ",", "\"_\"", ")", ...
b8b481770bcdb333a69afde5cce7eaa449128326
train
Locale.get
Returns the Locale for the given locale code. If it is not supported, we raise an exception.
tornado/locale.py
def get(cls, code: str) -> "Locale": """Returns the Locale for the given locale code. If it is not supported, we raise an exception. """ if code not in cls._cache: assert code in _supported_locales translations = _translations.get(code, None) if trans...
def get(cls, code: str) -> "Locale": """Returns the Locale for the given locale code. If it is not supported, we raise an exception. """ if code not in cls._cache: assert code in _supported_locales translations = _translations.get(code, None) if trans...
[ "Returns", "the", "Locale", "for", "the", "given", "locale", "code", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/locale.py#L254-L269
[ "def", "get", "(", "cls", ",", "code", ":", "str", ")", "->", "\"Locale\"", ":", "if", "code", "not", "in", "cls", ".", "_cache", ":", "assert", "code", "in", "_supported_locales", "translations", "=", "_translations", ".", "get", "(", "code", ",", "No...
b8b481770bcdb333a69afde5cce7eaa449128326
train
Locale.translate
Returns the translation for the given message for this locale. If ``plural_message`` is given, you must also provide ``count``. We return ``plural_message`` when ``count != 1``, and we return the singular form for the given message when ``count == 1``.
tornado/locale.py
def translate( self, message: str, plural_message: str = None, count: int = None ) -> str: """Returns the translation for the given message for this locale. If ``plural_message`` is given, you must also provide ``count``. We return ``plural_message`` when ``count != 1``, and...
def translate( self, message: str, plural_message: str = None, count: int = None ) -> str: """Returns the translation for the given message for this locale. If ``plural_message`` is given, you must also provide ``count``. We return ``plural_message`` when ``count != 1``, and...
[ "Returns", "the", "translation", "for", "the", "given", "message", "for", "this", "locale", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/locale.py#L306-L316
[ "def", "translate", "(", "self", ",", "message", ":", "str", ",", "plural_message", ":", "str", "=", "None", ",", "count", ":", "int", "=", "None", ")", "->", "str", ":", "raise", "NotImplementedError", "(", ")" ]
b8b481770bcdb333a69afde5cce7eaa449128326
train
Locale.format_date
Formats the given date (which should be GMT). By default, we return a relative time (e.g., "2 minutes ago"). You can return an absolute date string with ``relative=False``. You can force a full format date ("July 10, 1980") with ``full_format=True``. This method is primarily i...
tornado/locale.py
def format_date( self, date: Union[int, float, datetime.datetime], gmt_offset: int = 0, relative: bool = True, shorter: bool = False, full_format: bool = False, ) -> str: """Formats the given date (which should be GMT). By default, we return a relativ...
def format_date( self, date: Union[int, float, datetime.datetime], gmt_offset: int = 0, relative: bool = True, shorter: bool = False, full_format: bool = False, ) -> str: """Formats the given date (which should be GMT). By default, we return a relativ...
[ "Formats", "the", "given", "date", "(", "which", "should", "be", "GMT", ")", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/locale.py#L323-L421
[ "def", "format_date", "(", "self", ",", "date", ":", "Union", "[", "int", ",", "float", ",", "datetime", ".", "datetime", "]", ",", "gmt_offset", ":", "int", "=", "0", ",", "relative", ":", "bool", "=", "True", ",", "shorter", ":", "bool", "=", "Fa...
b8b481770bcdb333a69afde5cce7eaa449128326
train
Locale.format_day
Formats the given date as a day of week. Example: "Monday, January 22". You can remove the day of week with ``dow=False``.
tornado/locale.py
def format_day( self, date: datetime.datetime, gmt_offset: int = 0, dow: bool = True ) -> bool: """Formats the given date as a day of week. Example: "Monday, January 22". You can remove the day of week with ``dow=False``. """ local_date = date - datetime.timedelta(mi...
def format_day( self, date: datetime.datetime, gmt_offset: int = 0, dow: bool = True ) -> bool: """Formats the given date as a day of week. Example: "Monday, January 22". You can remove the day of week with ``dow=False``. """ local_date = date - datetime.timedelta(mi...
[ "Formats", "the", "given", "date", "as", "a", "day", "of", "week", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/locale.py#L423-L443
[ "def", "format_day", "(", "self", ",", "date", ":", "datetime", ".", "datetime", ",", "gmt_offset", ":", "int", "=", "0", ",", "dow", ":", "bool", "=", "True", ")", "->", "bool", ":", "local_date", "=", "date", "-", "datetime", ".", "timedelta", "(",...
b8b481770bcdb333a69afde5cce7eaa449128326
train
Locale.list
Returns a comma-separated list for the given list of parts. The format is, e.g., "A, B and C", "A and B" or just "A" for lists of size 1.
tornado/locale.py
def list(self, parts: Any) -> str: """Returns a comma-separated list for the given list of parts. The format is, e.g., "A, B and C", "A and B" or just "A" for lists of size 1. """ _ = self.translate if len(parts) == 0: return "" if len(parts) == 1: ...
def list(self, parts: Any) -> str: """Returns a comma-separated list for the given list of parts. The format is, e.g., "A, B and C", "A and B" or just "A" for lists of size 1. """ _ = self.translate if len(parts) == 0: return "" if len(parts) == 1: ...
[ "Returns", "a", "comma", "-", "separated", "list", "for", "the", "given", "list", "of", "parts", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/locale.py#L445-L460
[ "def", "list", "(", "self", ",", "parts", ":", "Any", ")", "->", "str", ":", "_", "=", "self", ".", "translate", "if", "len", "(", "parts", ")", "==", "0", ":", "return", "\"\"", "if", "len", "(", "parts", ")", "==", "1", ":", "return", "parts"...
b8b481770bcdb333a69afde5cce7eaa449128326
train
Locale.friendly_number
Returns a comma-separated number for the given integer.
tornado/locale.py
def friendly_number(self, value: int) -> str: """Returns a comma-separated number for the given integer.""" if self.code not in ("en", "en_US"): return str(value) s = str(value) parts = [] while s: parts.append(s[-3:]) s = s[:-3] return...
def friendly_number(self, value: int) -> str: """Returns a comma-separated number for the given integer.""" if self.code not in ("en", "en_US"): return str(value) s = str(value) parts = [] while s: parts.append(s[-3:]) s = s[:-3] return...
[ "Returns", "a", "comma", "-", "separated", "number", "for", "the", "given", "integer", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/locale.py#L462-L471
[ "def", "friendly_number", "(", "self", ",", "value", ":", "int", ")", "->", "str", ":", "if", "self", ".", "code", "not", "in", "(", "\"en\"", ",", "\"en_US\"", ")", ":", "return", "str", "(", "value", ")", "s", "=", "str", "(", "value", ")", "pa...
b8b481770bcdb333a69afde5cce7eaa449128326
train
GettextLocale.pgettext
Allows to set context for translation, accepts plural forms. Usage example:: pgettext("law", "right") pgettext("good", "right") Plural message example:: pgettext("organization", "club", "clubs", len(clubs)) pgettext("stick", "club", "clubs", len(clubs)...
tornado/locale.py
def pgettext( self, context: str, message: str, plural_message: str = None, count: int = None ) -> str: """Allows to set context for translation, accepts plural forms. Usage example:: pgettext("law", "right") pgettext("good", "right") Plural message example...
def pgettext( self, context: str, message: str, plural_message: str = None, count: int = None ) -> str: """Allows to set context for translation, accepts plural forms. Usage example:: pgettext("law", "right") pgettext("good", "right") Plural message example...
[ "Allows", "to", "set", "context", "for", "translation", "accepts", "plural", "forms", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/locale.py#L522-L562
[ "def", "pgettext", "(", "self", ",", "context", ":", "str", ",", "message", ":", "str", ",", "plural_message", ":", "str", "=", "None", ",", "count", ":", "int", "=", "None", ")", "->", "str", ":", "if", "plural_message", "is", "not", "None", ":", ...
b8b481770bcdb333a69afde5cce7eaa449128326
train
_unquote_or_none
None-safe wrapper around url_unescape to handle unmatched optional groups correctly. Note that args are passed as bytes so the handler can decide what encoding to use.
tornado/routing.py
def _unquote_or_none(s: Optional[str]) -> Optional[bytes]: # noqa: F811 """None-safe wrapper around url_unescape to handle unmatched optional groups correctly. Note that args are passed as bytes so the handler can decide what encoding to use. """ if s is None: return s return url_u...
def _unquote_or_none(s: Optional[str]) -> Optional[bytes]: # noqa: F811 """None-safe wrapper around url_unescape to handle unmatched optional groups correctly. Note that args are passed as bytes so the handler can decide what encoding to use. """ if s is None: return s return url_u...
[ "None", "-", "safe", "wrapper", "around", "url_unescape", "to", "handle", "unmatched", "optional", "groups", "correctly", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/routing.py#L702-L711
[ "def", "_unquote_or_none", "(", "s", ":", "Optional", "[", "str", "]", ")", "->", "Optional", "[", "bytes", "]", ":", "# noqa: F811", "if", "s", "is", "None", ":", "return", "s", "return", "url_unescape", "(", "s", ",", "encoding", "=", "None", ",", ...
b8b481770bcdb333a69afde5cce7eaa449128326
train
Router.find_handler
Must be implemented to return an appropriate instance of `~.httputil.HTTPMessageDelegate` that can serve the request. Routing implementations may pass additional kwargs to extend the routing logic. :arg httputil.HTTPServerRequest request: current HTTP request. :arg kwargs: additional ke...
tornado/routing.py
def find_handler( self, request: httputil.HTTPServerRequest, **kwargs: Any ) -> Optional[httputil.HTTPMessageDelegate]: """Must be implemented to return an appropriate instance of `~.httputil.HTTPMessageDelegate` that can serve the request. Routing implementations may pass additional...
def find_handler( self, request: httputil.HTTPServerRequest, **kwargs: Any ) -> Optional[httputil.HTTPMessageDelegate]: """Must be implemented to return an appropriate instance of `~.httputil.HTTPMessageDelegate` that can serve the request. Routing implementations may pass additional...
[ "Must", "be", "implemented", "to", "return", "an", "appropriate", "instance", "of", "~", ".", "httputil", ".", "HTTPMessageDelegate", "that", "can", "serve", "the", "request", ".", "Routing", "implementations", "may", "pass", "additional", "kwargs", "to", "exten...
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/routing.py#L193-L205
[ "def", "find_handler", "(", "self", ",", "request", ":", "httputil", ".", "HTTPServerRequest", ",", "*", "*", "kwargs", ":", "Any", ")", "->", "Optional", "[", "httputil", ".", "HTTPMessageDelegate", "]", ":", "raise", "NotImplementedError", "(", ")" ]
b8b481770bcdb333a69afde5cce7eaa449128326
train
RuleRouter.add_rules
Appends new rules to the router. :arg rules: a list of Rule instances (or tuples of arguments, which are passed to Rule constructor).
tornado/routing.py
def add_rules(self, rules: _RuleList) -> None: """Appends new rules to the router. :arg rules: a list of Rule instances (or tuples of arguments, which are passed to Rule constructor). """ for rule in rules: if isinstance(rule, (tuple, list)): asse...
def add_rules(self, rules: _RuleList) -> None: """Appends new rules to the router. :arg rules: a list of Rule instances (or tuples of arguments, which are passed to Rule constructor). """ for rule in rules: if isinstance(rule, (tuple, list)): asse...
[ "Appends", "new", "rules", "to", "the", "router", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/routing.py#L334-L348
[ "def", "add_rules", "(", "self", ",", "rules", ":", "_RuleList", ")", "->", "None", ":", "for", "rule", "in", "rules", ":", "if", "isinstance", "(", "rule", ",", "(", "tuple", ",", "list", ")", ")", ":", "assert", "len", "(", "rule", ")", "in", "...
b8b481770bcdb333a69afde5cce7eaa449128326
train
RuleRouter.get_target_delegate
Returns an instance of `~.httputil.HTTPMessageDelegate` for a Rule's target. This method is called by `~.find_handler` and can be extended to provide additional target types. :arg target: a Rule's target. :arg httputil.HTTPServerRequest request: current request. :arg target_para...
tornado/routing.py
def get_target_delegate( self, target: Any, request: httputil.HTTPServerRequest, **target_params: Any ) -> Optional[httputil.HTTPMessageDelegate]: """Returns an instance of `~.httputil.HTTPMessageDelegate` for a Rule's target. This method is called by `~.find_handler` and can be exte...
def get_target_delegate( self, target: Any, request: httputil.HTTPServerRequest, **target_params: Any ) -> Optional[httputil.HTTPMessageDelegate]: """Returns an instance of `~.httputil.HTTPMessageDelegate` for a Rule's target. This method is called by `~.find_handler` and can be exte...
[ "Returns", "an", "instance", "of", "~", ".", "httputil", ".", "HTTPMessageDelegate", "for", "a", "Rule", "s", "target", ".", "This", "method", "is", "called", "by", "~", ".", "find_handler", "and", "can", "be", "extended", "to", "provide", "additional", "t...
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/routing.py#L376-L401
[ "def", "get_target_delegate", "(", "self", ",", "target", ":", "Any", ",", "request", ":", "httputil", ".", "HTTPServerRequest", ",", "*", "*", "target_params", ":", "Any", ")", "->", "Optional", "[", "httputil", ".", "HTTPMessageDelegate", "]", ":", "if", ...
b8b481770bcdb333a69afde5cce7eaa449128326
train
Matcher.match
Matches current instance against the request. :arg httputil.HTTPServerRequest request: current HTTP request :returns: a dict of parameters to be passed to the target handler (for example, ``handler_kwargs``, ``path_args``, ``path_kwargs`` can be passed for proper `~.web.RequestH...
tornado/routing.py
def match(self, request: httputil.HTTPServerRequest) -> Optional[Dict[str, Any]]: """Matches current instance against the request. :arg httputil.HTTPServerRequest request: current HTTP request :returns: a dict of parameters to be passed to the target handler (for example, ``handler_...
def match(self, request: httputil.HTTPServerRequest) -> Optional[Dict[str, Any]]: """Matches current instance against the request. :arg httputil.HTTPServerRequest request: current HTTP request :returns: a dict of parameters to be passed to the target handler (for example, ``handler_...
[ "Matches", "current", "instance", "against", "the", "request", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/routing.py#L493-L503
[ "def", "match", "(", "self", ",", "request", ":", "httputil", ".", "HTTPServerRequest", ")", "->", "Optional", "[", "Dict", "[", "str", ",", "Any", "]", "]", ":", "raise", "NotImplementedError", "(", ")" ]
b8b481770bcdb333a69afde5cce7eaa449128326
train
PathMatches._find_groups
Returns a tuple (reverse string, group count) for a url. For example: Given the url pattern /([0-9]{4})/([a-z-]+)/, this method would return ('/%s/%s/', 2).
tornado/routing.py
def _find_groups(self) -> Tuple[Optional[str], Optional[int]]: """Returns a tuple (reverse string, group count) for a url. For example: Given the url pattern /([0-9]{4})/([a-z-]+)/, this method would return ('/%s/%s/', 2). """ pattern = self.regex.pattern if pattern.star...
def _find_groups(self) -> Tuple[Optional[str], Optional[int]]: """Returns a tuple (reverse string, group count) for a url. For example: Given the url pattern /([0-9]{4})/([a-z-]+)/, this method would return ('/%s/%s/', 2). """ pattern = self.regex.pattern if pattern.star...
[ "Returns", "a", "tuple", "(", "reverse", "string", "group", "count", ")", "for", "a", "url", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/routing.py#L608-L640
[ "def", "_find_groups", "(", "self", ")", "->", "Tuple", "[", "Optional", "[", "str", "]", ",", "Optional", "[", "int", "]", "]", ":", "pattern", "=", "self", ".", "regex", ".", "pattern", "if", "pattern", ".", "startswith", "(", "\"^\"", ")", ":", ...
b8b481770bcdb333a69afde5cce7eaa449128326
train
get_links_from_url
Download the page at `url` and parse it for links. Returned links have had the fragment after `#` removed, and have been made absolute so, e.g. the URL 'gen.html#tornado.gen.coroutine' becomes 'http://www.tornadoweb.org/en/stable/gen.html'.
demos/webspider/webspider.py
async def get_links_from_url(url): """Download the page at `url` and parse it for links. Returned links have had the fragment after `#` removed, and have been made absolute so, e.g. the URL 'gen.html#tornado.gen.coroutine' becomes 'http://www.tornadoweb.org/en/stable/gen.html'. """ response = a...
async def get_links_from_url(url): """Download the page at `url` and parse it for links. Returned links have had the fragment after `#` removed, and have been made absolute so, e.g. the URL 'gen.html#tornado.gen.coroutine' becomes 'http://www.tornadoweb.org/en/stable/gen.html'. """ response = a...
[ "Download", "the", "page", "at", "url", "and", "parse", "it", "for", "links", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/demos/webspider/webspider.py#L15-L26
[ "async", "def", "get_links_from_url", "(", "url", ")", ":", "response", "=", "await", "httpclient", ".", "AsyncHTTPClient", "(", ")", ".", "fetch", "(", "url", ")", "print", "(", "\"fetched %s\"", "%", "url", ")", "html", "=", "response", ".", "body", "....
b8b481770bcdb333a69afde5cce7eaa449128326
train
MessageBuffer.get_messages_since
Returns a list of messages newer than the given cursor. ``cursor`` should be the ``id`` of the last message received.
demos/chat/chatdemo.py
def get_messages_since(self, cursor): """Returns a list of messages newer than the given cursor. ``cursor`` should be the ``id`` of the last message received. """ results = [] for msg in reversed(self.cache): if msg["id"] == cursor: break ...
def get_messages_since(self, cursor): """Returns a list of messages newer than the given cursor. ``cursor`` should be the ``id`` of the last message received. """ results = [] for msg in reversed(self.cache): if msg["id"] == cursor: break ...
[ "Returns", "a", "list", "of", "messages", "newer", "than", "the", "given", "cursor", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/demos/chat/chatdemo.py#L38-L49
[ "def", "get_messages_since", "(", "self", ",", "cursor", ")", ":", "results", "=", "[", "]", "for", "msg", "in", "reversed", "(", "self", ".", "cache", ")", ":", "if", "msg", "[", "\"id\"", "]", "==", "cursor", ":", "break", "results", ".", "append",...
b8b481770bcdb333a69afde5cce7eaa449128326
train
import_object
Imports an object by name. ``import_object('x')`` is equivalent to ``import x``. ``import_object('x.y.z')`` is equivalent to ``from x.y import z``. >>> import tornado.escape >>> import_object('tornado.escape') is tornado.escape True >>> import_object('tornado.escape.utf8') is tornado.escape.ut...
tornado/util.py
def import_object(name: str) -> Any: """Imports an object by name. ``import_object('x')`` is equivalent to ``import x``. ``import_object('x.y.z')`` is equivalent to ``from x.y import z``. >>> import tornado.escape >>> import_object('tornado.escape') is tornado.escape True >>> import_object...
def import_object(name: str) -> Any: """Imports an object by name. ``import_object('x')`` is equivalent to ``import x``. ``import_object('x.y.z')`` is equivalent to ``from x.y import z``. >>> import tornado.escape >>> import_object('tornado.escape') is tornado.escape True >>> import_object...
[ "Imports", "an", "object", "by", "name", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/util.py#L131-L157
[ "def", "import_object", "(", "name", ":", "str", ")", "->", "Any", ":", "if", "name", ".", "count", "(", "\".\"", ")", "==", "0", ":", "return", "__import__", "(", "name", ")", "parts", "=", "name", ".", "split", "(", "\".\"", ")", "obj", "=", "_...
b8b481770bcdb333a69afde5cce7eaa449128326
train
errno_from_exception
Provides the errno from an Exception object. There are cases that the errno attribute was not set so we pull the errno out of the args but if someone instantiates an Exception without any args you will get a tuple error. So this function abstracts all that behavior to give you a safe way to get the ...
tornado/util.py
def errno_from_exception(e: BaseException) -> Optional[int]: """Provides the errno from an Exception object. There are cases that the errno attribute was not set so we pull the errno out of the args but if someone instantiates an Exception without any args you will get a tuple error. So this function ...
def errno_from_exception(e: BaseException) -> Optional[int]: """Provides the errno from an Exception object. There are cases that the errno attribute was not set so we pull the errno out of the args but if someone instantiates an Exception without any args you will get a tuple error. So this function ...
[ "Provides", "the", "errno", "from", "an", "Exception", "object", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/util.py#L188-L203
[ "def", "errno_from_exception", "(", "e", ":", "BaseException", ")", "->", "Optional", "[", "int", "]", ":", "if", "hasattr", "(", "e", ",", "\"errno\"", ")", ":", "return", "e", ".", "errno", "# type: ignore", "elif", "e", ".", "args", ":", "return", "...
b8b481770bcdb333a69afde5cce7eaa449128326
train
_websocket_mask_python
Websocket masking function. `mask` is a `bytes` object of length 4; `data` is a `bytes` object of any length. Returns a `bytes` object of the same length as `data` with the mask applied as specified in section 5.3 of RFC 6455. This pure-python implementation may be replaced by an optimized version whe...
tornado/util.py
def _websocket_mask_python(mask: bytes, data: bytes) -> bytes: """Websocket masking function. `mask` is a `bytes` object of length 4; `data` is a `bytes` object of any length. Returns a `bytes` object of the same length as `data` with the mask applied as specified in section 5.3 of RFC 6455. This ...
def _websocket_mask_python(mask: bytes, data: bytes) -> bytes: """Websocket masking function. `mask` is a `bytes` object of length 4; `data` is a `bytes` object of any length. Returns a `bytes` object of the same length as `data` with the mask applied as specified in section 5.3 of RFC 6455. This ...
[ "Websocket", "masking", "function", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/util.py#L439-L452
[ "def", "_websocket_mask_python", "(", "mask", ":", "bytes", ",", "data", ":", "bytes", ")", "->", "bytes", ":", "mask_arr", "=", "array", ".", "array", "(", "\"B\"", ",", "mask", ")", "unmasked_arr", "=", "array", ".", "array", "(", "\"B\"", ",", "data...
b8b481770bcdb333a69afde5cce7eaa449128326
train
GzipDecompressor.decompress
Decompress a chunk, returning newly-available data. Some data may be buffered for later processing; `flush` must be called when there is no more input data to ensure that all data was processed. If ``max_length`` is given, some input data may be left over in ``unconsumed_tail``...
tornado/util.py
def decompress(self, value: bytes, max_length: int = 0) -> bytes: """Decompress a chunk, returning newly-available data. Some data may be buffered for later processing; `flush` must be called when there is no more input data to ensure that all data was processed. If ``max_lengt...
def decompress(self, value: bytes, max_length: int = 0) -> bytes: """Decompress a chunk, returning newly-available data. Some data may be buffered for later processing; `flush` must be called when there is no more input data to ensure that all data was processed. If ``max_lengt...
[ "Decompress", "a", "chunk", "returning", "newly", "-", "available", "data", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/util.py#L103-L114
[ "def", "decompress", "(", "self", ",", "value", ":", "bytes", ",", "max_length", ":", "int", "=", "0", ")", "->", "bytes", ":", "return", "self", ".", "decompressobj", ".", "decompress", "(", "value", ",", "max_length", ")" ]
b8b481770bcdb333a69afde5cce7eaa449128326
train
Configurable.configure
Sets the class to use when the base class is instantiated. Keyword arguments will be saved and added to the arguments passed to the constructor. This can be used to set global defaults for some parameters.
tornado/util.py
def configure(cls, impl, **kwargs): # type: (Union[None, str, Type[Configurable]], Any) -> None """Sets the class to use when the base class is instantiated. Keyword arguments will be saved and added to the arguments passed to the constructor. This can be used to set global defaults fo...
def configure(cls, impl, **kwargs): # type: (Union[None, str, Type[Configurable]], Any) -> None """Sets the class to use when the base class is instantiated. Keyword arguments will be saved and added to the arguments passed to the constructor. This can be used to set global defaults fo...
[ "Sets", "the", "class", "to", "use", "when", "the", "base", "class", "is", "instantiated", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/util.py#L320-L334
[ "def", "configure", "(", "cls", ",", "impl", ",", "*", "*", "kwargs", ")", ":", "# type: (Union[None, str, Type[Configurable]], Any) -> None", "base", "=", "cls", ".", "configurable_base", "(", ")", "if", "isinstance", "(", "impl", ",", "str", ")", ":", "impl"...
b8b481770bcdb333a69afde5cce7eaa449128326
train
ArgReplacer.get_old_value
Returns the old value of the named argument without replacing it. Returns ``default`` if the argument is not present.
tornado/util.py
def get_old_value( self, args: Sequence[Any], kwargs: Dict[str, Any], default: Any = None ) -> Any: """Returns the old value of the named argument without replacing it. Returns ``default`` if the argument is not present. """ if self.arg_pos is not None and len(args) > self.a...
def get_old_value( self, args: Sequence[Any], kwargs: Dict[str, Any], default: Any = None ) -> Any: """Returns the old value of the named argument without replacing it. Returns ``default`` if the argument is not present. """ if self.arg_pos is not None and len(args) > self.a...
[ "Returns", "the", "old", "value", "of", "the", "named", "argument", "without", "replacing", "it", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/util.py#L397-L407
[ "def", "get_old_value", "(", "self", ",", "args", ":", "Sequence", "[", "Any", "]", ",", "kwargs", ":", "Dict", "[", "str", ",", "Any", "]", ",", "default", ":", "Any", "=", "None", ")", "->", "Any", ":", "if", "self", ".", "arg_pos", "is", "not"...
b8b481770bcdb333a69afde5cce7eaa449128326
train
ArgReplacer.replace
Replace the named argument in ``args, kwargs`` with ``new_value``. Returns ``(old_value, args, kwargs)``. The returned ``args`` and ``kwargs`` objects may not be the same as the input objects, or the input objects may be mutated. If the named argument was not found, ``new_value`` will...
tornado/util.py
def replace( self, 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``. Returns ``(old_value, args, kwargs)``. The returned ``args`` and ``kwargs`` objects m...
def replace( self, 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``. Returns ``(old_value, args, kwargs)``. The returned ``args`` and ``kwargs`` objects m...
[ "Replace", "the", "named", "argument", "in", "args", "kwargs", "with", "new_value", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/util.py#L409-L430
[ "def", "replace", "(", "self", ",", "new_value", ":", "Any", ",", "args", ":", "Sequence", "[", "Any", "]", ",", "kwargs", ":", "Dict", "[", "str", ",", "Any", "]", ")", "->", "Tuple", "[", "Any", ",", "Sequence", "[", "Any", "]", ",", "Dict", ...
b8b481770bcdb333a69afde5cce7eaa449128326
train
WSGIContainer.environ
Converts a `tornado.httputil.HTTPServerRequest` to a WSGI environment.
tornado/wsgi.py
def environ(request: httputil.HTTPServerRequest) -> Dict[Text, Any]: """Converts a `tornado.httputil.HTTPServerRequest` to a WSGI environment. """ hostport = request.host.split(":") if len(hostport) == 2: host = hostport[0] port = int(hostport[1]) else: ...
def environ(request: httputil.HTTPServerRequest) -> Dict[Text, Any]: """Converts a `tornado.httputil.HTTPServerRequest` to a WSGI environment. """ hostport = request.host.split(":") if len(hostport) == 2: host = hostport[0] port = int(hostport[1]) else: ...
[ "Converts", "a", "tornado", ".", "httputil", ".", "HTTPServerRequest", "to", "a", "WSGI", "environment", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/wsgi.py#L148-L183
[ "def", "environ", "(", "request", ":", "httputil", ".", "HTTPServerRequest", ")", "->", "Dict", "[", "Text", ",", "Any", "]", ":", "hostport", "=", "request", ".", "host", ".", "split", "(", "\":\"", ")", "if", "len", "(", "hostport", ")", "==", "2",...
b8b481770bcdb333a69afde5cce7eaa449128326
train
stream_request_body
Apply to `RequestHandler` subclasses to enable streaming body support. This decorator implies the following changes: * `.HTTPServerRequest.body` is undefined, and body arguments will not be included in `RequestHandler.get_argument`. * `RequestHandler.prepare` is called when the request headers have ...
tornado/web.py
def stream_request_body(cls: Type[RequestHandler]) -> Type[RequestHandler]: """Apply to `RequestHandler` subclasses to enable streaming body support. This decorator implies the following changes: * `.HTTPServerRequest.body` is undefined, and body arguments will not be included in `RequestHandler.get...
def stream_request_body(cls: Type[RequestHandler]) -> Type[RequestHandler]: """Apply to `RequestHandler` subclasses to enable streaming body support. This decorator implies the following changes: * `.HTTPServerRequest.body` is undefined, and body arguments will not be included in `RequestHandler.get...
[ "Apply", "to", "RequestHandler", "subclasses", "to", "enable", "streaming", "body", "support", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/web.py#L1824-L1848
[ "def", "stream_request_body", "(", "cls", ":", "Type", "[", "RequestHandler", "]", ")", "->", "Type", "[", "RequestHandler", "]", ":", "# noqa: E501", "if", "not", "issubclass", "(", "cls", ",", "RequestHandler", ")", ":", "raise", "TypeError", "(", "\"expec...
b8b481770bcdb333a69afde5cce7eaa449128326
train
removeslash
Use this decorator to remove trailing slashes from the request path. For example, a request to ``/foo/`` would redirect to ``/foo`` with this decorator. Your request handler mapping should use a regular expression like ``r'/foo/*'`` in conjunction with using the decorator.
tornado/web.py
def removeslash( method: Callable[..., Optional[Awaitable[None]]] ) -> Callable[..., Optional[Awaitable[None]]]: """Use this decorator to remove trailing slashes from the request path. For example, a request to ``/foo/`` would redirect to ``/foo`` with this decorator. Your request handler mapping shoul...
def removeslash( method: Callable[..., Optional[Awaitable[None]]] ) -> Callable[..., Optional[Awaitable[None]]]: """Use this decorator to remove trailing slashes from the request path. For example, a request to ``/foo/`` would redirect to ``/foo`` with this decorator. Your request handler mapping shoul...
[ "Use", "this", "decorator", "to", "remove", "trailing", "slashes", "from", "the", "request", "path", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/web.py#L1857-L1883
[ "def", "removeslash", "(", "method", ":", "Callable", "[", "...", ",", "Optional", "[", "Awaitable", "[", "None", "]", "]", "]", ")", "->", "Callable", "[", "...", ",", "Optional", "[", "Awaitable", "[", "None", "]", "]", "]", ":", "@", "functools", ...
b8b481770bcdb333a69afde5cce7eaa449128326
train
authenticated
Decorate methods with this to require that the user be logged in. If the user is not logged in, they will be redirected to the configured `login url <RequestHandler.get_login_url>`. If you configure a login url with a query parameter, Tornado will assume you know what you're doing and use it as-is. I...
tornado/web.py
def authenticated( method: Callable[..., Optional[Awaitable[None]]] ) -> Callable[..., Optional[Awaitable[None]]]: """Decorate methods with this to require that the user be logged in. If the user is not logged in, they will be redirected to the configured `login url <RequestHandler.get_login_url>`. ...
def authenticated( method: Callable[..., Optional[Awaitable[None]]] ) -> Callable[..., Optional[Awaitable[None]]]: """Decorate methods with this to require that the user be logged in. If the user is not logged in, they will be redirected to the configured `login url <RequestHandler.get_login_url>`. ...
[ "Decorate", "methods", "with", "this", "to", "require", "that", "the", "user", "be", "logged", "in", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/web.py#L3142-L3176
[ "def", "authenticated", "(", "method", ":", "Callable", "[", "...", ",", "Optional", "[", "Awaitable", "[", "None", "]", "]", "]", ")", "->", "Callable", "[", "...", ",", "Optional", "[", "Awaitable", "[", "None", "]", "]", "]", ":", "@", "functools"...
b8b481770bcdb333a69afde5cce7eaa449128326
train
RequestHandler.on_connection_close
Called in async handlers if the client closed the connection. Override this to clean up resources associated with long-lived connections. Note that this method is called only if the connection was closed during asynchronous processing; if you need to do cleanup after every request over...
tornado/web.py
def on_connection_close(self) -> None: """Called in async handlers if the client closed the connection. Override this to clean up resources associated with long-lived connections. Note that this method is called only if the connection was closed during asynchronous processing; if you ...
def on_connection_close(self) -> None: """Called in async handlers if the client closed the connection. Override this to clean up resources associated with long-lived connections. Note that this method is called only if the connection was closed during asynchronous processing; if you ...
[ "Called", "in", "async", "handlers", "if", "the", "client", "closed", "the", "connection", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/web.py#L300-L317
[ "def", "on_connection_close", "(", "self", ")", "->", "None", ":", "if", "_has_stream_request_body", "(", "self", ".", "__class__", ")", ":", "if", "not", "self", ".", "request", ".", "_body_future", ".", "done", "(", ")", ":", "self", ".", "request", "....
b8b481770bcdb333a69afde5cce7eaa449128326
train
RequestHandler.clear
Resets all headers and content for this response.
tornado/web.py
def clear(self) -> None: """Resets all headers and content for this response.""" self._headers = httputil.HTTPHeaders( { "Server": "TornadoServer/%s" % tornado.version, "Content-Type": "text/html; charset=UTF-8", "Date": httputil.format_timesta...
def clear(self) -> None: """Resets all headers and content for this response.""" self._headers = httputil.HTTPHeaders( { "Server": "TornadoServer/%s" % tornado.version, "Content-Type": "text/html; charset=UTF-8", "Date": httputil.format_timesta...
[ "Resets", "all", "headers", "and", "content", "for", "this", "response", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/web.py#L319-L331
[ "def", "clear", "(", "self", ")", "->", "None", ":", "self", ".", "_headers", "=", "httputil", ".", "HTTPHeaders", "(", "{", "\"Server\"", ":", "\"TornadoServer/%s\"", "%", "tornado", ".", "version", ",", "\"Content-Type\"", ":", "\"text/html; charset=UTF-8\"", ...
b8b481770bcdb333a69afde5cce7eaa449128326
train
RequestHandler.set_status
Sets the status code for our response. :arg int status_code: Response status code. :arg str reason: Human-readable reason phrase describing the status code. If ``None``, it will be filled in from `http.client.responses` or "Unknown". .. versionchanged:: 5.0 ...
tornado/web.py
def set_status(self, status_code: int, reason: str = None) -> None: """Sets the status code for our response. :arg int status_code: Response status code. :arg str reason: Human-readable reason phrase describing the status code. If ``None``, it will be filled in from `htt...
def set_status(self, status_code: int, reason: str = None) -> None: """Sets the status code for our response. :arg int status_code: Response status code. :arg str reason: Human-readable reason phrase describing the status code. If ``None``, it will be filled in from `htt...
[ "Sets", "the", "status", "code", "for", "our", "response", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/web.py#L343-L360
[ "def", "set_status", "(", "self", ",", "status_code", ":", "int", ",", "reason", ":", "str", "=", "None", ")", "->", "None", ":", "self", ".", "_status_code", "=", "status_code", "if", "reason", "is", "not", "None", ":", "self", ".", "_reason", "=", ...
b8b481770bcdb333a69afde5cce7eaa449128326
train
RequestHandler.set_header
Sets the given response header name and value. All header values are converted to strings (`datetime` objects are formatted according to the HTTP specification for the ``Date`` header).
tornado/web.py
def set_header(self, name: str, value: _HeaderTypes) -> None: """Sets the given response header name and value. All header values are converted to strings (`datetime` objects are formatted according to the HTTP specification for the ``Date`` header). """ self._headers[n...
def set_header(self, name: str, value: _HeaderTypes) -> None: """Sets the given response header name and value. All header values are converted to strings (`datetime` objects are formatted according to the HTTP specification for the ``Date`` header). """ self._headers[n...
[ "Sets", "the", "given", "response", "header", "name", "and", "value", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/web.py#L366-L374
[ "def", "set_header", "(", "self", ",", "name", ":", "str", ",", "value", ":", "_HeaderTypes", ")", "->", "None", ":", "self", ".", "_headers", "[", "name", "]", "=", "self", ".", "_convert_header_value", "(", "value", ")" ]
b8b481770bcdb333a69afde5cce7eaa449128326
train
RequestHandler.add_header
Adds the given response header and value. Unlike `set_header`, `add_header` may be called multiple times to return multiple values for the same header.
tornado/web.py
def add_header(self, name: str, value: _HeaderTypes) -> None: """Adds the given response header and value. Unlike `set_header`, `add_header` may be called multiple times to return multiple values for the same header. """ self._headers.add(name, self._convert_header_value(value))
def add_header(self, name: str, value: _HeaderTypes) -> None: """Adds the given response header and value. Unlike `set_header`, `add_header` may be called multiple times to return multiple values for the same header. """ self._headers.add(name, self._convert_header_value(value))
[ "Adds", "the", "given", "response", "header", "and", "value", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/web.py#L376-L382
[ "def", "add_header", "(", "self", ",", "name", ":", "str", ",", "value", ":", "_HeaderTypes", ")", "->", "None", ":", "self", ".", "_headers", ".", "add", "(", "name", ",", "self", ".", "_convert_header_value", "(", "value", ")", ")" ]
b8b481770bcdb333a69afde5cce7eaa449128326
train
RequestHandler.clear_header
Clears an outgoing header, undoing a previous `set_header` call. Note that this method does not apply to multi-valued headers set by `add_header`.
tornado/web.py
def clear_header(self, name: str) -> None: """Clears an outgoing header, undoing a previous `set_header` call. Note that this method does not apply to multi-valued headers set by `add_header`. """ if name in self._headers: del self._headers[name]
def clear_header(self, name: str) -> None: """Clears an outgoing header, undoing a previous `set_header` call. Note that this method does not apply to multi-valued headers set by `add_header`. """ if name in self._headers: del self._headers[name]
[ "Clears", "an", "outgoing", "header", "undoing", "a", "previous", "set_header", "call", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/web.py#L384-L391
[ "def", "clear_header", "(", "self", ",", "name", ":", "str", ")", "->", "None", ":", "if", "name", "in", "self", ".", "_headers", ":", "del", "self", ".", "_headers", "[", "name", "]" ]
b8b481770bcdb333a69afde5cce7eaa449128326
train
RequestHandler.get_argument
Returns the value of the argument with the given name. If default is not provided, the argument is considered to be required, and we raise a `MissingArgumentError` if it is missing. If the argument appears in the request more than once, we return the last value. This method se...
tornado/web.py
def get_argument( # noqa: F811 self, name: str, default: Union[None, str, _ArgDefaultMarker] = _ARG_DEFAULT, strip: bool = True, ) -> Optional[str]: """Returns the value of the argument with the given name. If default is not provided, the argument is considered to b...
def get_argument( # noqa: F811 self, name: str, default: Union[None, str, _ArgDefaultMarker] = _ARG_DEFAULT, strip: bool = True, ) -> Optional[str]: """Returns the value of the argument with the given name. If default is not provided, the argument is considered to b...
[ "Returns", "the", "value", "of", "the", "argument", "with", "the", "given", "name", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/web.py#L439-L455
[ "def", "get_argument", "(", "# noqa: F811", "self", ",", "name", ":", "str", ",", "default", ":", "Union", "[", "None", ",", "str", ",", "_ArgDefaultMarker", "]", "=", "_ARG_DEFAULT", ",", "strip", ":", "bool", "=", "True", ",", ")", "->", "Optional", ...
b8b481770bcdb333a69afde5cce7eaa449128326
train
RequestHandler.get_arguments
Returns a list of the arguments with the given name. If the argument is not present, returns an empty list. This method searches both the query and body arguments.
tornado/web.py
def get_arguments(self, name: str, strip: bool = True) -> List[str]: """Returns a list of the arguments with the given name. If the argument is not present, returns an empty list. This method searches both the query and body arguments. """ # Make sure `get_arguments` isn't acc...
def get_arguments(self, name: str, strip: bool = True) -> List[str]: """Returns a list of the arguments with the given name. If the argument is not present, returns an empty list. This method searches both the query and body arguments. """ # Make sure `get_arguments` isn't acc...
[ "Returns", "a", "list", "of", "the", "arguments", "with", "the", "given", "name", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/web.py#L457-L470
[ "def", "get_arguments", "(", "self", ",", "name", ":", "str", ",", "strip", ":", "bool", "=", "True", ")", "->", "List", "[", "str", "]", ":", "# Make sure `get_arguments` isn't accidentally being called with a", "# positional argument that's assumed to be a default (like...
b8b481770bcdb333a69afde5cce7eaa449128326
train
RequestHandler.get_body_argument
Returns the value of the argument with the given name from the request body. If default is not provided, the argument is considered to be required, and we raise a `MissingArgumentError` if it is missing. If the argument appears in the url more than once, we return the last valu...
tornado/web.py
def get_body_argument( self, name: str, default: Union[None, str, _ArgDefaultMarker] = _ARG_DEFAULT, strip: bool = True, ) -> Optional[str]: """Returns the value of the argument with the given name from the request body. If default is not provided, the argume...
def get_body_argument( self, name: str, default: Union[None, str, _ArgDefaultMarker] = _ARG_DEFAULT, strip: bool = True, ) -> Optional[str]: """Returns the value of the argument with the given name from the request body. If default is not provided, the argume...
[ "Returns", "the", "value", "of", "the", "argument", "with", "the", "given", "name", "from", "the", "request", "body", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/web.py#L472-L489
[ "def", "get_body_argument", "(", "self", ",", "name", ":", "str", ",", "default", ":", "Union", "[", "None", ",", "str", ",", "_ArgDefaultMarker", "]", "=", "_ARG_DEFAULT", ",", "strip", ":", "bool", "=", "True", ",", ")", "->", "Optional", "[", "str",...
b8b481770bcdb333a69afde5cce7eaa449128326
train
RequestHandler.get_body_arguments
Returns a list of the body arguments with the given name. If the argument is not present, returns an empty list. .. versionadded:: 3.2
tornado/web.py
def get_body_arguments(self, name: str, strip: bool = True) -> List[str]: """Returns a list of the body arguments with the given name. If the argument is not present, returns an empty list. .. versionadded:: 3.2 """ return self._get_arguments(name, self.request.body_arguments, ...
def get_body_arguments(self, name: str, strip: bool = True) -> List[str]: """Returns a list of the body arguments with the given name. If the argument is not present, returns an empty list. .. versionadded:: 3.2 """ return self._get_arguments(name, self.request.body_arguments, ...
[ "Returns", "a", "list", "of", "the", "body", "arguments", "with", "the", "given", "name", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/web.py#L491-L498
[ "def", "get_body_arguments", "(", "self", ",", "name", ":", "str", ",", "strip", ":", "bool", "=", "True", ")", "->", "List", "[", "str", "]", ":", "return", "self", ".", "_get_arguments", "(", "name", ",", "self", ".", "request", ".", "body_arguments"...
b8b481770bcdb333a69afde5cce7eaa449128326
train
RequestHandler.get_query_argument
Returns the value of the argument with the given name from the request query string. If default is not provided, the argument is considered to be required, and we raise a `MissingArgumentError` if it is missing. If the argument appears in the url more than once, we return the l...
tornado/web.py
def get_query_argument( self, name: str, default: Union[None, str, _ArgDefaultMarker] = _ARG_DEFAULT, strip: bool = True, ) -> Optional[str]: """Returns the value of the argument with the given name from the request query string. If default is not provided, t...
def get_query_argument( self, name: str, default: Union[None, str, _ArgDefaultMarker] = _ARG_DEFAULT, strip: bool = True, ) -> Optional[str]: """Returns the value of the argument with the given name from the request query string. If default is not provided, t...
[ "Returns", "the", "value", "of", "the", "argument", "with", "the", "given", "name", "from", "the", "request", "query", "string", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/web.py#L500-L517
[ "def", "get_query_argument", "(", "self", ",", "name", ":", "str", ",", "default", ":", "Union", "[", "None", ",", "str", ",", "_ArgDefaultMarker", "]", "=", "_ARG_DEFAULT", ",", "strip", ":", "bool", "=", "True", ",", ")", "->", "Optional", "[", "str"...
b8b481770bcdb333a69afde5cce7eaa449128326
train
RequestHandler.get_query_arguments
Returns a list of the query arguments with the given name. If the argument is not present, returns an empty list. .. versionadded:: 3.2
tornado/web.py
def get_query_arguments(self, name: str, strip: bool = True) -> List[str]: """Returns a list of the query arguments with the given name. If the argument is not present, returns an empty list. .. versionadded:: 3.2 """ return self._get_arguments(name, self.request.query_argument...
def get_query_arguments(self, name: str, strip: bool = True) -> List[str]: """Returns a list of the query arguments with the given name. If the argument is not present, returns an empty list. .. versionadded:: 3.2 """ return self._get_arguments(name, self.request.query_argument...
[ "Returns", "a", "list", "of", "the", "query", "arguments", "with", "the", "given", "name", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/web.py#L519-L526
[ "def", "get_query_arguments", "(", "self", ",", "name", ":", "str", ",", "strip", ":", "bool", "=", "True", ")", "->", "List", "[", "str", "]", ":", "return", "self", ".", "_get_arguments", "(", "name", ",", "self", ".", "request", ".", "query_argument...
b8b481770bcdb333a69afde5cce7eaa449128326
train
RequestHandler.decode_argument
Decodes an argument from the request. The argument has been percent-decoded and is now a byte string. By default, this method decodes the argument as utf-8 and returns a unicode string, but this may be overridden in subclasses. This method is used as a filter for both `get_argument()` ...
tornado/web.py
def decode_argument(self, value: bytes, name: str = None) -> str: """Decodes an argument from the request. The argument has been percent-decoded and is now a byte string. By default, this method decodes the argument as utf-8 and returns a unicode string, but this may be overridden in su...
def decode_argument(self, value: bytes, name: str = None) -> str: """Decodes an argument from the request. The argument has been percent-decoded and is now a byte string. By default, this method decodes the argument as utf-8 and returns a unicode string, but this may be overridden in su...
[ "Decodes", "an", "argument", "from", "the", "request", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/web.py#L557-L575
[ "def", "decode_argument", "(", "self", ",", "value", ":", "bytes", ",", "name", ":", "str", "=", "None", ")", "->", "str", ":", "try", ":", "return", "_unicode", "(", "value", ")", "except", "UnicodeDecodeError", ":", "raise", "HTTPError", "(", "400", ...
b8b481770bcdb333a69afde5cce7eaa449128326
train
RequestHandler.cookies
An alias for `self.request.cookies <.httputil.HTTPServerRequest.cookies>`.
tornado/web.py
def cookies(self) -> Dict[str, http.cookies.Morsel]: """An alias for `self.request.cookies <.httputil.HTTPServerRequest.cookies>`.""" return self.request.cookies
def cookies(self) -> Dict[str, http.cookies.Morsel]: """An alias for `self.request.cookies <.httputil.HTTPServerRequest.cookies>`.""" return self.request.cookies
[ "An", "alias", "for", "self", ".", "request", ".", "cookies", "<", ".", "httputil", ".", "HTTPServerRequest", ".", "cookies", ">", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/web.py#L578-L581
[ "def", "cookies", "(", "self", ")", "->", "Dict", "[", "str", ",", "http", ".", "cookies", ".", "Morsel", "]", ":", "return", "self", ".", "request", ".", "cookies" ]
b8b481770bcdb333a69afde5cce7eaa449128326
train
RequestHandler.get_cookie
Returns the value of the request cookie with the given name. If the named cookie is not present, returns ``default``. This method only returns cookies that were present in the request. It does not see the outgoing cookies set by `set_cookie` in this handler.
tornado/web.py
def get_cookie(self, name: str, default: str = None) -> Optional[str]: """Returns the value of the request cookie with the given name. If the named cookie is not present, returns ``default``. This method only returns cookies that were present in the request. It does not see the outgoin...
def get_cookie(self, name: str, default: str = None) -> Optional[str]: """Returns the value of the request cookie with the given name. If the named cookie is not present, returns ``default``. This method only returns cookies that were present in the request. It does not see the outgoin...
[ "Returns", "the", "value", "of", "the", "request", "cookie", "with", "the", "given", "name", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/web.py#L583-L594
[ "def", "get_cookie", "(", "self", ",", "name", ":", "str", ",", "default", ":", "str", "=", "None", ")", "->", "Optional", "[", "str", "]", ":", "if", "self", ".", "request", ".", "cookies", "is", "not", "None", "and", "name", "in", "self", ".", ...
b8b481770bcdb333a69afde5cce7eaa449128326
train
RequestHandler.set_cookie
Sets an outgoing cookie name/value with the given options. Newly-set cookies are not immediately visible via `get_cookie`; they are not present until the next request. expires may be a numeric timestamp as returned by `time.time`, a time tuple as returned by `time.gmtime`, or a ...
tornado/web.py
def set_cookie( self, name: str, value: Union[str, bytes], domain: str = None, expires: Union[float, Tuple, datetime.datetime] = None, path: str = "/", expires_days: int = None, **kwargs: Any ) -> None: """Sets an outgoing cookie name/value wit...
def set_cookie( self, name: str, value: Union[str, bytes], domain: str = None, expires: Union[float, Tuple, datetime.datetime] = None, path: str = "/", expires_days: int = None, **kwargs: Any ) -> None: """Sets an outgoing cookie name/value wit...
[ "Sets", "an", "outgoing", "cookie", "name", "/", "value", "with", "the", "given", "options", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/web.py#L596-L649
[ "def", "set_cookie", "(", "self", ",", "name", ":", "str", ",", "value", ":", "Union", "[", "str", ",", "bytes", "]", ",", "domain", ":", "str", "=", "None", ",", "expires", ":", "Union", "[", "float", ",", "Tuple", ",", "datetime", ".", "datetime"...
b8b481770bcdb333a69afde5cce7eaa449128326
train
RequestHandler.clear_cookie
Deletes the cookie with the given name. Due to limitations of the cookie protocol, you must pass the same path and domain to clear a cookie as were used when that cookie was set (but there is no way to find out on the server side which values were used for a given cookie). Simi...
tornado/web.py
def clear_cookie(self, name: str, path: str = "/", domain: str = None) -> None: """Deletes the cookie with the given name. Due to limitations of the cookie protocol, you must pass the same path and domain to clear a cookie as were used when that cookie was set (but there is no way to fi...
def clear_cookie(self, name: str, path: str = "/", domain: str = None) -> None: """Deletes the cookie with the given name. Due to limitations of the cookie protocol, you must pass the same path and domain to clear a cookie as were used when that cookie was set (but there is no way to fi...
[ "Deletes", "the", "cookie", "with", "the", "given", "name", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/web.py#L651-L663
[ "def", "clear_cookie", "(", "self", ",", "name", ":", "str", ",", "path", ":", "str", "=", "\"/\"", ",", "domain", ":", "str", "=", "None", ")", "->", "None", ":", "expires", "=", "datetime", ".", "datetime", ".", "utcnow", "(", ")", "-", "datetime...
b8b481770bcdb333a69afde5cce7eaa449128326
train
RequestHandler.clear_all_cookies
Deletes all the cookies the user sent with this request. See `clear_cookie` for more information on the path and domain parameters. Similar to `set_cookie`, the effect of this method will not be seen until the following request. .. versionchanged:: 3.2 Added the ``...
tornado/web.py
def clear_all_cookies(self, path: str = "/", domain: str = None) -> None: """Deletes all the cookies the user sent with this request. See `clear_cookie` for more information on the path and domain parameters. Similar to `set_cookie`, the effect of this method will not be seen u...
def clear_all_cookies(self, path: str = "/", domain: str = None) -> None: """Deletes all the cookies the user sent with this request. See `clear_cookie` for more information on the path and domain parameters. Similar to `set_cookie`, the effect of this method will not be seen u...
[ "Deletes", "all", "the", "cookies", "the", "user", "sent", "with", "this", "request", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/web.py#L665-L679
[ "def", "clear_all_cookies", "(", "self", ",", "path", ":", "str", "=", "\"/\"", ",", "domain", ":", "str", "=", "None", ")", "->", "None", ":", "for", "name", "in", "self", ".", "request", ".", "cookies", ":", "self", ".", "clear_cookie", "(", "name"...
b8b481770bcdb333a69afde5cce7eaa449128326
train
RequestHandler.set_secure_cookie
Signs and timestamps a cookie so it cannot be forged. You must specify the ``cookie_secret`` setting in your Application to use this method. It should be a long, random sequence of bytes to be used as the HMAC secret for the signature. To read a cookie set with this method, use `get_se...
tornado/web.py
def set_secure_cookie( self, name: str, value: Union[str, bytes], expires_days: int = 30, version: int = None, **kwargs: Any ) -> None: """Signs and timestamps a cookie so it cannot be forged. You must specify the ``cookie_secret`` setting in your App...
def set_secure_cookie( self, name: str, value: Union[str, bytes], expires_days: int = 30, version: int = None, **kwargs: Any ) -> None: """Signs and timestamps a cookie so it cannot be forged. You must specify the ``cookie_secret`` setting in your App...
[ "Signs", "and", "timestamps", "a", "cookie", "so", "it", "cannot", "be", "forged", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/web.py#L681-L717
[ "def", "set_secure_cookie", "(", "self", ",", "name", ":", "str", ",", "value", ":", "Union", "[", "str", ",", "bytes", "]", ",", "expires_days", ":", "int", "=", "30", ",", "version", ":", "int", "=", "None", ",", "*", "*", "kwargs", ":", "Any", ...
b8b481770bcdb333a69afde5cce7eaa449128326
train
RequestHandler.create_signed_value
Signs and timestamps a string so it cannot be forged. Normally used via set_secure_cookie, but provided as a separate method for non-cookie uses. To decode a value not stored as a cookie use the optional value argument to get_secure_cookie. .. versionchanged:: 3.2.1 Added ...
tornado/web.py
def create_signed_value( self, name: str, value: Union[str, bytes], version: int = None ) -> bytes: """Signs and timestamps a string so it cannot be forged. Normally used via set_secure_cookie, but provided as a separate method for non-cookie uses. To decode a value not stored ...
def create_signed_value( self, name: str, value: Union[str, bytes], version: int = None ) -> bytes: """Signs and timestamps a string so it cannot be forged. Normally used via set_secure_cookie, but provided as a separate method for non-cookie uses. To decode a value not stored ...
[ "Signs", "and", "timestamps", "a", "string", "so", "it", "cannot", "be", "forged", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/web.py#L719-L743
[ "def", "create_signed_value", "(", "self", ",", "name", ":", "str", ",", "value", ":", "Union", "[", "str", ",", "bytes", "]", ",", "version", ":", "int", "=", "None", ")", "->", "bytes", ":", "self", ".", "require_setting", "(", "\"cookie_secret\"", "...
b8b481770bcdb333a69afde5cce7eaa449128326
train
RequestHandler.get_secure_cookie
Returns the given signed cookie if it validates, or None. The decoded cookie value is returned as a byte string (unlike `get_cookie`). Similar to `get_cookie`, this method only returns cookies that were present in the request. It does not see outgoing cookies set by `set_secure...
tornado/web.py
def get_secure_cookie( self, name: str, value: str = None, max_age_days: int = 31, min_version: int = None, ) -> Optional[bytes]: """Returns the given signed cookie if it validates, or None. The decoded cookie value is returned as a byte string (unlike ...
def get_secure_cookie( self, name: str, value: str = None, max_age_days: int = 31, min_version: int = None, ) -> Optional[bytes]: """Returns the given signed cookie if it validates, or None. The decoded cookie value is returned as a byte string (unlike ...
[ "Returns", "the", "given", "signed", "cookie", "if", "it", "validates", "or", "None", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/web.py#L745-L775
[ "def", "get_secure_cookie", "(", "self", ",", "name", ":", "str", ",", "value", ":", "str", "=", "None", ",", "max_age_days", ":", "int", "=", "31", ",", "min_version", ":", "int", "=", "None", ",", ")", "->", "Optional", "[", "bytes", "]", ":", "s...
b8b481770bcdb333a69afde5cce7eaa449128326
train
RequestHandler.get_secure_cookie_key_version
Returns the signing key version of the secure cookie. The version is returned as int.
tornado/web.py
def get_secure_cookie_key_version( self, name: str, value: str = None ) -> Optional[int]: """Returns the signing key version of the secure cookie. The version is returned as int. """ self.require_setting("cookie_secret", "secure cookies") if value is None: ...
def get_secure_cookie_key_version( self, name: str, value: str = None ) -> Optional[int]: """Returns the signing key version of the secure cookie. The version is returned as int. """ self.require_setting("cookie_secret", "secure cookies") if value is None: ...
[ "Returns", "the", "signing", "key", "version", "of", "the", "secure", "cookie", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/web.py#L777-L789
[ "def", "get_secure_cookie_key_version", "(", "self", ",", "name", ":", "str", ",", "value", ":", "str", "=", "None", ")", "->", "Optional", "[", "int", "]", ":", "self", ".", "require_setting", "(", "\"cookie_secret\"", ",", "\"secure cookies\"", ")", "if", ...
b8b481770bcdb333a69afde5cce7eaa449128326
train
RequestHandler.redirect
Sends a redirect to the given (optionally relative) URL. If the ``status`` argument is specified, that value is used as the HTTP status code; otherwise either 301 (permanent) or 302 (temporary) is chosen based on the ``permanent`` argument. The default is 302 (temporary).
tornado/web.py
def redirect(self, url: str, permanent: bool = False, status: int = None) -> None: """Sends a redirect to the given (optionally relative) URL. If the ``status`` argument is specified, that value is used as the HTTP status code; otherwise either 301 (permanent) or 302 (temporary) is chos...
def redirect(self, url: str, permanent: bool = False, status: int = None) -> None: """Sends a redirect to the given (optionally relative) URL. If the ``status`` argument is specified, that value is used as the HTTP status code; otherwise either 301 (permanent) or 302 (temporary) is chos...
[ "Sends", "a", "redirect", "to", "the", "given", "(", "optionally", "relative", ")", "URL", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/web.py#L791-L807
[ "def", "redirect", "(", "self", ",", "url", ":", "str", ",", "permanent", ":", "bool", "=", "False", ",", "status", ":", "int", "=", "None", ")", "->", "None", ":", "if", "self", ".", "_headers_written", ":", "raise", "Exception", "(", "\"Cannot redire...
b8b481770bcdb333a69afde5cce7eaa449128326
train
RequestHandler.write
Writes the given chunk to the output buffer. To write the output to the network, use the `flush()` method below. If the given chunk is a dictionary, we write it as JSON and set the Content-Type of the response to be ``application/json``. (if you want to send JSON as a different ``Conte...
tornado/web.py
def write(self, chunk: Union[str, bytes, dict]) -> None: """Writes the given chunk to the output buffer. To write the output to the network, use the `flush()` method below. If the given chunk is a dictionary, we write it as JSON and set the Content-Type of the response to be ``applicat...
def write(self, chunk: Union[str, bytes, dict]) -> None: """Writes the given chunk to the output buffer. To write the output to the network, use the `flush()` method below. If the given chunk is a dictionary, we write it as JSON and set the Content-Type of the response to be ``applicat...
[ "Writes", "the", "given", "chunk", "to", "the", "output", "buffer", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/web.py#L809-L839
[ "def", "write", "(", "self", ",", "chunk", ":", "Union", "[", "str", ",", "bytes", ",", "dict", "]", ")", "->", "None", ":", "if", "self", ".", "_finished", ":", "raise", "RuntimeError", "(", "\"Cannot write() after finish()\"", ")", "if", "not", "isinst...
b8b481770bcdb333a69afde5cce7eaa449128326
train
RequestHandler.render
Renders the template with the given arguments as the response. ``render()`` calls ``finish()``, so no other output methods can be called after it. Returns a `.Future` with the same semantics as the one returned by `finish`. Awaiting this `.Future` is optional. .. versionchange...
tornado/web.py
def render(self, template_name: str, **kwargs: Any) -> "Future[None]": """Renders the template with the given arguments as the response. ``render()`` calls ``finish()``, so no other output methods can be called after it. Returns a `.Future` with the same semantics as the one returned b...
def render(self, template_name: str, **kwargs: Any) -> "Future[None]": """Renders the template with the given arguments as the response. ``render()`` calls ``finish()``, so no other output methods can be called after it. Returns a `.Future` with the same semantics as the one returned b...
[ "Renders", "the", "template", "with", "the", "given", "arguments", "as", "the", "response", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/web.py#L841-L914
[ "def", "render", "(", "self", ",", "template_name", ":", "str", ",", "*", "*", "kwargs", ":", "Any", ")", "->", "\"Future[None]\"", ":", "if", "self", ".", "_finished", ":", "raise", "RuntimeError", "(", "\"Cannot render() after finish()\"", ")", "html", "="...
b8b481770bcdb333a69afde5cce7eaa449128326
train
RequestHandler.render_linked_js
Default method used to render the final js links for the rendered webpage. Override this method in a sub-classed controller to change the output.
tornado/web.py
def render_linked_js(self, js_files: Iterable[str]) -> str: """Default method used to render the final js links for the rendered webpage. Override this method in a sub-classed controller to change the output. """ paths = [] unique_paths = set() # type: Set[str] ...
def render_linked_js(self, js_files: Iterable[str]) -> str: """Default method used to render the final js links for the rendered webpage. Override this method in a sub-classed controller to change the output. """ paths = [] unique_paths = set() # type: Set[str] ...
[ "Default", "method", "used", "to", "render", "the", "final", "js", "links", "for", "the", "rendered", "webpage", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/web.py#L916-L937
[ "def", "render_linked_js", "(", "self", ",", "js_files", ":", "Iterable", "[", "str", "]", ")", "->", "str", ":", "paths", "=", "[", "]", "unique_paths", "=", "set", "(", ")", "# type: Set[str]", "for", "path", "in", "js_files", ":", "if", "not", "is_a...
b8b481770bcdb333a69afde5cce7eaa449128326
train
RequestHandler.render_embed_js
Default method used to render the final embedded js for the rendered webpage. Override this method in a sub-classed controller to change the output.
tornado/web.py
def render_embed_js(self, js_embed: Iterable[bytes]) -> bytes: """Default method used to render the final embedded js for the rendered webpage. Override this method in a sub-classed controller to change the output. """ return ( b'<script type="text/javascript">\n//<!...
def render_embed_js(self, js_embed: Iterable[bytes]) -> bytes: """Default method used to render the final embedded js for the rendered webpage. Override this method in a sub-classed controller to change the output. """ return ( b'<script type="text/javascript">\n//<!...
[ "Default", "method", "used", "to", "render", "the", "final", "embedded", "js", "for", "the", "rendered", "webpage", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/web.py#L939-L949
[ "def", "render_embed_js", "(", "self", ",", "js_embed", ":", "Iterable", "[", "bytes", "]", ")", "->", "bytes", ":", "return", "(", "b'<script type=\"text/javascript\">\\n//<![CDATA[\\n'", "+", "b\"\\n\"", ".", "join", "(", "js_embed", ")", "+", "b\"\\n//]]>\\n</s...
b8b481770bcdb333a69afde5cce7eaa449128326
train
RequestHandler.render_linked_css
Default method used to render the final css links for the rendered webpage. Override this method in a sub-classed controller to change the output.
tornado/web.py
def render_linked_css(self, css_files: Iterable[str]) -> str: """Default method used to render the final css links for the rendered webpage. Override this method in a sub-classed controller to change the output. """ paths = [] unique_paths = set() # type: Set[str] ...
def render_linked_css(self, css_files: Iterable[str]) -> str: """Default method used to render the final css links for the rendered webpage. Override this method in a sub-classed controller to change the output. """ paths = [] unique_paths = set() # type: Set[str] ...
[ "Default", "method", "used", "to", "render", "the", "final", "css", "links", "for", "the", "rendered", "webpage", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/web.py#L951-L971
[ "def", "render_linked_css", "(", "self", ",", "css_files", ":", "Iterable", "[", "str", "]", ")", "->", "str", ":", "paths", "=", "[", "]", "unique_paths", "=", "set", "(", ")", "# type: Set[str]", "for", "path", "in", "css_files", ":", "if", "not", "i...
b8b481770bcdb333a69afde5cce7eaa449128326
train
RequestHandler.render_embed_css
Default method used to render the final embedded css for the rendered webpage. Override this method in a sub-classed controller to change the output.
tornado/web.py
def render_embed_css(self, css_embed: Iterable[bytes]) -> bytes: """Default method used to render the final embedded css for the rendered webpage. Override this method in a sub-classed controller to change the output. """ return b'<style type="text/css">\n' + b"\n".join(css_embe...
def render_embed_css(self, css_embed: Iterable[bytes]) -> bytes: """Default method used to render the final embedded css for the rendered webpage. Override this method in a sub-classed controller to change the output. """ return b'<style type="text/css">\n' + b"\n".join(css_embe...
[ "Default", "method", "used", "to", "render", "the", "final", "embedded", "css", "for", "the", "rendered", "webpage", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/web.py#L973-L979
[ "def", "render_embed_css", "(", "self", ",", "css_embed", ":", "Iterable", "[", "bytes", "]", ")", "->", "bytes", ":", "return", "b'<style type=\"text/css\">\\n'", "+", "b\"\\n\"", ".", "join", "(", "css_embed", ")", "+", "b\"\\n</style>\"" ]
b8b481770bcdb333a69afde5cce7eaa449128326
train
RequestHandler.render_string
Generate the given template with the given arguments. We return the generated byte string (in utf8). To generate and write a template as a response, use render() above.
tornado/web.py
def render_string(self, template_name: str, **kwargs: Any) -> bytes: """Generate the given template with the given arguments. We return the generated byte string (in utf8). To generate and write a template as a response, use render() above. """ # If no template_path is specified...
def render_string(self, template_name: str, **kwargs: Any) -> bytes: """Generate the given template with the given arguments. We return the generated byte string (in utf8). To generate and write a template as a response, use render() above. """ # If no template_path is specified...
[ "Generate", "the", "given", "template", "with", "the", "given", "arguments", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/web.py#L981-L1005
[ "def", "render_string", "(", "self", ",", "template_name", ":", "str", ",", "*", "*", "kwargs", ":", "Any", ")", "->", "bytes", ":", "# If no template_path is specified, use the path of the calling file", "template_path", "=", "self", ".", "get_template_path", "(", ...
b8b481770bcdb333a69afde5cce7eaa449128326
train
RequestHandler.get_template_namespace
Returns a dictionary to be used as the default template namespace. May be overridden by subclasses to add or modify values. The results of this method will be combined with additional defaults in the `tornado.template` module and keyword arguments to `render` or `render_string`.
tornado/web.py
def get_template_namespace(self) -> Dict[str, Any]: """Returns a dictionary to be used as the default template namespace. May be overridden by subclasses to add or modify values. The results of this method will be combined with additional defaults in the `tornado.template` module and k...
def get_template_namespace(self) -> Dict[str, Any]: """Returns a dictionary to be used as the default template namespace. May be overridden by subclasses to add or modify values. The results of this method will be combined with additional defaults in the `tornado.template` module and k...
[ "Returns", "a", "dictionary", "to", "be", "used", "as", "the", "default", "template", "namespace", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/web.py#L1007-L1028
[ "def", "get_template_namespace", "(", "self", ")", "->", "Dict", "[", "str", ",", "Any", "]", ":", "namespace", "=", "dict", "(", "handler", "=", "self", ",", "request", "=", "self", ".", "request", ",", "current_user", "=", "self", ".", "current_user", ...
b8b481770bcdb333a69afde5cce7eaa449128326
train
RequestHandler.create_template_loader
Returns a new template loader for the given path. May be overridden by subclasses. By default returns a directory-based loader on the given path, using the ``autoescape`` and ``template_whitespace`` application settings. If a ``template_loader`` application setting is supplied...
tornado/web.py
def create_template_loader(self, template_path: str) -> template.BaseLoader: """Returns a new template loader for the given path. May be overridden by subclasses. By default returns a directory-based loader on the given path, using the ``autoescape`` and ``template_whitespace`` applica...
def create_template_loader(self, template_path: str) -> template.BaseLoader: """Returns a new template loader for the given path. May be overridden by subclasses. By default returns a directory-based loader on the given path, using the ``autoescape`` and ``template_whitespace`` applica...
[ "Returns", "a", "new", "template", "loader", "for", "the", "given", "path", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/web.py#L1030-L1049
[ "def", "create_template_loader", "(", "self", ",", "template_path", ":", "str", ")", "->", "template", ".", "BaseLoader", ":", "settings", "=", "self", ".", "application", ".", "settings", "if", "\"template_loader\"", "in", "settings", ":", "return", "settings",...
b8b481770bcdb333a69afde5cce7eaa449128326
train
RequestHandler.flush
Flushes the current output buffer to the network. The ``callback`` argument, if given, can be used for flow control: it will be run when all flushed data has been written to the socket. Note that only one flush callback can be outstanding at a time; if another flush occurs before the pr...
tornado/web.py
def flush(self, include_footers: bool = False) -> "Future[None]": """Flushes the current output buffer to the network. The ``callback`` argument, if given, can be used for flow control: it will be run when all flushed data has been written to the socket. Note that only one flush callbac...
def flush(self, include_footers: bool = False) -> "Future[None]": """Flushes the current output buffer to the network. The ``callback`` argument, if given, can be used for flow control: it will be run when all flushed data has been written to the socket. Note that only one flush callbac...
[ "Flushes", "the", "current", "output", "buffer", "to", "the", "network", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/web.py#L1051-L1101
[ "def", "flush", "(", "self", ",", "include_footers", ":", "bool", "=", "False", ")", "->", "\"Future[None]\"", ":", "assert", "self", ".", "request", ".", "connection", "is", "not", "None", "chunk", "=", "b\"\"", ".", "join", "(", "self", ".", "_write_bu...
b8b481770bcdb333a69afde5cce7eaa449128326
train
RequestHandler.finish
Finishes this response, ending the HTTP request. Passing a ``chunk`` to ``finish()`` is equivalent to passing that chunk to ``write()`` and then calling ``finish()`` with no arguments. Returns a `.Future` which may optionally be awaited to track the sending of the response to the clien...
tornado/web.py
def finish(self, chunk: Union[str, bytes, dict] = None) -> "Future[None]": """Finishes this response, ending the HTTP request. Passing a ``chunk`` to ``finish()`` is equivalent to passing that chunk to ``write()`` and then calling ``finish()`` with no arguments. Returns a `.Future` whi...
def finish(self, chunk: Union[str, bytes, dict] = None) -> "Future[None]": """Finishes this response, ending the HTTP request. Passing a ``chunk`` to ``finish()`` is equivalent to passing that chunk to ``write()`` and then calling ``finish()`` with no arguments. Returns a `.Future` whi...
[ "Finishes", "this", "response", "ending", "the", "HTTP", "request", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/web.py#L1103-L1160
[ "def", "finish", "(", "self", ",", "chunk", ":", "Union", "[", "str", ",", "bytes", ",", "dict", "]", "=", "None", ")", "->", "\"Future[None]\"", ":", "if", "self", ".", "_finished", ":", "raise", "RuntimeError", "(", "\"finish() called twice\"", ")", "i...
b8b481770bcdb333a69afde5cce7eaa449128326
train
RequestHandler.detach
Take control of the underlying stream. Returns the underlying `.IOStream` object and stops all further HTTP processing. Intended for implementing protocols like websockets that tunnel over an HTTP handshake. This method is only supported when HTTP/1.1 is used. .. versionadded:...
tornado/web.py
def detach(self) -> iostream.IOStream: """Take control of the underlying stream. Returns the underlying `.IOStream` object and stops all further HTTP processing. Intended for implementing protocols like websockets that tunnel over an HTTP handshake. This method is only supporte...
def detach(self) -> iostream.IOStream: """Take control of the underlying stream. Returns the underlying `.IOStream` object and stops all further HTTP processing. Intended for implementing protocols like websockets that tunnel over an HTTP handshake. This method is only supporte...
[ "Take", "control", "of", "the", "underlying", "stream", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/web.py#L1162-L1175
[ "def", "detach", "(", "self", ")", "->", "iostream", ".", "IOStream", ":", "self", ".", "_finished", "=", "True", "# TODO: add detach to HTTPConnection?", "return", "self", ".", "request", ".", "connection", ".", "detach", "(", ")" ]
b8b481770bcdb333a69afde5cce7eaa449128326
train
RequestHandler.send_error
Sends the given HTTP error code to the browser. If `flush()` has already been called, it is not possible to send an error, so this method will simply terminate the response. If output has been written but not yet flushed, it will be discarded and replaced with the error page. O...
tornado/web.py
def send_error(self, status_code: int = 500, **kwargs: Any) -> None: """Sends the given HTTP error code to the browser. If `flush()` has already been called, it is not possible to send an error, so this method will simply terminate the response. If output has been written but not yet fl...
def send_error(self, status_code: int = 500, **kwargs: Any) -> None: """Sends the given HTTP error code to the browser. If `flush()` has already been called, it is not possible to send an error, so this method will simply terminate the response. If output has been written but not yet fl...
[ "Sends", "the", "given", "HTTP", "error", "code", "to", "the", "browser", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/web.py#L1182-L1218
[ "def", "send_error", "(", "self", ",", "status_code", ":", "int", "=", "500", ",", "*", "*", "kwargs", ":", "Any", ")", "->", "None", ":", "if", "self", ".", "_headers_written", ":", "gen_log", ".", "error", "(", "\"Cannot send error response after headers w...
b8b481770bcdb333a69afde5cce7eaa449128326
train
RequestHandler.write_error
Override to implement custom error pages. ``write_error`` may call `write`, `render`, `set_header`, etc to produce output as usual. If this error was caused by an uncaught exception (including HTTPError), an ``exc_info`` triple will be available as ``kwargs["exc_info"]``. Note...
tornado/web.py
def write_error(self, status_code: int, **kwargs: Any) -> None: """Override to implement custom error pages. ``write_error`` may call `write`, `render`, `set_header`, etc to produce output as usual. If this error was caused by an uncaught exception (including HTTPError), an ``e...
def write_error(self, status_code: int, **kwargs: Any) -> None: """Override to implement custom error pages. ``write_error`` may call `write`, `render`, `set_header`, etc to produce output as usual. If this error was caused by an uncaught exception (including HTTPError), an ``e...
[ "Override", "to", "implement", "custom", "error", "pages", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/web.py#L1220-L1243
[ "def", "write_error", "(", "self", ",", "status_code", ":", "int", ",", "*", "*", "kwargs", ":", "Any", ")", "->", "None", ":", "if", "self", ".", "settings", ".", "get", "(", "\"serve_traceback\"", ")", "and", "\"exc_info\"", "in", "kwargs", ":", "# i...
b8b481770bcdb333a69afde5cce7eaa449128326
train
RequestHandler.locale
The locale for the current session. Determined by either `get_user_locale`, which you can override to set the locale based on, e.g., a user preference stored in a database, or `get_browser_locale`, which uses the ``Accept-Language`` header. .. versionchanged: 4.1 Add...
tornado/web.py
def locale(self) -> tornado.locale.Locale: """The locale for the current session. Determined by either `get_user_locale`, which you can override to set the locale based on, e.g., a user preference stored in a database, or `get_browser_locale`, which uses the ``Accept-Language`` ...
def locale(self) -> tornado.locale.Locale: """The locale for the current session. Determined by either `get_user_locale`, which you can override to set the locale based on, e.g., a user preference stored in a database, or `get_browser_locale`, which uses the ``Accept-Language`` ...
[ "The", "locale", "for", "the", "current", "session", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/web.py#L1246-L1264
[ "def", "locale", "(", "self", ")", "->", "tornado", ".", "locale", ".", "Locale", ":", "if", "not", "hasattr", "(", "self", ",", "\"_locale\"", ")", ":", "loc", "=", "self", ".", "get_user_locale", "(", ")", "if", "loc", "is", "not", "None", ":", "...
b8b481770bcdb333a69afde5cce7eaa449128326
train
RequestHandler.get_browser_locale
Determines the user's locale from ``Accept-Language`` header. See http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.4
tornado/web.py
def get_browser_locale(self, default: str = "en_US") -> tornado.locale.Locale: """Determines the user's locale from ``Accept-Language`` header. See http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.4 """ if "Accept-Language" in self.request.headers: languages = se...
def get_browser_locale(self, default: str = "en_US") -> tornado.locale.Locale: """Determines the user's locale from ``Accept-Language`` header. See http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.4 """ if "Accept-Language" in self.request.headers: languages = se...
[ "Determines", "the", "user", "s", "locale", "from", "Accept", "-", "Language", "header", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/web.py#L1280-L1302
[ "def", "get_browser_locale", "(", "self", ",", "default", ":", "str", "=", "\"en_US\"", ")", "->", "tornado", ".", "locale", ".", "Locale", ":", "if", "\"Accept-Language\"", "in", "self", ".", "request", ".", "headers", ":", "languages", "=", "self", ".", ...
b8b481770bcdb333a69afde5cce7eaa449128326
train
RequestHandler.current_user
The authenticated user for this request. This is set in one of two ways: * A subclass may override `get_current_user()`, which will be called automatically the first time ``self.current_user`` is accessed. `get_current_user()` will only be called once per request, and is ...
tornado/web.py
def current_user(self) -> Any: """The authenticated user for this request. This is set in one of two ways: * A subclass may override `get_current_user()`, which will be called automatically the first time ``self.current_user`` is accessed. `get_current_user()` will only be ...
def current_user(self) -> Any: """The authenticated user for this request. This is set in one of two ways: * A subclass may override `get_current_user()`, which will be called automatically the first time ``self.current_user`` is accessed. `get_current_user()` will only be ...
[ "The", "authenticated", "user", "for", "this", "request", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/web.py#L1305-L1338
[ "def", "current_user", "(", "self", ")", "->", "Any", ":", "if", "not", "hasattr", "(", "self", ",", "\"_current_user\"", ")", ":", "self", ".", "_current_user", "=", "self", ".", "get_current_user", "(", ")", "return", "self", ".", "_current_user" ]
b8b481770bcdb333a69afde5cce7eaa449128326
train
RequestHandler.xsrf_token
The XSRF-prevention token for the current user/session. To prevent cross-site request forgery, we set an '_xsrf' cookie and include the same '_xsrf' value as an argument with all POST requests. If the two do not match, we reject the form submission as a potential forgery. See h...
tornado/web.py
def xsrf_token(self) -> bytes: """The XSRF-prevention token for the current user/session. To prevent cross-site request forgery, we set an '_xsrf' cookie and include the same '_xsrf' value as an argument with all POST requests. If the two do not match, we reject the form submission ...
def xsrf_token(self) -> bytes: """The XSRF-prevention token for the current user/session. To prevent cross-site request forgery, we set an '_xsrf' cookie and include the same '_xsrf' value as an argument with all POST requests. If the two do not match, we reject the form submission ...
[ "The", "XSRF", "-", "prevention", "token", "for", "the", "current", "user", "/", "session", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/web.py#L1368-L1422
[ "def", "xsrf_token", "(", "self", ")", "->", "bytes", ":", "if", "not", "hasattr", "(", "self", ",", "\"_xsrf_token\"", ")", ":", "version", ",", "token", ",", "timestamp", "=", "self", ".", "_get_raw_xsrf_token", "(", ")", "output_version", "=", "self", ...
b8b481770bcdb333a69afde5cce7eaa449128326
train
RequestHandler._get_raw_xsrf_token
Read or generate the xsrf token in its raw form. The raw_xsrf_token is a tuple containing: * version: the version of the cookie from which this token was read, or None if we generated a new token in this request. * token: the raw token data; random (non-ascii) bytes. * timest...
tornado/web.py
def _get_raw_xsrf_token(self) -> Tuple[Optional[int], bytes, float]: """Read or generate the xsrf token in its raw form. The raw_xsrf_token is a tuple containing: * version: the version of the cookie from which this token was read, or None if we generated a new token in this request....
def _get_raw_xsrf_token(self) -> Tuple[Optional[int], bytes, float]: """Read or generate the xsrf token in its raw form. The raw_xsrf_token is a tuple containing: * version: the version of the cookie from which this token was read, or None if we generated a new token in this request....
[ "Read", "or", "generate", "the", "xsrf", "token", "in", "its", "raw", "form", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/web.py#L1424-L1448
[ "def", "_get_raw_xsrf_token", "(", "self", ")", "->", "Tuple", "[", "Optional", "[", "int", "]", ",", "bytes", ",", "float", "]", ":", "if", "not", "hasattr", "(", "self", ",", "\"_raw_xsrf_token\"", ")", ":", "cookie", "=", "self", ".", "get_cookie", ...
b8b481770bcdb333a69afde5cce7eaa449128326
train
RequestHandler._decode_xsrf_token
Convert a cookie string into a the tuple form returned by _get_raw_xsrf_token.
tornado/web.py
def _decode_xsrf_token( self, cookie: str ) -> Tuple[Optional[int], Optional[bytes], Optional[float]]: """Convert a cookie string into a the tuple form returned by _get_raw_xsrf_token. """ try: m = _signed_value_version_re.match(utf8(cookie)) if m: ...
def _decode_xsrf_token( self, cookie: str ) -> Tuple[Optional[int], Optional[bytes], Optional[float]]: """Convert a cookie string into a the tuple form returned by _get_raw_xsrf_token. """ try: m = _signed_value_version_re.match(utf8(cookie)) if m: ...
[ "Convert", "a", "cookie", "string", "into", "a", "the", "tuple", "form", "returned", "by", "_get_raw_xsrf_token", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/web.py#L1450-L1484
[ "def", "_decode_xsrf_token", "(", "self", ",", "cookie", ":", "str", ")", "->", "Tuple", "[", "Optional", "[", "int", "]", ",", "Optional", "[", "bytes", "]", ",", "Optional", "[", "float", "]", "]", ":", "try", ":", "m", "=", "_signed_value_version_re...
b8b481770bcdb333a69afde5cce7eaa449128326
train
RequestHandler.check_xsrf_cookie
Verifies that the ``_xsrf`` cookie matches the ``_xsrf`` argument. To prevent cross-site request forgery, we set an ``_xsrf`` cookie and include the same value as a non-cookie field with all ``POST`` requests. If the two do not match, we reject the form submission as a potential forgery...
tornado/web.py
def check_xsrf_cookie(self) -> None: """Verifies that the ``_xsrf`` cookie matches the ``_xsrf`` argument. To prevent cross-site request forgery, we set an ``_xsrf`` cookie and include the same value as a non-cookie field with all ``POST`` requests. If the two do not match, we r...
def check_xsrf_cookie(self) -> None: """Verifies that the ``_xsrf`` cookie matches the ``_xsrf`` argument. To prevent cross-site request forgery, we set an ``_xsrf`` cookie and include the same value as a non-cookie field with all ``POST`` requests. If the two do not match, we r...
[ "Verifies", "that", "the", "_xsrf", "cookie", "matches", "the", "_xsrf", "argument", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/web.py#L1486-L1522
[ "def", "check_xsrf_cookie", "(", "self", ")", "->", "None", ":", "# Prior to release 1.1.1, this check was ignored if the HTTP header", "# ``X-Requested-With: XMLHTTPRequest`` was present. This exception", "# has been shown to be insecure and has been removed. For more", "# information pleas...
b8b481770bcdb333a69afde5cce7eaa449128326
train
RequestHandler.static_url
Returns a static URL for the given relative static file path. This method requires you set the ``static_path`` setting in your application (which specifies the root directory of your static files). This method returns a versioned url (by default appending ``?v=<signature>``), w...
tornado/web.py
def static_url(self, path: str, include_host: bool = None, **kwargs: Any) -> str: """Returns a static URL for the given relative static file path. This method requires you set the ``static_path`` setting in your application (which specifies the root directory of your static files). ...
def static_url(self, path: str, include_host: bool = None, **kwargs: Any) -> str: """Returns a static URL for the given relative static file path. This method requires you set the ``static_path`` setting in your application (which specifies the root directory of your static files). ...
[ "Returns", "a", "static", "URL", "for", "the", "given", "relative", "static", "file", "path", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/web.py#L1543-L1577
[ "def", "static_url", "(", "self", ",", "path", ":", "str", ",", "include_host", ":", "bool", "=", "None", ",", "*", "*", "kwargs", ":", "Any", ")", "->", "str", ":", "self", ".", "require_setting", "(", "\"static_path\"", ",", "\"static_url\"", ")", "g...
b8b481770bcdb333a69afde5cce7eaa449128326
train
RequestHandler.require_setting
Raises an exception if the given app setting is not defined.
tornado/web.py
def require_setting(self, name: str, feature: str = "this feature") -> None: """Raises an exception if the given app setting is not defined.""" if not self.application.settings.get(name): raise Exception( "You must define the '%s' setting in your " "applicatio...
def require_setting(self, name: str, feature: str = "this feature") -> None: """Raises an exception if the given app setting is not defined.""" if not self.application.settings.get(name): raise Exception( "You must define the '%s' setting in your " "applicatio...
[ "Raises", "an", "exception", "if", "the", "given", "app", "setting", "is", "not", "defined", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/web.py#L1579-L1585
[ "def", "require_setting", "(", "self", ",", "name", ":", "str", ",", "feature", ":", "str", "=", "\"this feature\"", ")", "->", "None", ":", "if", "not", "self", ".", "application", ".", "settings", ".", "get", "(", "name", ")", ":", "raise", "Exceptio...
b8b481770bcdb333a69afde5cce7eaa449128326
train
RequestHandler.reverse_url
Alias for `Application.reverse_url`.
tornado/web.py
def reverse_url(self, name: str, *args: Any) -> str: """Alias for `Application.reverse_url`.""" return self.application.reverse_url(name, *args)
def reverse_url(self, name: str, *args: Any) -> str: """Alias for `Application.reverse_url`.""" return self.application.reverse_url(name, *args)
[ "Alias", "for", "Application", ".", "reverse_url", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/web.py#L1587-L1589
[ "def", "reverse_url", "(", "self", ",", "name", ":", "str", ",", "*", "args", ":", "Any", ")", "->", "str", ":", "return", "self", ".", "application", ".", "reverse_url", "(", "name", ",", "*", "args", ")" ]
b8b481770bcdb333a69afde5cce7eaa449128326
train
RequestHandler.compute_etag
Computes the etag header to be used for this request. By default uses a hash of the content written so far. May be overridden to provide custom etag implementations, or may return None to disable tornado's default etag support.
tornado/web.py
def compute_etag(self) -> Optional[str]: """Computes the etag header to be used for this request. By default uses a hash of the content written so far. May be overridden to provide custom etag implementations, or may return None to disable tornado's default etag support. """ ...
def compute_etag(self) -> Optional[str]: """Computes the etag header to be used for this request. By default uses a hash of the content written so far. May be overridden to provide custom etag implementations, or may return None to disable tornado's default etag support. """ ...
[ "Computes", "the", "etag", "header", "to", "be", "used", "for", "this", "request", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/web.py#L1591-L1602
[ "def", "compute_etag", "(", "self", ")", "->", "Optional", "[", "str", "]", ":", "hasher", "=", "hashlib", ".", "sha1", "(", ")", "for", "part", "in", "self", ".", "_write_buffer", ":", "hasher", ".", "update", "(", "part", ")", "return", "'\"%s\"'", ...
b8b481770bcdb333a69afde5cce7eaa449128326
train
RequestHandler.check_etag_header
Checks the ``Etag`` header against requests's ``If-None-Match``. Returns ``True`` if the request's Etag matches and a 304 should be returned. For example:: self.set_etag_header() if self.check_etag_header(): self.set_status(304) return T...
tornado/web.py
def check_etag_header(self) -> bool: """Checks the ``Etag`` header against requests's ``If-None-Match``. Returns ``True`` if the request's Etag matches and a 304 should be returned. For example:: self.set_etag_header() if self.check_etag_header(): self.s...
def check_etag_header(self) -> bool: """Checks the ``Etag`` header against requests's ``If-None-Match``. Returns ``True`` if the request's Etag matches and a 304 should be returned. For example:: self.set_etag_header() if self.check_etag_header(): self.s...
[ "Checks", "the", "Etag", "header", "against", "requests", "s", "If", "-", "None", "-", "Match", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/web.py#L1615-L1653
[ "def", "check_etag_header", "(", "self", ")", "->", "bool", ":", "computed_etag", "=", "utf8", "(", "self", ".", "_headers", ".", "get", "(", "\"Etag\"", ",", "\"\"", ")", ")", "# Find all weak and strong etag values from If-None-Match header", "# because RFC 7232 all...
b8b481770bcdb333a69afde5cce7eaa449128326
train
RequestHandler._execute
Executes this request with the given output transforms.
tornado/web.py
async def _execute( self, transforms: List["OutputTransform"], *args: bytes, **kwargs: bytes ) -> None: """Executes this request with the given output transforms.""" self._transforms = transforms try: if self.request.method not in self.SUPPORTED_METHODS: r...
async def _execute( self, transforms: List["OutputTransform"], *args: bytes, **kwargs: bytes ) -> None: """Executes this request with the given output transforms.""" self._transforms = transforms try: if self.request.method not in self.SUPPORTED_METHODS: r...
[ "Executes", "this", "request", "with", "the", "given", "output", "transforms", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/web.py#L1655-L1714
[ "async", "def", "_execute", "(", "self", ",", "transforms", ":", "List", "[", "\"OutputTransform\"", "]", ",", "*", "args", ":", "bytes", ",", "*", "*", "kwargs", ":", "bytes", ")", "->", "None", ":", "self", ".", "_transforms", "=", "transforms", "try...
b8b481770bcdb333a69afde5cce7eaa449128326
train
RequestHandler.log_exception
Override to customize logging of uncaught exceptions. By default logs instances of `HTTPError` as warnings without stack traces (on the ``tornado.general`` logger), and all other exceptions as errors with stack traces (on the ``tornado.application`` logger). .. versionadded:: 3...
tornado/web.py
def log_exception( self, typ: "Optional[Type[BaseException]]", value: Optional[BaseException], tb: Optional[TracebackType], ) -> None: """Override to customize logging of uncaught exceptions. By default logs instances of `HTTPError` as warnings without stack ...
def log_exception( self, typ: "Optional[Type[BaseException]]", value: Optional[BaseException], tb: Optional[TracebackType], ) -> None: """Override to customize logging of uncaught exceptions. By default logs instances of `HTTPError` as warnings without stack ...
[ "Override", "to", "customize", "logging", "of", "uncaught", "exceptions", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/web.py#L1763-L1789
[ "def", "log_exception", "(", "self", ",", "typ", ":", "\"Optional[Type[BaseException]]\"", ",", "value", ":", "Optional", "[", "BaseException", "]", ",", "tb", ":", "Optional", "[", "TracebackType", "]", ",", ")", "->", "None", ":", "if", "isinstance", "(", ...
b8b481770bcdb333a69afde5cce7eaa449128326
train
Application.listen
Starts an HTTP server for this application on the given port. This is a convenience alias for creating an `.HTTPServer` object and calling its listen method. Keyword arguments not supported by `HTTPServer.listen <.TCPServer.listen>` are passed to the `.HTTPServer` constructor. For adv...
tornado/web.py
def listen(self, port: int, address: str = "", **kwargs: Any) -> HTTPServer: """Starts an HTTP server for this application on the given port. This is a convenience alias for creating an `.HTTPServer` object and calling its listen method. Keyword arguments not supported by `HTTPServer.l...
def listen(self, port: int, address: str = "", **kwargs: Any) -> HTTPServer: """Starts an HTTP server for this application on the given port. This is a convenience alias for creating an `.HTTPServer` object and calling its listen method. Keyword arguments not supported by `HTTPServer.l...
[ "Starts", "an", "HTTP", "server", "for", "this", "application", "on", "the", "given", "port", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/web.py#L2092-L2113
[ "def", "listen", "(", "self", ",", "port", ":", "int", ",", "address", ":", "str", "=", "\"\"", ",", "*", "*", "kwargs", ":", "Any", ")", "->", "HTTPServer", ":", "server", "=", "HTTPServer", "(", "self", ",", "*", "*", "kwargs", ")", "server", "...
b8b481770bcdb333a69afde5cce7eaa449128326
train
Application.add_handlers
Appends the given handlers to our handler list. Host patterns are processed sequentially in the order they were added. All matching patterns will be considered.
tornado/web.py
def add_handlers(self, host_pattern: str, host_handlers: _RuleList) -> None: """Appends the given handlers to our handler list. Host patterns are processed sequentially in the order they were added. All matching patterns will be considered. """ host_matcher = HostMatches(host_pa...
def add_handlers(self, host_pattern: str, host_handlers: _RuleList) -> None: """Appends the given handlers to our handler list. Host patterns are processed sequentially in the order they were added. All matching patterns will be considered. """ host_matcher = HostMatches(host_pa...
[ "Appends", "the", "given", "handlers", "to", "our", "handler", "list", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/web.py#L2115-L2129
[ "def", "add_handlers", "(", "self", ",", "host_pattern", ":", "str", ",", "host_handlers", ":", "_RuleList", ")", "->", "None", ":", "host_matcher", "=", "HostMatches", "(", "host_pattern", ")", "rule", "=", "Rule", "(", "host_matcher", ",", "_ApplicationRoute...
b8b481770bcdb333a69afde5cce7eaa449128326
train
Application.get_handler_delegate
Returns `~.httputil.HTTPMessageDelegate` that can serve a request for application and `RequestHandler` subclass. :arg httputil.HTTPServerRequest request: current HTTP request. :arg RequestHandler target_class: a `RequestHandler` class. :arg dict target_kwargs: keyword arguments for ``ta...
tornado/web.py
def get_handler_delegate( self, request: httputil.HTTPServerRequest, target_class: Type[RequestHandler], target_kwargs: Dict[str, Any] = None, path_args: List[bytes] = None, path_kwargs: Dict[str, bytes] = None, ) -> "_HandlerDelegate": """Returns `~.httputil....
def get_handler_delegate( self, request: httputil.HTTPServerRequest, target_class: Type[RequestHandler], target_kwargs: Dict[str, Any] = None, path_args: List[bytes] = None, path_kwargs: Dict[str, bytes] = None, ) -> "_HandlerDelegate": """Returns `~.httputil....
[ "Returns", "~", ".", "httputil", ".", "HTTPMessageDelegate", "that", "can", "serve", "a", "request", "for", "application", "and", "RequestHandler", "subclass", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/web.py#L2187-L2207
[ "def", "get_handler_delegate", "(", "self", ",", "request", ":", "httputil", ".", "HTTPServerRequest", ",", "target_class", ":", "Type", "[", "RequestHandler", "]", ",", "target_kwargs", ":", "Dict", "[", "str", ",", "Any", "]", "=", "None", ",", "path_args"...
b8b481770bcdb333a69afde5cce7eaa449128326
train
Application.reverse_url
Returns a URL path for handler named ``name`` The handler must be added to the application as a named `URLSpec`. Args will be substituted for capturing groups in the `URLSpec` regex. They will be converted to strings if necessary, encoded as utf8, and url-escaped.
tornado/web.py
def reverse_url(self, name: str, *args: Any) -> str: """Returns a URL path for handler named ``name`` The handler must be added to the application as a named `URLSpec`. Args will be substituted for capturing groups in the `URLSpec` regex. They will be converted to strings if necessary,...
def reverse_url(self, name: str, *args: Any) -> str: """Returns a URL path for handler named ``name`` The handler must be added to the application as a named `URLSpec`. Args will be substituted for capturing groups in the `URLSpec` regex. They will be converted to strings if necessary,...
[ "Returns", "a", "URL", "path", "for", "handler", "named", "name" ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/web.py#L2209-L2222
[ "def", "reverse_url", "(", "self", ",", "name", ":", "str", ",", "*", "args", ":", "Any", ")", "->", "str", ":", "reversed_url", "=", "self", ".", "default_router", ".", "reverse_url", "(", "name", ",", "*", "args", ")", "if", "reversed_url", "is", "...
b8b481770bcdb333a69afde5cce7eaa449128326
train
Application.log_request
Writes a completed HTTP request to the logs. By default writes to the python root logger. To change this behavior either subclass Application and override this method, or pass a function in the application settings dictionary as ``log_function``.
tornado/web.py
def log_request(self, handler: RequestHandler) -> None: """Writes a completed HTTP request to the logs. By default writes to the python root logger. To change this behavior either subclass Application and override this method, or pass a function in the application settings dictionary a...
def log_request(self, handler: RequestHandler) -> None: """Writes a completed HTTP request to the logs. By default writes to the python root logger. To change this behavior either subclass Application and override this method, or pass a function in the application settings dictionary a...
[ "Writes", "a", "completed", "HTTP", "request", "to", "the", "logs", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/web.py#L2224-L2247
[ "def", "log_request", "(", "self", ",", "handler", ":", "RequestHandler", ")", "->", "None", ":", "if", "\"log_function\"", "in", "self", ".", "settings", ":", "self", ".", "settings", "[", "\"log_function\"", "]", "(", "handler", ")", "return", "if", "han...
b8b481770bcdb333a69afde5cce7eaa449128326
train
StaticFileHandler.compute_etag
Sets the ``Etag`` header based on static url version. This allows efficient ``If-None-Match`` checks against cached versions, and sends the correct ``Etag`` for a partial response (i.e. the same ``Etag`` as the full file). .. versionadded:: 3.1
tornado/web.py
def compute_etag(self) -> Optional[str]: """Sets the ``Etag`` header based on static url version. This allows efficient ``If-None-Match`` checks against cached versions, and sends the correct ``Etag`` for a partial response (i.e. the same ``Etag`` as the full file). .. versiona...
def compute_etag(self) -> Optional[str]: """Sets the ``Etag`` header based on static url version. This allows efficient ``If-None-Match`` checks against cached versions, and sends the correct ``Etag`` for a partial response (i.e. the same ``Etag`` as the full file). .. versiona...
[ "Sets", "the", "Etag", "header", "based", "on", "static", "url", "version", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/web.py#L2655-L2668
[ "def", "compute_etag", "(", "self", ")", "->", "Optional", "[", "str", "]", ":", "assert", "self", ".", "absolute_path", "is", "not", "None", "version_hash", "=", "self", ".", "_get_cached_version", "(", "self", ".", "absolute_path", ")", "if", "not", "ver...
b8b481770bcdb333a69afde5cce7eaa449128326
train
StaticFileHandler.set_headers
Sets the content and caching headers on the response. .. versionadded:: 3.1
tornado/web.py
def set_headers(self) -> None: """Sets the content and caching headers on the response. .. versionadded:: 3.1 """ self.set_header("Accept-Ranges", "bytes") self.set_etag_header() if self.modified is not None: self.set_header("Last-Modified", self.modified) ...
def set_headers(self) -> None: """Sets the content and caching headers on the response. .. versionadded:: 3.1 """ self.set_header("Accept-Ranges", "bytes") self.set_etag_header() if self.modified is not None: self.set_header("Last-Modified", self.modified) ...
[ "Sets", "the", "content", "and", "caching", "headers", "on", "the", "response", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/web.py#L2670-L2693
[ "def", "set_headers", "(", "self", ")", "->", "None", ":", "self", ".", "set_header", "(", "\"Accept-Ranges\"", ",", "\"bytes\"", ")", "self", ".", "set_etag_header", "(", ")", "if", "self", ".", "modified", "is", "not", "None", ":", "self", ".", "set_he...
b8b481770bcdb333a69afde5cce7eaa449128326
train
StaticFileHandler.should_return_304
Returns True if the headers indicate that we should return 304. .. versionadded:: 3.1
tornado/web.py
def should_return_304(self) -> bool: """Returns True if the headers indicate that we should return 304. .. versionadded:: 3.1 """ # If client sent If-None-Match, use it, ignore If-Modified-Since if self.request.headers.get("If-None-Match"): return self.check_etag_hea...
def should_return_304(self) -> bool: """Returns True if the headers indicate that we should return 304. .. versionadded:: 3.1 """ # If client sent If-None-Match, use it, ignore If-Modified-Since if self.request.headers.get("If-None-Match"): return self.check_etag_hea...
[ "Returns", "True", "if", "the", "headers", "indicate", "that", "we", "should", "return", "304", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/web.py#L2695-L2715
[ "def", "should_return_304", "(", "self", ")", "->", "bool", ":", "# If client sent If-None-Match, use it, ignore If-Modified-Since", "if", "self", ".", "request", ".", "headers", ".", "get", "(", "\"If-None-Match\"", ")", ":", "return", "self", ".", "check_etag_header...
b8b481770bcdb333a69afde5cce7eaa449128326
train
StaticFileHandler.get_absolute_path
Returns the absolute location of ``path`` relative to ``root``. ``root`` is the path configured for this `StaticFileHandler` (in most cases the ``static_path`` `Application` setting). This class method may be overridden in subclasses. By default it returns a filesystem path, but other...
tornado/web.py
def get_absolute_path(cls, root: str, path: str) -> str: """Returns the absolute location of ``path`` relative to ``root``. ``root`` is the path configured for this `StaticFileHandler` (in most cases the ``static_path`` `Application` setting). This class method may be overridden in sub...
def get_absolute_path(cls, root: str, path: str) -> str: """Returns the absolute location of ``path`` relative to ``root``. ``root`` is the path configured for this `StaticFileHandler` (in most cases the ``static_path`` `Application` setting). This class method may be overridden in sub...
[ "Returns", "the", "absolute", "location", "of", "path", "relative", "to", "root", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/web.py#L2718-L2732
[ "def", "get_absolute_path", "(", "cls", ",", "root", ":", "str", ",", "path", ":", "str", ")", "->", "str", ":", "abspath", "=", "os", ".", "path", ".", "abspath", "(", "os", ".", "path", ".", "join", "(", "root", ",", "path", ")", ")", "return",...
b8b481770bcdb333a69afde5cce7eaa449128326
train
StaticFileHandler.validate_absolute_path
Validate and return the absolute path. ``root`` is the configured path for the `StaticFileHandler`, and ``path`` is the result of `get_absolute_path` This is an instance method called during request processing, so it may raise `HTTPError` or use methods like `RequestHandler.red...
tornado/web.py
def validate_absolute_path(self, root: str, absolute_path: str) -> Optional[str]: """Validate and return the absolute path. ``root`` is the configured path for the `StaticFileHandler`, and ``path`` is the result of `get_absolute_path` This is an instance method called during request pr...
def validate_absolute_path(self, root: str, absolute_path: str) -> Optional[str]: """Validate and return the absolute path. ``root`` is the configured path for the `StaticFileHandler`, and ``path`` is the result of `get_absolute_path` This is an instance method called during request pr...
[ "Validate", "and", "return", "the", "absolute", "path", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/web.py#L2734-L2782
[ "def", "validate_absolute_path", "(", "self", ",", "root", ":", "str", ",", "absolute_path", ":", "str", ")", "->", "Optional", "[", "str", "]", ":", "# os.path.abspath strips a trailing /.", "# We must add it back to `root` so that we only match files", "# in a directory n...
b8b481770bcdb333a69afde5cce7eaa449128326
train
StaticFileHandler.get_content
Retrieve the content of the requested resource which is located at the given absolute path. This class method may be overridden by subclasses. Note that its signature is different from other overridable class methods (no ``settings`` argument); this is deliberate to ensure that ...
tornado/web.py
def get_content( cls, abspath: str, start: int = None, end: int = None ) -> Generator[bytes, None, None]: """Retrieve the content of the requested resource which is located at the given absolute path. This class method may be overridden by subclasses. Note that its signatur...
def get_content( cls, abspath: str, start: int = None, end: int = None ) -> Generator[bytes, None, None]: """Retrieve the content of the requested resource which is located at the given absolute path. This class method may be overridden by subclasses. Note that its signatur...
[ "Retrieve", "the", "content", "of", "the", "requested", "resource", "which", "is", "located", "at", "the", "given", "absolute", "path", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/web.py#L2785-L2821
[ "def", "get_content", "(", "cls", ",", "abspath", ":", "str", ",", "start", ":", "int", "=", "None", ",", "end", ":", "int", "=", "None", ")", "->", "Generator", "[", "bytes", ",", "None", ",", "None", "]", ":", "with", "open", "(", "abspath", ",...
b8b481770bcdb333a69afde5cce7eaa449128326
train
StaticFileHandler.get_content_version
Returns a version string for the resource at the given path. This class method may be overridden by subclasses. The default implementation is a hash of the file's contents. .. versionadded:: 3.1
tornado/web.py
def get_content_version(cls, abspath: str) -> str: """Returns a version string for the resource at the given path. This class method may be overridden by subclasses. The default implementation is a hash of the file's contents. .. versionadded:: 3.1 """ data = cls.get_c...
def get_content_version(cls, abspath: str) -> str: """Returns a version string for the resource at the given path. This class method may be overridden by subclasses. The default implementation is a hash of the file's contents. .. versionadded:: 3.1 """ data = cls.get_c...
[ "Returns", "a", "version", "string", "for", "the", "resource", "at", "the", "given", "path", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/web.py#L2824-L2839
[ "def", "get_content_version", "(", "cls", ",", "abspath", ":", "str", ")", "->", "str", ":", "data", "=", "cls", ".", "get_content", "(", "abspath", ")", "hasher", "=", "hashlib", ".", "md5", "(", ")", "if", "isinstance", "(", "data", ",", "bytes", "...
b8b481770bcdb333a69afde5cce7eaa449128326
train
StaticFileHandler.get_modified_time
Returns the time that ``self.absolute_path`` was last modified. May be overridden in subclasses. Should return a `~datetime.datetime` object or None. .. versionadded:: 3.1
tornado/web.py
def get_modified_time(self) -> Optional[datetime.datetime]: """Returns the time that ``self.absolute_path`` was last modified. May be overridden in subclasses. Should return a `~datetime.datetime` object or None. .. versionadded:: 3.1 """ stat_result = self._stat() ...
def get_modified_time(self) -> Optional[datetime.datetime]: """Returns the time that ``self.absolute_path`` was last modified. May be overridden in subclasses. Should return a `~datetime.datetime` object or None. .. versionadded:: 3.1 """ stat_result = self._stat() ...
[ "Returns", "the", "time", "that", "self", ".", "absolute_path", "was", "last", "modified", "." ]
tornadoweb/tornado
python
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/web.py#L2861-L2879
[ "def", "get_modified_time", "(", "self", ")", "->", "Optional", "[", "datetime", ".", "datetime", "]", ":", "stat_result", "=", "self", ".", "_stat", "(", ")", "# NOTE: Historically, this used stat_result[stat.ST_MTIME],", "# which truncates the fractional portion of the ti...
b8b481770bcdb333a69afde5cce7eaa449128326