tag.py — flask Source File
Architecture documentation for tag.py, a python file in the flask codebase. 7 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 5e2eed77_f23f_513d_2d00_d39ce63b14ab["tag.py"] 7a68bb60_6718_5d3b_7213_b254798b9b59["json"] 5e2eed77_f23f_513d_2d00_d39ce63b14ab --> 7a68bb60_6718_5d3b_7213_b254798b9b59 852dc50b_4da6_57dc_ead7_cdd90925e0b8["typing"] 5e2eed77_f23f_513d_2d00_d39ce63b14ab --> 852dc50b_4da6_57dc_ead7_cdd90925e0b8 61f61608_35ff_6a8c_e9f9_3e1306cde484["base64"] 5e2eed77_f23f_513d_2d00_d39ce63b14ab --> 61f61608_35ff_6a8c_e9f9_3e1306cde484 bdb4799f_8b0c_fcfd_51cc_f0b833652f8f["datetime"] 5e2eed77_f23f_513d_2d00_d39ce63b14ab --> bdb4799f_8b0c_fcfd_51cc_f0b833652f8f c26d67c5_e5bf_05b7_bcb4_ac69089e1109["uuid"] 5e2eed77_f23f_513d_2d00_d39ce63b14ab --> c26d67c5_e5bf_05b7_bcb4_ac69089e1109 73ef7241_8c5f_09fd_18d9_bc9f2aafacb1["markupsafe"] 5e2eed77_f23f_513d_2d00_d39ce63b14ab --> 73ef7241_8c5f_09fd_18d9_bc9f2aafacb1 c8ef0481_732f_584a_537b_20ea831e8fd0["werkzeug.http"] 5e2eed77_f23f_513d_2d00_d39ce63b14ab --> c8ef0481_732f_584a_537b_20ea831e8fd0 style 5e2eed77_f23f_513d_2d00_d39ce63b14ab fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
"""
Tagged JSON
~~~~~~~~~~~
A compact representation for lossless serialization of non-standard JSON
types. :class:`~flask.sessions.SecureCookieSessionInterface` uses this
to serialize the session data, but it may be useful in other places. It
can be extended to support other types.
.. autoclass:: TaggedJSONSerializer
:members:
.. autoclass:: JSONTag
:members:
Let's see an example that adds support for
:class:`~collections.OrderedDict`. Dicts don't have an order in JSON, so
to handle this we will dump the items as a list of ``[key, value]``
pairs. Subclass :class:`JSONTag` and give it the new key ``' od'`` to
identify the type. The session serializer processes dicts first, so
insert the new tag at the front of the order since ``OrderedDict`` must
be processed before ``dict``.
.. code-block:: python
from flask.json.tag import JSONTag
class TagOrderedDict(JSONTag):
__slots__ = ('serializer',)
key = ' od'
def check(self, value):
return isinstance(value, OrderedDict)
def to_json(self, value):
return [[k, self.serializer.tag(v)] for k, v in iteritems(value)]
def to_python(self, value):
return OrderedDict(value)
app.session_interface.serializer.register(TagOrderedDict, index=0)
"""
from __future__ import annotations
import typing as t
from base64 import b64decode
from base64 import b64encode
from datetime import datetime
from uuid import UUID
from markupsafe import Markup
from werkzeug.http import http_date
from werkzeug.http import parse_date
from ..json import dumps
from ..json import loads
class JSONTag:
// ... (268 more lines)
Domain
Subdomains
Classes
Dependencies
- base64
- datetime
- json
- markupsafe
- typing
- uuid
- werkzeug.http
Source
Frequently Asked Questions
What does tag.py do?
tag.py is a source file in the flask codebase, written in python. It belongs to the DataHandling domain, JsonProvider subdomain.
What does tag.py depend on?
tag.py imports 7 module(s): base64, datetime, json, markupsafe, typing, uuid, werkzeug.http.
Where is tag.py in the architecture?
tag.py is located at src/flask/json/tag.py (domain: DataHandling, subdomain: JsonProvider, directory: src/flask/json).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free