tina4-python 3.13.149__tar.gz → 3.13.151__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {tina4_python-3.13.149 → tina4_python-3.13.151}/PKG-INFO +5 -7
- {tina4_python-3.13.149 → tina4_python-3.13.151}/README.md +1 -1
- {tina4_python-3.13.149 → tina4_python-3.13.151}/pyproject.toml +16 -19
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/CLAUDE.md +2 -1
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/__init__.py +1 -1
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/cache/__init__.py +9 -1
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/cli/__init__.py +125 -2
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/core/middleware.py +15 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/core/request.py +190 -11
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/core/server.py +47 -4
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/crud/page.py +1 -1
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/crud/page_render.py +5 -5
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/dev_admin/__init__.py +153 -117
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/dev_admin/metrics.py +5 -1
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/dev_admin/plan.py +1 -1
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/frond/engine.py +174 -11
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/public/bundled-component-provenance.json +2 -2
- tina4_python-3.13.151/tina4_python/public/js/tina4-dev-admin-split.html +202 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/public/js/tina4-dev-admin.min.js +147 -138
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/realtime/__init__.py +15 -4
- tina4_python-3.13.151/tina4_python/realtime/s3_client.py +255 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/realtime/storage.py +18 -27
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/templates/crud/form.twig +5 -5
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/templates/crud/table.twig +2 -2
- tina4_python-3.13.151/tina4_python/templates/errors/302.twig +23 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/websocket/__init__.py +6 -3
- tina4_python-3.13.149/tina4_python/templates/errors/302.twig +0 -22
- {tina4_python-3.13.149 → tina4_python-3.13.151}/.gitignore +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/COMMERCIAL-LICENSE.md +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/LICENSE +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/NOTICE +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/.tina4-metrics.json +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/HtmlElement.py +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/Testing.py +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/_import_helper.py +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/ai/__init__.py +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/ai/client.py +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/api/__init__.py +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/auth/__init__.py +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/container/__init__.py +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/context/__init__.py +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/context/chunker.py +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/core/__init__.py +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/core/cache.py +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/core/constants.py +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/core/csp.py +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/core/events.py +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/core/port_takeover.py +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/core/rate_limiter.py +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/core/response.py +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/core/router.py +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/crud/__init__.py +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/database/__init__.py +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/database/adapter.py +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/database/async_api.py +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/database/connection.py +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/database/database_url.py +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/database/firebird.py +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/database/mongodb.py +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/database/mssql.py +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/database/mysql.py +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/database/odbc.py +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/database/pool.py +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/database/postgres.py +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/database/sql_translator.py +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/database/sqlite.py +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/debug/__init__.py +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/debug/error_overlay.py +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/dev_admin/project_index.py +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/docs.py +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/docstore/__init__.py +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/dotenv/__init__.py +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/env.py +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/frond/FROND.md +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/frond/__init__.py +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/frond/compiler.py +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/frond/parser.py +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/gallery/auth/meta.json +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/gallery/auth/src/routes/api/gallery_auth.py +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/gallery/database/meta.json +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/gallery/database/src/routes/api/gallery_db.py +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/gallery/error-overlay/meta.json +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/gallery/error-overlay/src/routes/api/gallery_crash.py +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/gallery/orm/meta.json +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/gallery/orm/src/orm/Product.py +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/gallery/orm/src/routes/api/gallery_products.py +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/gallery/queue/meta.json +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/gallery/queue/src/routes/api/gallery_queue.py +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/gallery/rest-api/meta.json +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/gallery/rest-api/src/routes/api/gallery_hello.py +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/gallery/templates/meta.json +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/gallery/templates/src/routes/gallery_page.py +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/gallery/templates/src/templates/gallery_page.twig +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/graph/__init__.py +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/graph/adapter.py +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/graph/adapters/__init__.py +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/graph/adapters/arango.py +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/graph/adapters/bolt.py +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/graph/adapters/ultipa.py +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/graph/graph_url.py +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/graphql/__init__.py +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/i18n/__init__.py +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/mcp/__init__.py +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/mcp/protocol.py +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/mcp/tools.py +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/messenger/__init__.py +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/migration/__init__.py +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/migration/runner.py +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/mqtt/__init__.py +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/mqtt/message.py +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/orm/__init__.py +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/orm/async_api.py +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/orm/collection.py +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/orm/fields.py +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/orm/model.py +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/orm/point.py +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/public/THIRD-PARTY-NOTICES.md +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/public/__feedback/widget.js +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/public/css/tina4.css +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/public/css/tina4.min.css +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/public/favicon.ico +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/public/images/logo.svg +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/public/images/tina4-logo-icon.webp +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/public/js/frond.js +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/public/js/frond.min.js +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/public/js/tina4.min.js +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/public/js/tina4js.min.js +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/public/licenses/swagger-ui-3.10.0-original-notice.txt +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/public/licenses/swagger-ui-5.17.14-NOTICE.txt +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/public/licenses/swagger-ui-Apache-2.0.txt +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/public/licenses/tina4-css-MIT.txt +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/public/licenses/tina4-dev-admin-components.json +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/public/licenses/tina4-dev-admin-third-party.txt +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/public/licenses/tina4-js-MIT.txt +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/public/swagger/index.html +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/public/swagger/oauth2-redirect.html +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/push/__init__.py +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/push/_base.py +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/push/_cryptography.py +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/push/_libcrypto.py +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/query_builder/__init__.py +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/queue/__init__.py +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/queue/amqp_url.py +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/queue/job.py +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/queue/kafka_backend.py +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/queue/lite_backend.py +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/queue/mongo_backend.py +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/queue/rabbitmq_backend.py +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/queue/topic_dead_letter.py +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/queue_backends/__init__.py +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/queue_backends/kafka_backend.py +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/queue_backends/mongo_backend.py +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/queue_backends/rabbitmq_backend.py +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/realtime/models/Attachment.py +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/realtime/models/Channel.py +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/realtime/models/ChannelMember.py +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/realtime/models/Message.py +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/realtime/models/Workspace.py +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/realtime/models/__init__.py +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/seeder/__init__.py +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/service/__init__.py +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/session/__init__.py +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/session_handlers/__init__.py +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/session_handlers/memcached_handler.py +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/session_handlers/mongodb_handler.py +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/session_handlers/redis_handler.py +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/session_handlers/valkey_handler.py +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/sso.py +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/ssrf.py +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/swagger/__init__.py +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/templates/components/crud.twig +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/templates/crud/modals.twig +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/templates/crud/page.twig +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/templates/docker/distroless/Dockerfile +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/templates/docker/poetry/Dockerfile +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/templates/docker/python/Dockerfile +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/templates/docker/uv/Dockerfile +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/templates/errors/401.twig +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/templates/errors/403.twig +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/templates/errors/404.twig +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/templates/errors/500.twig +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/templates/errors/502.twig +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/templates/errors/503.twig +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/templates/errors/base.twig +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/templates/frontend/README.md +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/templates/readme.md +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/test/__init__.py +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/test_client/__init__.py +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/translations/af/LC_MESSAGES/messages.mo +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/translations/af/LC_MESSAGES/messages.po +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/translations/en/LC_MESSAGES/messages.mo +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/translations/en/LC_MESSAGES/messages.po +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/translations/es/LC_MESSAGES/messages.mo +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/translations/es/LC_MESSAGES/messages.po +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/translations/fr/LC_MESSAGES/messages.mo +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/translations/fr/LC_MESSAGES/messages.po +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/translations/ja/LC_MESSAGES/messages.mo +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/translations/ja/LC_MESSAGES/messages.po +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/translations/zh/LC_MESSAGES/messages.mo +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/translations/zh/LC_MESSAGES/messages.po +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/validator/__init__.py +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/websocket/backplane.py +0 -0
- {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/wsdl/__init__.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: tina4-python
|
|
3
|
-
Version: 3.13.
|
|
3
|
+
Version: 3.13.151
|
|
4
4
|
Summary: Tina4 Python v3 — Zero-dependency, lightweight web framework
|
|
5
5
|
Author-email: Andre van Zuydam <andrevanzuydam@gmail.com>
|
|
6
6
|
License-Expression: MPL-2.0
|
|
@@ -12,7 +12,7 @@ Provides-Extra: all-db
|
|
|
12
12
|
Requires-Dist: firebird-driver>=1.10; extra == 'all-db'
|
|
13
13
|
Requires-Dist: mysql-connector-python>=9.0; extra == 'all-db'
|
|
14
14
|
Requires-Dist: psycopg2-binary>=2.9; extra == 'all-db'
|
|
15
|
-
Requires-Dist: pymongo>=4.
|
|
15
|
+
Requires-Dist: pymongo>=4.18.2; extra == 'all-db'
|
|
16
16
|
Requires-Dist: pymssql>=2.3; extra == 'all-db'
|
|
17
17
|
Requires-Dist: pyodbc>=5.0; extra == 'all-db'
|
|
18
18
|
Provides-Extra: arango
|
|
@@ -29,7 +29,7 @@ Requires-Dist: confluent-kafka>=2.0; extra == 'kafka'
|
|
|
29
29
|
Provides-Extra: memcache
|
|
30
30
|
Requires-Dist: pymemcache>=4.0; extra == 'memcache'
|
|
31
31
|
Provides-Extra: mongo
|
|
32
|
-
Requires-Dist: pymongo>=4.
|
|
32
|
+
Requires-Dist: pymongo>=4.18.2; extra == 'mongo'
|
|
33
33
|
Provides-Extra: mssql
|
|
34
34
|
Requires-Dist: pymssql>=2.3; extra == 'mssql'
|
|
35
35
|
Provides-Extra: mysql
|
|
@@ -47,9 +47,7 @@ Requires-Dist: pika>=1.3; extra == 'rabbitmq'
|
|
|
47
47
|
Provides-Extra: redis
|
|
48
48
|
Requires-Dist: redis>=5.0; extra == 'redis'
|
|
49
49
|
Provides-Extra: s3
|
|
50
|
-
Requires-Dist: boto3>=1.34; extra == 's3'
|
|
51
50
|
Provides-Extra: test
|
|
52
|
-
Requires-Dist: boto3>=1.34; extra == 'test'
|
|
53
51
|
Requires-Dist: confluent-kafka>=2.0; extra == 'test'
|
|
54
52
|
Requires-Dist: cryptography>=42.0; extra == 'test'
|
|
55
53
|
Requires-Dist: firebird-driver>=1.10; extra == 'test'
|
|
@@ -58,7 +56,7 @@ Requires-Dist: openapi-spec-validator>=0.7; extra == 'test'
|
|
|
58
56
|
Requires-Dist: pika>=1.3; extra == 'test'
|
|
59
57
|
Requires-Dist: psycopg2-binary>=2.9; extra == 'test'
|
|
60
58
|
Requires-Dist: pymemcache>=4.0; extra == 'test'
|
|
61
|
-
Requires-Dist: pymongo>=4.
|
|
59
|
+
Requires-Dist: pymongo>=4.18.2; extra == 'test'
|
|
62
60
|
Requires-Dist: pymssql>=2.3; extra == 'test'
|
|
63
61
|
Requires-Dist: pyodbc>=5.0; extra == 'test'
|
|
64
62
|
Requires-Dist: redis>=5.0; extra == 'test'
|
|
@@ -143,7 +141,7 @@ Open http://localhost:7146
|
|
|
143
141
|
|
|
144
142
|
---
|
|
145
143
|
|
|
146
|
-
## What's Built In (
|
|
144
|
+
## What's Built In (140 Features)
|
|
147
145
|
|
|
148
146
|
Every feature is built from scratch -- no pip install, no node_modules, no third-party runtime dependencies in core.
|
|
149
147
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "tina4-python"
|
|
3
|
-
version = "3.13.
|
|
3
|
+
version = "3.13.151"
|
|
4
4
|
description = "Tina4 Python v3 — Zero-dependency, lightweight web framework"
|
|
5
5
|
authors = [
|
|
6
6
|
{name = "Andre van Zuydam", email = "andrevanzuydam@gmail.com"}
|
|
@@ -19,7 +19,7 @@ postgres = ["psycopg2-binary>=2.9"]
|
|
|
19
19
|
mysql = ["mysql-connector-python>=9.0"]
|
|
20
20
|
mssql = ["pymssql>=2.3"]
|
|
21
21
|
firebird = ["firebird-driver>=1.10"]
|
|
22
|
-
mongo = ["pymongo>=4.
|
|
22
|
+
mongo = ["pymongo>=4.18.2"]
|
|
23
23
|
odbc = ["pyodbc>=5.0"]
|
|
24
24
|
|
|
25
25
|
# Graph engine drivers — install what you need (loaded lazily on first use).
|
|
@@ -33,10 +33,13 @@ graph = ["tina4-ultipa>=0.1", "protobuf>=7.35.1", "neo4j>=5.0", "python-arango>=
|
|
|
33
33
|
redis = ["redis>=5.0"]
|
|
34
34
|
memcache = ["pymemcache>=4.0"]
|
|
35
35
|
|
|
36
|
-
# File-storage backends
|
|
37
|
-
#
|
|
38
|
-
# (TINA4_STORAGE_BACKEND=s3)
|
|
39
|
-
|
|
36
|
+
# File-storage backends.
|
|
37
|
+
# Both shipped backends are zero-dependency: `local` (filesystem, the default)
|
|
38
|
+
# and `s3`/S3Storage (TINA4_STORAGE_BACKEND=s3), which talks to S3/MinIO/Garage
|
|
39
|
+
# through Tina4's own stdlib SigV4 client (tina4_python.realtime.s3_client) — no
|
|
40
|
+
# boto3. The extra is kept (empty) so `pip install tina4-python[s3]` still works;
|
|
41
|
+
# it installs nothing because S3 needs no driver.
|
|
42
|
+
s3 = []
|
|
40
43
|
|
|
41
44
|
# Queue backends — install what you need
|
|
42
45
|
kafka = ["confluent-kafka>=2.0"]
|
|
@@ -56,7 +59,7 @@ all-db = [
|
|
|
56
59
|
"mysql-connector-python>=9.0",
|
|
57
60
|
"pymssql>=2.3",
|
|
58
61
|
"firebird-driver>=1.10",
|
|
59
|
-
"pymongo>=4.
|
|
62
|
+
"pymongo>=4.18.2",
|
|
60
63
|
"pyodbc>=5.0",
|
|
61
64
|
]
|
|
62
65
|
|
|
@@ -75,28 +78,22 @@ all-db = [
|
|
|
75
78
|
# own: `uv sync --extra X` PRUNES anything outside the named extras, so a test
|
|
76
79
|
# extra that omitted it would silently uninstall it on a host that had it.
|
|
77
80
|
#
|
|
78
|
-
# boto3 is here
|
|
79
|
-
#
|
|
80
|
-
#
|
|
81
|
-
#
|
|
82
|
-
#
|
|
83
|
-
# "2 passed" to "2 skipped" -- with the suite still GREEN under
|
|
84
|
-
# TINA4_REQUIRE_SERVICES=1, because the skip reason matched neither a service
|
|
85
|
-
# keyword nor an unavailable hint in the conftest gate. Live S3 coverage
|
|
86
|
-
# evaporated silently. Declaring it here is the fix; tests/conftest.py now also
|
|
87
|
-
# recognises a missing boto3 so the gate can never miss it again.
|
|
81
|
+
# boto3 is NO LONGER here: S3Storage talks to S3 through Tina4's own stdlib
|
|
82
|
+
# SigV4 client, so the live-S3 tests in tests/test_realtime_files.py need no
|
|
83
|
+
# driver at all — only a reachable S3 server (MinIO/Garage). Removing boto3 also
|
|
84
|
+
# drops botocore + urllib3 + s3transfer + jmespath from the test tree, clearing
|
|
85
|
+
# the urllib3 advisories they carried.
|
|
88
86
|
test = [
|
|
89
87
|
"psycopg2-binary>=2.9",
|
|
90
88
|
"mysql-connector-python>=9.0",
|
|
91
89
|
"pymssql>=2.3",
|
|
92
90
|
"firebird-driver>=1.10",
|
|
93
|
-
"pymongo>=4.
|
|
91
|
+
"pymongo>=4.18.2",
|
|
94
92
|
"pyodbc>=5.0",
|
|
95
93
|
"redis>=5.0",
|
|
96
94
|
"pymemcache>=4.0",
|
|
97
95
|
"confluent-kafka>=2.0",
|
|
98
96
|
"pika>=1.3",
|
|
99
|
-
"boto3>=1.34",
|
|
100
97
|
# TEST-ONLY: validates the generated OpenAPI document against the real
|
|
101
98
|
# OpenAPI 3.0/3.1 schema (tests/test_swagger_contract.py). NEVER a framework
|
|
102
99
|
# runtime dependency — the swagger generator itself stays zero-dependency.
|
|
@@ -477,7 +477,8 @@ async def protected_get(request, response):
|
|
|
477
477
|
|
|
478
478
|
```python
|
|
479
479
|
request.body # Parsed request body (dict for JSON, dict for form data)
|
|
480
|
-
request.params #
|
|
480
|
+
request.params # ROUTE params ONLY (the {id} segments) — never query/body
|
|
481
|
+
request.query # Query string parameters (dict) — read ?q=, ?page= here
|
|
481
482
|
request.headers # HTTP headers (dict, lowercase keys)
|
|
482
483
|
request.files # Uploaded files (dict, values are base64-encoded dicts)
|
|
483
484
|
request.url # Request URL path
|
|
@@ -1418,7 +1418,8 @@ class ResponseCache:
|
|
|
1418
1418
|
Authorization, and Tina4's own session mechanism IS a cookie. Because
|
|
1419
1419
|
the key is method + URL, storing such a response replays one signed-in
|
|
1420
1420
|
user's page to whoever asks for that URL next. A response that installs
|
|
1421
|
-
a session is per-user by construction for the same reason
|
|
1421
|
+
a session is per-user by construction for the same reason, whether it
|
|
1422
|
+
already carries the Set-Cookie or the session is about to add it.
|
|
1422
1423
|
|
|
1423
1424
|
Both cookie cases stay cacheable when the response opts in explicitly with
|
|
1424
1425
|
a shared-cache directive, which is how a genuinely public page served to
|
|
@@ -1435,6 +1436,13 @@ class ResponseCache:
|
|
|
1435
1436
|
return _shared_cache_allowed(response)
|
|
1436
1437
|
if _header_value(response, "Set-Cookie") is not None:
|
|
1437
1438
|
return _shared_cache_allowed(response)
|
|
1439
|
+
# The session cookie is added after this check, so a response that is
|
|
1440
|
+
# about to install one carries no Set-Cookie yet: a request that came
|
|
1441
|
+
# without a cookie and leaves its session holding data (a form token
|
|
1442
|
+
# bound to it marks it) is that case.
|
|
1443
|
+
session = getattr(request, "session", None)
|
|
1444
|
+
if session is not None and not session.is_fresh():
|
|
1445
|
+
return _shared_cache_allowed(response)
|
|
1438
1446
|
return True
|
|
1439
1447
|
|
|
1440
1448
|
@staticmethod
|
|
@@ -1652,8 +1652,8 @@ def _generate(args):
|
|
|
1652
1652
|
|
|
1653
1653
|
what = args[0].lower()
|
|
1654
1654
|
|
|
1655
|
-
#
|
|
1656
|
-
no_name_generators = {"auth"}
|
|
1655
|
+
# These generators take no name argument.
|
|
1656
|
+
no_name_generators = {"auth", "base"}
|
|
1657
1657
|
if what not in no_name_generators and len(args) < 2:
|
|
1658
1658
|
print(f"Usage: tina4python generate {what} <name> [options]")
|
|
1659
1659
|
sys.exit(1)
|
|
@@ -3352,6 +3352,127 @@ def _gen_form(name: str, flags: dict = None):
|
|
|
3352
3352
|
print(f" ✓ Created {path}")
|
|
3353
3353
|
|
|
3354
3354
|
|
|
3355
|
+
_BASE_TWIG = '''<!DOCTYPE html>
|
|
3356
|
+
<html lang="en">
|
|
3357
|
+
<head>
|
|
3358
|
+
<meta charset="UTF-8">
|
|
3359
|
+
<title>{% block title %}{{ APP_NAME }}{% endblock %}</title>
|
|
3360
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
3361
|
+
<link rel="stylesheet" href="/css/tina4.min.css">
|
|
3362
|
+
<link rel="stylesheet" href="/css/default.css">
|
|
3363
|
+
{% block stylesheets %}{% endblock %}
|
|
3364
|
+
</head>
|
|
3365
|
+
<body>
|
|
3366
|
+
{% block nav %}{% include "partials/nav.twig" ignore missing %}{% endblock %}
|
|
3367
|
+
<main>{% block content %}{% endblock %}</main>
|
|
3368
|
+
{% block javascripts %}
|
|
3369
|
+
<script src="/js/tina4.min.js"></script>
|
|
3370
|
+
<script src="/js/frond.min.js"></script>
|
|
3371
|
+
{% endblock %}
|
|
3372
|
+
</body>
|
|
3373
|
+
</html>
|
|
3374
|
+
'''
|
|
3375
|
+
|
|
3376
|
+
|
|
3377
|
+
def _ensure_base_template():
|
|
3378
|
+
"""Create src/templates/base.twig and the src/templates/pages/ folder if
|
|
3379
|
+
missing. Returns the paths created (empty when everything already existed).
|
|
3380
|
+
Shared by `generate base` and `generate page` so a page can be scaffolded
|
|
3381
|
+
into a fresh project and still inherit from a real base."""
|
|
3382
|
+
created = []
|
|
3383
|
+
templates = Path("src/templates")
|
|
3384
|
+
templates.mkdir(parents=True, exist_ok=True)
|
|
3385
|
+
(templates / "pages").mkdir(parents=True, exist_ok=True)
|
|
3386
|
+
base = templates / "base.twig"
|
|
3387
|
+
if not base.exists():
|
|
3388
|
+
base.write_text(_BASE_TWIG, encoding="utf-8")
|
|
3389
|
+
created.append(str(base))
|
|
3390
|
+
return created
|
|
3391
|
+
|
|
3392
|
+
|
|
3393
|
+
def _page_twig(title: str) -> str:
|
|
3394
|
+
"""A Frond page template that extends base.twig (Twig braces kept literal)."""
|
|
3395
|
+
return (
|
|
3396
|
+
'{% extends "base.twig" %}\n'
|
|
3397
|
+
'{% block title %}' + title + '{% endblock %}\n'
|
|
3398
|
+
'{% block content %}\n'
|
|
3399
|
+
'<div class="container mt-4">\n'
|
|
3400
|
+
' <h1>' + title + '</h1>\n'
|
|
3401
|
+
' {# tina4:edit page content goes here #}\n'
|
|
3402
|
+
'</div>\n'
|
|
3403
|
+
'{% endblock %}\n'
|
|
3404
|
+
)
|
|
3405
|
+
|
|
3406
|
+
|
|
3407
|
+
def _page_route(url_path: str, template_name: str, fn_name: str, title: str) -> str:
|
|
3408
|
+
"""A route that renders a page template through the @template decorator."""
|
|
3409
|
+
return (
|
|
3410
|
+
"from tina4_python.core.router import get, template\n\n\n"
|
|
3411
|
+
'@get("' + url_path + '")\n'
|
|
3412
|
+
'@template("' + template_name + '")\n'
|
|
3413
|
+
"async def " + fn_name + "(request, response):\n"
|
|
3414
|
+
' return {"title": "' + title + '"}\n'
|
|
3415
|
+
)
|
|
3416
|
+
|
|
3417
|
+
|
|
3418
|
+
def _gen_base(name: str = None, flags: dict = None):
|
|
3419
|
+
"""Scaffold a Frond base template + an index page that extends it.
|
|
3420
|
+
|
|
3421
|
+
tina4python generate base
|
|
3422
|
+
|
|
3423
|
+
Creates src/templates/base.twig (if missing), the src/templates/pages/
|
|
3424
|
+
folder, src/templates/pages/index.twig (extends base), and the `/` route
|
|
3425
|
+
that renders it. Subsequent `generate page <name>` pages inherit from base.
|
|
3426
|
+
"""
|
|
3427
|
+
created = _ensure_base_template()
|
|
3428
|
+
index_tpl = Path("src/templates/pages/index.twig")
|
|
3429
|
+
if not index_tpl.exists():
|
|
3430
|
+
index_tpl.write_text(_page_twig("Home"), encoding="utf-8")
|
|
3431
|
+
created.append(str(index_tpl))
|
|
3432
|
+
routes = Path("src/routes")
|
|
3433
|
+
routes.mkdir(parents=True, exist_ok=True)
|
|
3434
|
+
index_route = routes / "index.py"
|
|
3435
|
+
if not index_route.exists():
|
|
3436
|
+
index_route.write_text(_page_route("/", "pages/index.twig", "index_page", "Home"), encoding="utf-8")
|
|
3437
|
+
created.append(str(index_route))
|
|
3438
|
+
if created:
|
|
3439
|
+
for p in created:
|
|
3440
|
+
print(f" ✓ Created {p}")
|
|
3441
|
+
else:
|
|
3442
|
+
print(" ✓ base template + index page already present")
|
|
3443
|
+
|
|
3444
|
+
|
|
3445
|
+
def _gen_page(name: str, flags: dict = None):
|
|
3446
|
+
"""Scaffold a page that inherits from the Frond base template.
|
|
3447
|
+
|
|
3448
|
+
tina4python generate page about
|
|
3449
|
+
|
|
3450
|
+
Creates src/templates/pages/<name>.twig (extends base.twig) and a route that
|
|
3451
|
+
renders it. Auto-creates the pages/ folder and bootstraps base.twig when they
|
|
3452
|
+
do not exist yet, so a page always inherits from a real base.
|
|
3453
|
+
"""
|
|
3454
|
+
slug = _to_snake(name or "").strip("/")
|
|
3455
|
+
if not slug:
|
|
3456
|
+
print(" ✗ page needs a name (e.g. generate page about)")
|
|
3457
|
+
return
|
|
3458
|
+
title = slug.replace("_", " ").title()
|
|
3459
|
+
created = _ensure_base_template()
|
|
3460
|
+
tpl = Path("src/templates/pages") / f"{slug}.twig"
|
|
3461
|
+
if tpl.exists():
|
|
3462
|
+
print(f" ✗ File already exists: {tpl}")
|
|
3463
|
+
return
|
|
3464
|
+
tpl.write_text(_page_twig(title), encoding="utf-8")
|
|
3465
|
+
created.append(str(tpl))
|
|
3466
|
+
routes = Path("src/routes")
|
|
3467
|
+
routes.mkdir(parents=True, exist_ok=True)
|
|
3468
|
+
route = routes / f"{slug}.py"
|
|
3469
|
+
if not route.exists():
|
|
3470
|
+
route.write_text(_page_route(f"/{slug}", f"pages/{slug}.twig", f"{slug}_page", title), encoding="utf-8")
|
|
3471
|
+
created.append(str(route))
|
|
3472
|
+
for p in created:
|
|
3473
|
+
print(f" ✓ Created {p}")
|
|
3474
|
+
|
|
3475
|
+
|
|
3355
3476
|
def _gen_view(name: str, flags: dict = None):
|
|
3356
3477
|
"""Generate list + detail view templates.
|
|
3357
3478
|
|
|
@@ -3912,6 +4033,8 @@ def _commands(args=None):
|
|
|
3912
4033
|
GENERATORS = {
|
|
3913
4034
|
"model": {"handler": _gen_model, "usage": '<Name> [--fields "name:string,price:float"] [--table-name <name>]', "summary": "ORM model + matching migration"},
|
|
3914
4035
|
"route": {"handler": _gen_route, "usage": "<name> [--model Name] [--public]", "summary": "CRUD route file, secure by default (--public opens writes)"},
|
|
4036
|
+
"base": {"handler": _gen_base, "usage": "", "summary": "Frond base template + index page + pages/ folder"},
|
|
4037
|
+
"page": {"handler": _gen_page, "usage": "<name>", "summary": "Page that extends base.twig (auto-creates pages/ + base)"},
|
|
3915
4038
|
"crud": {"handler": _gen_crud, "usage": '<Name> [--fields "..."] [--public] [--no-templates]', "summary": "Model + migration + AutoCrud-backed admin page (to_crud) + editable crud/ templates + gate test"},
|
|
3916
4039
|
"migration": {"handler": _gen_migration, "usage": "<description>", "summary": "Timestamped migration file (UP/DOWN)"},
|
|
3917
4040
|
"middleware": {"handler": _gen_middleware, "usage": "<Name>", "summary": "Middleware with before/after hooks"},
|
|
@@ -589,6 +589,7 @@ class SecurityHeadersMiddleware:
|
|
|
589
589
|
TINA4_CSP — Content-Security-Policy (default: "default-src 'self'")
|
|
590
590
|
TINA4_REFERRER_POLICY — Referrer-Policy (default: strict-origin-when-cross-origin)
|
|
591
591
|
TINA4_PERMISSIONS_POLICY — Permissions-Policy (default: camera=(), microphone=(), geolocation=())
|
|
592
|
+
TINA4_COOP — Cross-Origin-Opener-Policy (default: same-origin-allow-popups)
|
|
592
593
|
"""
|
|
593
594
|
|
|
594
595
|
@staticmethod
|
|
@@ -647,6 +648,20 @@ class SecurityHeadersMiddleware:
|
|
|
647
648
|
"camera=(), microphone=(), geolocation=()",
|
|
648
649
|
),
|
|
649
650
|
)
|
|
651
|
+
# Cross-Origin-Opener-Policy severs the window-reference link to a
|
|
652
|
+
# cross-origin page, closing reverse-tab-nabbing and cross-window
|
|
653
|
+
# XS-Leaks that X-Frame-Options (framing only) does not. The default is
|
|
654
|
+
# same-origin-allow-popups, NOT same-origin: it isolates the page from
|
|
655
|
+
# whoever opened it while still letting the page talk to popups IT opens,
|
|
656
|
+
# so an OAuth / OIDC / payment popup that posts a token back to its opener
|
|
657
|
+
# keeps working out of the box. Set TINA4_COOP=same-origin for full
|
|
658
|
+
# isolation (the switch, with COEP, for crossOriginIsolated), or
|
|
659
|
+
# unsafe-none to opt out. Honoured only in a secure context — so it
|
|
660
|
+
# applies on https and on http://localhost, and is inert elsewhere.
|
|
661
|
+
response.header(
|
|
662
|
+
"Cross-Origin-Opener-Policy",
|
|
663
|
+
os.environ.get("TINA4_COOP", "same-origin-allow-popups"),
|
|
664
|
+
)
|
|
650
665
|
|
|
651
666
|
return request, response
|
|
652
667
|
|
|
@@ -12,7 +12,8 @@ import functools
|
|
|
12
12
|
import ipaddress
|
|
13
13
|
import json
|
|
14
14
|
import os
|
|
15
|
-
|
|
15
|
+
import re
|
|
16
|
+
from urllib.parse import parse_qs, parse_qsl, unquote
|
|
16
17
|
|
|
17
18
|
from tina4_python.env import _log_warning
|
|
18
19
|
|
|
@@ -519,8 +520,7 @@ def _parse_body(body: bytes, content_type: str) -> dict | str | None:
|
|
|
519
520
|
return body.decode(errors="replace")
|
|
520
521
|
|
|
521
522
|
if "application/x-www-form-urlencoded" in content_type:
|
|
522
|
-
|
|
523
|
-
return {k: v[0] if len(v) == 1 else v for k, v in parsed.items()}
|
|
523
|
+
return _nest_form_fields(parse_qsl(body.decode(), keep_blank_values=True))
|
|
524
524
|
|
|
525
525
|
if "multipart/form-data" in content_type:
|
|
526
526
|
return _parse_multipart(body, content_type)
|
|
@@ -539,6 +539,7 @@ def _parse_multipart(body: bytes, content_type: str) -> dict:
|
|
|
539
539
|
that may contain the boundary string in their content.
|
|
540
540
|
"""
|
|
541
541
|
result = {}
|
|
542
|
+
fields: list[tuple[str, str]] = []
|
|
542
543
|
|
|
543
544
|
# Extract boundary
|
|
544
545
|
boundary = None
|
|
@@ -631,12 +632,174 @@ def _parse_multipart(body: bytes, content_type: str) -> dict:
|
|
|
631
632
|
else:
|
|
632
633
|
result[name] = descriptor
|
|
633
634
|
else:
|
|
634
|
-
|
|
635
|
+
fields.append((name, content.decode(errors="replace")))
|
|
635
636
|
|
|
636
637
|
if is_last:
|
|
637
638
|
break
|
|
638
639
|
|
|
639
|
-
|
|
640
|
+
# Text fields nest after the loop. One named after a file field
|
|
641
|
+
# (``photo[caption]`` beside a ``photo`` upload) keeps its flat key, so it
|
|
642
|
+
# never collides with the file (files are separated out by key afterwards).
|
|
643
|
+
return {**_nest_form_fields(fields, reserved=frozenset(result)), **result}
|
|
644
|
+
|
|
645
|
+
|
|
646
|
+
# A field name nested deeper than this keeps its flat key. Rack's
|
|
647
|
+
# param_depth_limit, the same limit tina4-ruby's form parser applies.
|
|
648
|
+
_FORM_DEPTH_LIMIT = 32
|
|
649
|
+
|
|
650
|
+
# A form with more fields than this is not nested at all, so a crafted body
|
|
651
|
+
# cannot turn each small field into a deep structure. Rack's params_limit.
|
|
652
|
+
_FORM_FIELD_LIMIT = 4096
|
|
653
|
+
|
|
654
|
+
# A field name longer than this keeps its flat key, so nesting never copies a
|
|
655
|
+
# huge name once per level.
|
|
656
|
+
_FORM_NAME_LIMIT = 1024
|
|
657
|
+
|
|
658
|
+
|
|
659
|
+
class _FormNestError(ValueError):
|
|
660
|
+
"""A field name that is both a value and a container."""
|
|
661
|
+
|
|
662
|
+
|
|
663
|
+
class _Nested(dict):
|
|
664
|
+
"""A dict built by nesting, as opposed to a value that happens to be one."""
|
|
665
|
+
|
|
666
|
+
|
|
667
|
+
def _nest_form_fields(pairs, reserved=frozenset()) -> dict:
|
|
668
|
+
"""Nest ``(name, value)`` form pairs the way PHP and Rack nest a form.
|
|
669
|
+
|
|
670
|
+
``tags[]`` collects a list, ``user[name]`` builds a dict, ``a[][x]`` a list
|
|
671
|
+
of dicts, and a repeated plain name keeps every value as a list. Used for
|
|
672
|
+
urlencoded and multipart bodies alike, so a form arrives in one shape
|
|
673
|
+
however it was encoded. A field that cannot nest - its name conflicts with
|
|
674
|
+
an earlier one (``a=1`` then ``a[b]=2``), nests too deep, is longer than
|
|
675
|
+
``_FORM_NAME_LIMIT``, or starts with a ``reserved`` name (a file field's) -
|
|
676
|
+
keeps its flat key; the rest still nest. A later plain name replaces a dict
|
|
677
|
+
of that name, as Rack and parse_str do, and joins a list.
|
|
678
|
+
"""
|
|
679
|
+
params = _Nested()
|
|
680
|
+
if len(pairs) > _FORM_FIELD_LIMIT:
|
|
681
|
+
for name, value in pairs:
|
|
682
|
+
_append_value(params, name, value)
|
|
683
|
+
return _plain(params)
|
|
684
|
+
for name, value in pairs:
|
|
685
|
+
base = name.split("[", 1)[0] if name.find("[", 1) != -1 else name
|
|
686
|
+
if base in reserved or len(name) > _FORM_NAME_LIMIT or name.count("[") >= _FORM_DEPTH_LIMIT:
|
|
687
|
+
_append_value(params, name, value)
|
|
688
|
+
continue
|
|
689
|
+
try:
|
|
690
|
+
_nest_one(params, name, value, 0)
|
|
691
|
+
except _FormNestError:
|
|
692
|
+
_append_value(params, name, value)
|
|
693
|
+
return _plain(params)
|
|
694
|
+
|
|
695
|
+
|
|
696
|
+
def _append_value(params: dict, key: str, value) -> None:
|
|
697
|
+
"""Store a plain field; a repeat turns it into a list of every value."""
|
|
698
|
+
if key not in params:
|
|
699
|
+
params[key] = value
|
|
700
|
+
elif isinstance(params[key], _RepeatedValues):
|
|
701
|
+
params[key].append(value)
|
|
702
|
+
else:
|
|
703
|
+
params[key] = _RepeatedValues([params[key], value])
|
|
704
|
+
|
|
705
|
+
|
|
706
|
+
class _RepeatedValues(list):
|
|
707
|
+
"""The values of a repeated plain field name (``p=1&p=2``)."""
|
|
708
|
+
|
|
709
|
+
|
|
710
|
+
def _nest_one(params: dict, name: str, value, depth: int):
|
|
711
|
+
"""Rack::QueryParser#normalize_params, ported from tina4-ruby's form parser.
|
|
712
|
+
|
|
713
|
+
It raises where Rack raises on a conflict; a plain name after a list of
|
|
714
|
+
that name joins the list, where Rack would replace it.
|
|
715
|
+
"""
|
|
716
|
+
key, after = _split_field_name(name, depth)
|
|
717
|
+
if not key:
|
|
718
|
+
return None
|
|
719
|
+
if not after:
|
|
720
|
+
return _nest_leaf(params, key, value, depth)
|
|
721
|
+
if after == "[":
|
|
722
|
+
params[name] = value
|
|
723
|
+
elif after == "[]":
|
|
724
|
+
_list_at(params, key).append(value)
|
|
725
|
+
elif after.startswith("[]"):
|
|
726
|
+
_nest_list_item(_list_at(params, key), after, value, depth)
|
|
727
|
+
else:
|
|
728
|
+
current = params.setdefault(key, _Nested())
|
|
729
|
+
if not isinstance(current, _Nested):
|
|
730
|
+
raise _FormNestError(f"expected a dict for {key!r}")
|
|
731
|
+
params[key] = _nest_one(current, after, value, depth + 1)
|
|
732
|
+
return params
|
|
733
|
+
|
|
734
|
+
|
|
735
|
+
def _split_field_name(name: str, depth: int) -> tuple[str, str]:
|
|
736
|
+
"""The next key of a field name, and the bracketed rest after it."""
|
|
737
|
+
if depth == 0:
|
|
738
|
+
start = name.find("[", 1)
|
|
739
|
+
return (name[:start], name[start:]) if start != -1 else (name, "")
|
|
740
|
+
if name.startswith("[]"):
|
|
741
|
+
return "[]", name[2:]
|
|
742
|
+
close = name.find("]", 1)
|
|
743
|
+
if name.startswith("[") and close != -1:
|
|
744
|
+
return name[1:close], name[close + 1:]
|
|
745
|
+
return name, ""
|
|
746
|
+
|
|
747
|
+
|
|
748
|
+
def _nest_leaf(params: dict, key: str, value, depth: int):
|
|
749
|
+
if key == "[]" and depth:
|
|
750
|
+
return [value]
|
|
751
|
+
if depth:
|
|
752
|
+
params[key] = value
|
|
753
|
+
return params
|
|
754
|
+
# A plain name after a list of that name joins the list (``tags[]=1&tags=2``);
|
|
755
|
+
# after a dict it replaces it, as Rack and parse_str do.
|
|
756
|
+
existing = params.get(key)
|
|
757
|
+
if isinstance(existing, list) and not isinstance(existing, _RepeatedValues):
|
|
758
|
+
existing.append(value)
|
|
759
|
+
elif isinstance(existing, _Nested):
|
|
760
|
+
params[key] = value
|
|
761
|
+
else:
|
|
762
|
+
_append_value(params, key, value)
|
|
763
|
+
return params
|
|
764
|
+
|
|
765
|
+
|
|
766
|
+
def _list_at(params: dict, key: str) -> list:
|
|
767
|
+
current = params.setdefault(key, [])
|
|
768
|
+
if not isinstance(current, list) or isinstance(current, _RepeatedValues):
|
|
769
|
+
raise _FormNestError(f"expected a list for {key!r}")
|
|
770
|
+
return current
|
|
771
|
+
|
|
772
|
+
|
|
773
|
+
def _nest_list_item(items: list, after: str, value, depth: int) -> None:
|
|
774
|
+
"""``a[][x]``: fill the last record unless it already has ``x``, else start one."""
|
|
775
|
+
child_key = after[3:-1] if after[2:3] == "[" and after.endswith("]") else ""
|
|
776
|
+
if not child_key or "[" in child_key or "]" in child_key:
|
|
777
|
+
child_key = after[2:]
|
|
778
|
+
last = items[-1] if items else None
|
|
779
|
+
if isinstance(last, _Nested) and not _has_nested_key(last, child_key):
|
|
780
|
+
_nest_one(last, child_key, value, depth + 1)
|
|
781
|
+
else:
|
|
782
|
+
items.append(_nest_one(_Nested(), child_key, value, depth + 1))
|
|
783
|
+
|
|
784
|
+
|
|
785
|
+
def _has_nested_key(params: dict, key: str) -> bool:
|
|
786
|
+
if "[]" in key:
|
|
787
|
+
return False
|
|
788
|
+
level = params
|
|
789
|
+
for part in [p for p in re.split(r"[\[\]]+", key) if p]:
|
|
790
|
+
if not isinstance(level, _Nested) or part not in level:
|
|
791
|
+
return False
|
|
792
|
+
level = level[part]
|
|
793
|
+
return True
|
|
794
|
+
|
|
795
|
+
|
|
796
|
+
def _plain(value):
|
|
797
|
+
"""Turn the nesting markers back into ordinary dicts and lists."""
|
|
798
|
+
if isinstance(value, dict):
|
|
799
|
+
return {k: _plain(v) for k, v in value.items()}
|
|
800
|
+
if isinstance(value, list):
|
|
801
|
+
return [_plain(v) for v in value]
|
|
802
|
+
return value
|
|
640
803
|
|
|
641
804
|
|
|
642
805
|
def _is_file_value(value) -> bool:
|
|
@@ -646,11 +809,11 @@ def _is_file_value(value) -> bool:
|
|
|
646
809
|
non-empty list of such descriptors (a repeated field name). Everything else
|
|
647
810
|
is a plain form field.
|
|
648
811
|
"""
|
|
649
|
-
if isinstance(value, dict):
|
|
650
|
-
return "filename" in value
|
|
651
812
|
if isinstance(value, list):
|
|
652
|
-
return bool(value) and
|
|
653
|
-
|
|
813
|
+
return bool(value) and _is_file_value(value[0])
|
|
814
|
+
# Content is bytes only on a real upload; a nested text field such as
|
|
815
|
+
# doc[filename]=x is a dict too, but every value in it is a str.
|
|
816
|
+
return isinstance(value, dict) and "filename" in value and isinstance(value.get("content"), bytes)
|
|
654
817
|
|
|
655
818
|
|
|
656
819
|
def save_upload(file: dict, target_dir: str, filename: str | None = None) -> str:
|
|
@@ -683,7 +846,7 @@ def save_upload(file: dict, target_dir: str, filename: str | None = None) -> str
|
|
|
683
846
|
os.makedirs(target_dir, exist_ok=True)
|
|
684
847
|
dest = os.path.join(target_dir, base)
|
|
685
848
|
# Defence in depth: the resolved parent of the destination must be exactly
|
|
686
|
-
# the resolved target dir
|
|
849
|
+
# the resolved target dir.
|
|
687
850
|
real_dir = os.path.realpath(target_dir)
|
|
688
851
|
real_parent = os.path.realpath(os.path.dirname(dest))
|
|
689
852
|
if real_parent != real_dir:
|
|
@@ -691,6 +854,22 @@ def save_upload(file: dict, target_dir: str, filename: str | None = None) -> str
|
|
|
691
854
|
content = file.get("content", b"")
|
|
692
855
|
if isinstance(content, str):
|
|
693
856
|
content = content.encode()
|
|
694
|
-
|
|
857
|
+
# Never write THROUGH a link already at target/base: a symlink (even a
|
|
858
|
+
# dangling one) leads out of target_dir, and a hard link shares its bytes
|
|
859
|
+
# with a file elsewhere. Such an entry is removed so the upload gets a file
|
|
860
|
+
# of its own; a plain file is rewritten in place and keeps its mode.
|
|
861
|
+
if os.path.islink(dest):
|
|
862
|
+
os.unlink(dest)
|
|
863
|
+
flags = os.O_WRONLY | os.O_CREAT | getattr(os, "O_NOFOLLOW", 0) | getattr(os, "O_BINARY", 0)
|
|
864
|
+
# 0o600: an uploaded file is created owner-only, never group/other readable
|
|
865
|
+
# or writable (CWE-732). The mode applies only when O_CREAT makes the file;
|
|
866
|
+
# a plain file rewritten in place keeps its own mode, per the note above.
|
|
867
|
+
fd = os.open(dest, flags, 0o600)
|
|
868
|
+
if os.fstat(fd).st_nlink > 1:
|
|
869
|
+
os.close(fd)
|
|
870
|
+
os.unlink(dest)
|
|
871
|
+
fd = os.open(dest, flags | os.O_EXCL, 0o600)
|
|
872
|
+
with os.fdopen(fd, "wb") as handle:
|
|
873
|
+
handle.truncate(0)
|
|
695
874
|
handle.write(content)
|
|
696
875
|
return dest
|