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.
Files changed (203) hide show
  1. {tina4_python-3.13.149 → tina4_python-3.13.151}/PKG-INFO +5 -7
  2. {tina4_python-3.13.149 → tina4_python-3.13.151}/README.md +1 -1
  3. {tina4_python-3.13.149 → tina4_python-3.13.151}/pyproject.toml +16 -19
  4. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/CLAUDE.md +2 -1
  5. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/__init__.py +1 -1
  6. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/cache/__init__.py +9 -1
  7. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/cli/__init__.py +125 -2
  8. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/core/middleware.py +15 -0
  9. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/core/request.py +190 -11
  10. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/core/server.py +47 -4
  11. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/crud/page.py +1 -1
  12. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/crud/page_render.py +5 -5
  13. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/dev_admin/__init__.py +153 -117
  14. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/dev_admin/metrics.py +5 -1
  15. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/dev_admin/plan.py +1 -1
  16. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/frond/engine.py +174 -11
  17. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/public/bundled-component-provenance.json +2 -2
  18. tina4_python-3.13.151/tina4_python/public/js/tina4-dev-admin-split.html +202 -0
  19. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/public/js/tina4-dev-admin.min.js +147 -138
  20. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/realtime/__init__.py +15 -4
  21. tina4_python-3.13.151/tina4_python/realtime/s3_client.py +255 -0
  22. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/realtime/storage.py +18 -27
  23. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/templates/crud/form.twig +5 -5
  24. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/templates/crud/table.twig +2 -2
  25. tina4_python-3.13.151/tina4_python/templates/errors/302.twig +23 -0
  26. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/websocket/__init__.py +6 -3
  27. tina4_python-3.13.149/tina4_python/templates/errors/302.twig +0 -22
  28. {tina4_python-3.13.149 → tina4_python-3.13.151}/.gitignore +0 -0
  29. {tina4_python-3.13.149 → tina4_python-3.13.151}/COMMERCIAL-LICENSE.md +0 -0
  30. {tina4_python-3.13.149 → tina4_python-3.13.151}/LICENSE +0 -0
  31. {tina4_python-3.13.149 → tina4_python-3.13.151}/NOTICE +0 -0
  32. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/.tina4-metrics.json +0 -0
  33. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/HtmlElement.py +0 -0
  34. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/Testing.py +0 -0
  35. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/_import_helper.py +0 -0
  36. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/ai/__init__.py +0 -0
  37. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/ai/client.py +0 -0
  38. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/api/__init__.py +0 -0
  39. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/auth/__init__.py +0 -0
  40. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/container/__init__.py +0 -0
  41. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/context/__init__.py +0 -0
  42. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/context/chunker.py +0 -0
  43. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/core/__init__.py +0 -0
  44. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/core/cache.py +0 -0
  45. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/core/constants.py +0 -0
  46. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/core/csp.py +0 -0
  47. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/core/events.py +0 -0
  48. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/core/port_takeover.py +0 -0
  49. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/core/rate_limiter.py +0 -0
  50. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/core/response.py +0 -0
  51. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/core/router.py +0 -0
  52. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/crud/__init__.py +0 -0
  53. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/database/__init__.py +0 -0
  54. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/database/adapter.py +0 -0
  55. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/database/async_api.py +0 -0
  56. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/database/connection.py +0 -0
  57. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/database/database_url.py +0 -0
  58. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/database/firebird.py +0 -0
  59. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/database/mongodb.py +0 -0
  60. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/database/mssql.py +0 -0
  61. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/database/mysql.py +0 -0
  62. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/database/odbc.py +0 -0
  63. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/database/pool.py +0 -0
  64. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/database/postgres.py +0 -0
  65. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/database/sql_translator.py +0 -0
  66. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/database/sqlite.py +0 -0
  67. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/debug/__init__.py +0 -0
  68. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/debug/error_overlay.py +0 -0
  69. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/dev_admin/project_index.py +0 -0
  70. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/docs.py +0 -0
  71. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/docstore/__init__.py +0 -0
  72. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/dotenv/__init__.py +0 -0
  73. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/env.py +0 -0
  74. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/frond/FROND.md +0 -0
  75. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/frond/__init__.py +0 -0
  76. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/frond/compiler.py +0 -0
  77. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/frond/parser.py +0 -0
  78. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/gallery/auth/meta.json +0 -0
  79. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/gallery/auth/src/routes/api/gallery_auth.py +0 -0
  80. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/gallery/database/meta.json +0 -0
  81. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/gallery/database/src/routes/api/gallery_db.py +0 -0
  82. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/gallery/error-overlay/meta.json +0 -0
  83. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/gallery/error-overlay/src/routes/api/gallery_crash.py +0 -0
  84. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/gallery/orm/meta.json +0 -0
  85. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/gallery/orm/src/orm/Product.py +0 -0
  86. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/gallery/orm/src/routes/api/gallery_products.py +0 -0
  87. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/gallery/queue/meta.json +0 -0
  88. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/gallery/queue/src/routes/api/gallery_queue.py +0 -0
  89. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/gallery/rest-api/meta.json +0 -0
  90. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/gallery/rest-api/src/routes/api/gallery_hello.py +0 -0
  91. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/gallery/templates/meta.json +0 -0
  92. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/gallery/templates/src/routes/gallery_page.py +0 -0
  93. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/gallery/templates/src/templates/gallery_page.twig +0 -0
  94. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/graph/__init__.py +0 -0
  95. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/graph/adapter.py +0 -0
  96. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/graph/adapters/__init__.py +0 -0
  97. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/graph/adapters/arango.py +0 -0
  98. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/graph/adapters/bolt.py +0 -0
  99. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/graph/adapters/ultipa.py +0 -0
  100. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/graph/graph_url.py +0 -0
  101. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/graphql/__init__.py +0 -0
  102. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/i18n/__init__.py +0 -0
  103. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/mcp/__init__.py +0 -0
  104. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/mcp/protocol.py +0 -0
  105. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/mcp/tools.py +0 -0
  106. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/messenger/__init__.py +0 -0
  107. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/migration/__init__.py +0 -0
  108. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/migration/runner.py +0 -0
  109. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/mqtt/__init__.py +0 -0
  110. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/mqtt/message.py +0 -0
  111. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/orm/__init__.py +0 -0
  112. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/orm/async_api.py +0 -0
  113. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/orm/collection.py +0 -0
  114. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/orm/fields.py +0 -0
  115. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/orm/model.py +0 -0
  116. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/orm/point.py +0 -0
  117. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/public/THIRD-PARTY-NOTICES.md +0 -0
  118. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/public/__feedback/widget.js +0 -0
  119. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/public/css/tina4.css +0 -0
  120. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/public/css/tina4.min.css +0 -0
  121. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/public/favicon.ico +0 -0
  122. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/public/images/logo.svg +0 -0
  123. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/public/images/tina4-logo-icon.webp +0 -0
  124. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/public/js/frond.js +0 -0
  125. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/public/js/frond.min.js +0 -0
  126. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/public/js/tina4.min.js +0 -0
  127. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/public/js/tina4js.min.js +0 -0
  128. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/public/licenses/swagger-ui-3.10.0-original-notice.txt +0 -0
  129. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/public/licenses/swagger-ui-5.17.14-NOTICE.txt +0 -0
  130. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/public/licenses/swagger-ui-Apache-2.0.txt +0 -0
  131. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/public/licenses/tina4-css-MIT.txt +0 -0
  132. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/public/licenses/tina4-dev-admin-components.json +0 -0
  133. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/public/licenses/tina4-dev-admin-third-party.txt +0 -0
  134. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/public/licenses/tina4-js-MIT.txt +0 -0
  135. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/public/swagger/index.html +0 -0
  136. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/public/swagger/oauth2-redirect.html +0 -0
  137. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/push/__init__.py +0 -0
  138. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/push/_base.py +0 -0
  139. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/push/_cryptography.py +0 -0
  140. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/push/_libcrypto.py +0 -0
  141. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/query_builder/__init__.py +0 -0
  142. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/queue/__init__.py +0 -0
  143. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/queue/amqp_url.py +0 -0
  144. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/queue/job.py +0 -0
  145. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/queue/kafka_backend.py +0 -0
  146. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/queue/lite_backend.py +0 -0
  147. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/queue/mongo_backend.py +0 -0
  148. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/queue/rabbitmq_backend.py +0 -0
  149. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/queue/topic_dead_letter.py +0 -0
  150. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/queue_backends/__init__.py +0 -0
  151. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/queue_backends/kafka_backend.py +0 -0
  152. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/queue_backends/mongo_backend.py +0 -0
  153. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/queue_backends/rabbitmq_backend.py +0 -0
  154. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/realtime/models/Attachment.py +0 -0
  155. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/realtime/models/Channel.py +0 -0
  156. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/realtime/models/ChannelMember.py +0 -0
  157. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/realtime/models/Message.py +0 -0
  158. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/realtime/models/Workspace.py +0 -0
  159. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/realtime/models/__init__.py +0 -0
  160. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/seeder/__init__.py +0 -0
  161. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/service/__init__.py +0 -0
  162. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/session/__init__.py +0 -0
  163. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/session_handlers/__init__.py +0 -0
  164. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/session_handlers/memcached_handler.py +0 -0
  165. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/session_handlers/mongodb_handler.py +0 -0
  166. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/session_handlers/redis_handler.py +0 -0
  167. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/session_handlers/valkey_handler.py +0 -0
  168. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/sso.py +0 -0
  169. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/ssrf.py +0 -0
  170. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/swagger/__init__.py +0 -0
  171. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/templates/components/crud.twig +0 -0
  172. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/templates/crud/modals.twig +0 -0
  173. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/templates/crud/page.twig +0 -0
  174. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/templates/docker/distroless/Dockerfile +0 -0
  175. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/templates/docker/poetry/Dockerfile +0 -0
  176. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/templates/docker/python/Dockerfile +0 -0
  177. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/templates/docker/uv/Dockerfile +0 -0
  178. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/templates/errors/401.twig +0 -0
  179. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/templates/errors/403.twig +0 -0
  180. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/templates/errors/404.twig +0 -0
  181. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/templates/errors/500.twig +0 -0
  182. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/templates/errors/502.twig +0 -0
  183. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/templates/errors/503.twig +0 -0
  184. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/templates/errors/base.twig +0 -0
  185. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/templates/frontend/README.md +0 -0
  186. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/templates/readme.md +0 -0
  187. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/test/__init__.py +0 -0
  188. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/test_client/__init__.py +0 -0
  189. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/translations/af/LC_MESSAGES/messages.mo +0 -0
  190. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/translations/af/LC_MESSAGES/messages.po +0 -0
  191. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/translations/en/LC_MESSAGES/messages.mo +0 -0
  192. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/translations/en/LC_MESSAGES/messages.po +0 -0
  193. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/translations/es/LC_MESSAGES/messages.mo +0 -0
  194. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/translations/es/LC_MESSAGES/messages.po +0 -0
  195. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/translations/fr/LC_MESSAGES/messages.mo +0 -0
  196. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/translations/fr/LC_MESSAGES/messages.po +0 -0
  197. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/translations/ja/LC_MESSAGES/messages.mo +0 -0
  198. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/translations/ja/LC_MESSAGES/messages.po +0 -0
  199. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/translations/zh/LC_MESSAGES/messages.mo +0 -0
  200. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/translations/zh/LC_MESSAGES/messages.po +0 -0
  201. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/validator/__init__.py +0 -0
  202. {tina4_python-3.13.149 → tina4_python-3.13.151}/tina4_python/websocket/backplane.py +0 -0
  203. {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.149
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.0; extra == 'all-db'
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.0; extra == 'mongo'
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.0; extra == 'test'
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 (55 Features)
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
 
@@ -74,7 +74,7 @@ Open http://localhost:7146
74
74
 
75
75
  ---
76
76
 
77
- ## What's Built In (55 Features)
77
+ ## What's Built In (140 Features)
78
78
 
79
79
  Every feature is built from scratch -- no pip install, no node_modules, no third-party runtime dependencies in core.
80
80
 
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "tina4-python"
3
- version = "3.13.149"
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.0"]
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 — install what you need.
37
- # The `local` filesystem backend is the zero-dependency default; S3Storage
38
- # (TINA4_STORAGE_BACKEND=s3) is opt-in and imports boto3 lazily.
39
- s3 = ["boto3>=1.34"]
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.0",
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 for exactly that reason, MEASURED on the lab 2026-08-06
79
- # (Ubuntu 24.04.4 LTS x86_64, Python 3.13.3): it was declared in NO extra, but
80
- # happened to be installed ad hoc, so the two REAL-MinIO tests in
81
- # tests/test_realtime_files.py were passing. Running `uv sync --extra test`
82
- # pruned boto3 (plus s3transfer and jmespath) and those tests went straight from
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.0",
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 # Query string parameters (dict)
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
@@ -57,7 +57,7 @@ def _resolve_version() -> str:
57
57
  #
58
58
  # test_version_constant.py now asserts this literal equals the pyproject
59
59
  # version, so the release bump cannot leave it behind again.
60
- return "3.13.149"
60
+ return "3.13.151"
61
61
 
62
62
 
63
63
  __version__ = _resolve_version()
@@ -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
- # Auth doesn't require a name argument
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
- from urllib.parse import parse_qs, unquote
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
- parsed = parse_qs(body.decode(), keep_blank_values=True)
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
- result[name] = content.decode(errors="replace")
635
+ fields.append((name, content.decode(errors="replace")))
635
636
 
636
637
  if is_last:
637
638
  break
638
639
 
639
- return result
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 isinstance(value[0], dict) and "filename" in value[0]
653
- return False
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 (guards a pre-existing symlink at target/base).
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
- with open(dest, "wb") as handle:
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