tina4-python 3.13.162__tar.gz → 3.13.164__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 (204) hide show
  1. {tina4_python-3.13.162 → tina4_python-3.13.164}/PKG-INFO +9 -9
  2. {tina4_python-3.13.162 → tina4_python-3.13.164}/pyproject.toml +9 -9
  3. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/Testing.py +52 -17
  4. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/__init__.py +1 -1
  5. tina4_python-3.13.164/tina4_python/_testing_async.py +173 -0
  6. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/ai/__init__.py +4 -4
  7. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/cli/__init__.py +7 -3
  8. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/core/middleware.py +19 -0
  9. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/core/port_takeover.py +53 -12
  10. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/core/response.py +6 -2
  11. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/core/server.py +59 -4
  12. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/dev_admin/__init__.py +51 -18
  13. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/frond/engine.py +60 -19
  14. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/mcp/__init__.py +179 -43
  15. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/queue_backends/kafka_backend.py +87 -55
  16. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/test_client/__init__.py +4 -0
  17. {tina4_python-3.13.162 → tina4_python-3.13.164}/.gitignore +0 -0
  18. {tina4_python-3.13.162 → tina4_python-3.13.164}/COMMERCIAL-LICENSE.md +0 -0
  19. {tina4_python-3.13.162 → tina4_python-3.13.164}/LICENSE +0 -0
  20. {tina4_python-3.13.162 → tina4_python-3.13.164}/NOTICE +0 -0
  21. {tina4_python-3.13.162 → tina4_python-3.13.164}/README.md +0 -0
  22. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/.tina4-metrics.json +0 -0
  23. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/CLAUDE.md +0 -0
  24. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/HtmlElement.py +0 -0
  25. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/_import_helper.py +0 -0
  26. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/ai/client.py +0 -0
  27. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/api/__init__.py +0 -0
  28. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/auth/__init__.py +0 -0
  29. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/cache/__init__.py +0 -0
  30. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/container/__init__.py +0 -0
  31. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/context/__init__.py +0 -0
  32. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/context/chunker.py +0 -0
  33. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/core/__init__.py +0 -0
  34. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/core/cache.py +0 -0
  35. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/core/constants.py +0 -0
  36. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/core/csp.py +0 -0
  37. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/core/events.py +0 -0
  38. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/core/rate_limiter.py +0 -0
  39. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/core/request.py +0 -0
  40. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/core/router.py +0 -0
  41. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/crud/__init__.py +0 -0
  42. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/crud/page.py +0 -0
  43. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/crud/page_render.py +0 -0
  44. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/database/__init__.py +0 -0
  45. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/database/adapter.py +0 -0
  46. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/database/async_api.py +0 -0
  47. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/database/connection.py +0 -0
  48. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/database/database_url.py +0 -0
  49. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/database/firebird.py +0 -0
  50. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/database/mongodb.py +0 -0
  51. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/database/mssql.py +0 -0
  52. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/database/mysql.py +0 -0
  53. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/database/odbc.py +0 -0
  54. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/database/pool.py +0 -0
  55. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/database/postgres.py +0 -0
  56. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/database/sql_translator.py +0 -0
  57. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/database/sqlite.py +0 -0
  58. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/debug/__init__.py +0 -0
  59. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/debug/error_overlay.py +0 -0
  60. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/dev_admin/metrics.py +0 -0
  61. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/dev_admin/plan.py +0 -0
  62. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/dev_admin/project_index.py +0 -0
  63. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/docs.py +0 -0
  64. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/docstore/__init__.py +0 -0
  65. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/dotenv/__init__.py +0 -0
  66. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/env.py +0 -0
  67. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/frond/FROND.md +0 -0
  68. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/frond/__init__.py +0 -0
  69. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/frond/compiler.py +0 -0
  70. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/frond/parser.py +0 -0
  71. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/gallery/auth/meta.json +0 -0
  72. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/gallery/auth/src/routes/api/gallery_auth.py +0 -0
  73. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/gallery/database/meta.json +0 -0
  74. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/gallery/database/src/routes/api/gallery_db.py +0 -0
  75. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/gallery/error-overlay/meta.json +0 -0
  76. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/gallery/error-overlay/src/routes/api/gallery_crash.py +0 -0
  77. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/gallery/orm/meta.json +0 -0
  78. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/gallery/orm/src/orm/Product.py +0 -0
  79. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/gallery/orm/src/routes/api/gallery_products.py +0 -0
  80. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/gallery/queue/meta.json +0 -0
  81. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/gallery/queue/src/routes/api/gallery_queue.py +0 -0
  82. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/gallery/rest-api/meta.json +0 -0
  83. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/gallery/rest-api/src/routes/api/gallery_hello.py +0 -0
  84. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/gallery/templates/meta.json +0 -0
  85. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/gallery/templates/src/routes/gallery_page.py +0 -0
  86. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/gallery/templates/src/templates/gallery_page.twig +0 -0
  87. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/graph/__init__.py +0 -0
  88. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/graph/adapter.py +0 -0
  89. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/graph/adapters/__init__.py +0 -0
  90. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/graph/adapters/arango.py +0 -0
  91. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/graph/adapters/bolt.py +0 -0
  92. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/graph/adapters/ultipa.py +0 -0
  93. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/graph/graph_url.py +0 -0
  94. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/graphql/__init__.py +0 -0
  95. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/i18n/__init__.py +0 -0
  96. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/mcp/protocol.py +0 -0
  97. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/mcp/tools.py +0 -0
  98. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/messenger/__init__.py +0 -0
  99. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/migration/__init__.py +0 -0
  100. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/migration/runner.py +0 -0
  101. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/mqtt/__init__.py +0 -0
  102. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/mqtt/message.py +0 -0
  103. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/orm/__init__.py +0 -0
  104. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/orm/async_api.py +0 -0
  105. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/orm/collection.py +0 -0
  106. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/orm/fields.py +0 -0
  107. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/orm/model.py +0 -0
  108. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/orm/point.py +0 -0
  109. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/public/THIRD-PARTY-NOTICES.md +0 -0
  110. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/public/__feedback/widget.js +0 -0
  111. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/public/bundled-component-provenance.json +0 -0
  112. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/public/css/tina4.css +0 -0
  113. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/public/css/tina4.min.css +0 -0
  114. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/public/favicon.ico +0 -0
  115. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/public/images/logo.svg +0 -0
  116. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/public/images/tina4-logo-icon.webp +0 -0
  117. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/public/js/frond.js +0 -0
  118. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/public/js/frond.min.js +0 -0
  119. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/public/js/tina4-dev-admin-split.html +0 -0
  120. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/public/js/tina4-dev-admin.min.js +0 -0
  121. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/public/js/tina4.min.js +0 -0
  122. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/public/js/tina4js.min.js +0 -0
  123. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/public/licenses/swagger-ui-3.10.0-original-notice.txt +0 -0
  124. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/public/licenses/swagger-ui-5.17.14-NOTICE.txt +0 -0
  125. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/public/licenses/swagger-ui-Apache-2.0.txt +0 -0
  126. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/public/licenses/tina4-css-MIT.txt +0 -0
  127. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/public/licenses/tina4-dev-admin-components.json +0 -0
  128. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/public/licenses/tina4-dev-admin-third-party.txt +0 -0
  129. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/public/licenses/tina4-js-MIT.txt +0 -0
  130. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/public/swagger/index.html +0 -0
  131. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/public/swagger/oauth2-redirect.html +0 -0
  132. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/push/__init__.py +0 -0
  133. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/push/_base.py +0 -0
  134. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/push/_cryptography.py +0 -0
  135. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/push/_libcrypto.py +0 -0
  136. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/query_builder/__init__.py +0 -0
  137. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/queue/__init__.py +0 -0
  138. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/queue/amqp_url.py +0 -0
  139. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/queue/job.py +0 -0
  140. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/queue/kafka_backend.py +0 -0
  141. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/queue/lite_backend.py +0 -0
  142. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/queue/mongo_backend.py +0 -0
  143. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/queue/rabbitmq_backend.py +0 -0
  144. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/queue/topic_dead_letter.py +0 -0
  145. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/queue_backends/__init__.py +0 -0
  146. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/queue_backends/mongo_backend.py +0 -0
  147. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/queue_backends/rabbitmq_backend.py +0 -0
  148. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/realtime/__init__.py +0 -0
  149. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/realtime/models/Attachment.py +0 -0
  150. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/realtime/models/Channel.py +0 -0
  151. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/realtime/models/ChannelMember.py +0 -0
  152. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/realtime/models/Message.py +0 -0
  153. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/realtime/models/Workspace.py +0 -0
  154. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/realtime/models/__init__.py +0 -0
  155. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/realtime/s3_client.py +0 -0
  156. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/realtime/storage.py +0 -0
  157. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/seeder/__init__.py +0 -0
  158. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/service/__init__.py +0 -0
  159. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/session/__init__.py +0 -0
  160. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/session_handlers/__init__.py +0 -0
  161. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/session_handlers/memcached_handler.py +0 -0
  162. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/session_handlers/mongodb_handler.py +0 -0
  163. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/session_handlers/redis_handler.py +0 -0
  164. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/session_handlers/valkey_handler.py +0 -0
  165. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/sso.py +0 -0
  166. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/ssrf.py +0 -0
  167. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/swagger/__init__.py +0 -0
  168. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/tcp/__init__.py +0 -0
  169. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/templates/components/crud.twig +0 -0
  170. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/templates/crud/form.twig +0 -0
  171. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/templates/crud/modals.twig +0 -0
  172. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/templates/crud/page.twig +0 -0
  173. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/templates/crud/table.twig +0 -0
  174. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/templates/docker/distroless/Dockerfile +0 -0
  175. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/templates/docker/poetry/Dockerfile +0 -0
  176. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/templates/docker/python/Dockerfile +0 -0
  177. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/templates/docker/uv/Dockerfile +0 -0
  178. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/templates/errors/302.twig +0 -0
  179. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/templates/errors/401.twig +0 -0
  180. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/templates/errors/403.twig +0 -0
  181. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/templates/errors/404.twig +0 -0
  182. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/templates/errors/500.twig +0 -0
  183. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/templates/errors/502.twig +0 -0
  184. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/templates/errors/503.twig +0 -0
  185. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/templates/errors/base.twig +0 -0
  186. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/templates/frontend/README.md +0 -0
  187. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/templates/readme.md +0 -0
  188. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/test/__init__.py +0 -0
  189. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/translations/af/LC_MESSAGES/messages.mo +0 -0
  190. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/translations/af/LC_MESSAGES/messages.po +0 -0
  191. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/translations/en/LC_MESSAGES/messages.mo +0 -0
  192. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/translations/en/LC_MESSAGES/messages.po +0 -0
  193. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/translations/es/LC_MESSAGES/messages.mo +0 -0
  194. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/translations/es/LC_MESSAGES/messages.po +0 -0
  195. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/translations/fr/LC_MESSAGES/messages.mo +0 -0
  196. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/translations/fr/LC_MESSAGES/messages.po +0 -0
  197. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/translations/ja/LC_MESSAGES/messages.mo +0 -0
  198. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/translations/ja/LC_MESSAGES/messages.po +0 -0
  199. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/translations/zh/LC_MESSAGES/messages.mo +0 -0
  200. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/translations/zh/LC_MESSAGES/messages.po +0 -0
  201. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/validator/__init__.py +0 -0
  202. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/websocket/__init__.py +0 -0
  203. {tina4_python-3.13.162 → tina4_python-3.13.164}/tina4_python/websocket/backplane.py +0 -0
  204. {tina4_python-3.13.162 → tina4_python-3.13.164}/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.162
3
+ Version: 3.13.164
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
@@ -10,9 +10,9 @@ License-File: NOTICE
10
10
  Requires-Python: >=3.12
11
11
  Provides-Extra: all-db
12
12
  Requires-Dist: firebird-driver>=1.10; extra == 'all-db'
13
- Requires-Dist: mysql-connector-python>=9.0; extra == 'all-db'
13
+ Requires-Dist: mysql-connector-python>=9.1.0; extra == 'all-db'
14
14
  Requires-Dist: psycopg2-binary>=2.9; extra == 'all-db'
15
- Requires-Dist: pymongo>=4.18.2; extra == 'all-db'
15
+ Requires-Dist: pymongo>=4.18.3; 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,11 +29,11 @@ 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.18.2; extra == 'mongo'
32
+ Requires-Dist: pymongo>=4.18.3; extra == 'mongo'
33
33
  Provides-Extra: mssql
34
34
  Requires-Dist: pymssql>=2.3; extra == 'mssql'
35
35
  Provides-Extra: mysql
36
- Requires-Dist: mysql-connector-python>=9.0; extra == 'mysql'
36
+ Requires-Dist: mysql-connector-python>=9.1.0; extra == 'mysql'
37
37
  Provides-Extra: neo4j
38
38
  Requires-Dist: neo4j>=5.0; extra == 'neo4j'
39
39
  Provides-Extra: odbc
@@ -41,7 +41,7 @@ Requires-Dist: pyodbc>=5.0; extra == 'odbc'
41
41
  Provides-Extra: postgres
42
42
  Requires-Dist: psycopg2-binary>=2.9; extra == 'postgres'
43
43
  Provides-Extra: push
44
- Requires-Dist: cryptography>=42.0; extra == 'push'
44
+ Requires-Dist: cryptography>=50.0.0; extra == 'push'
45
45
  Provides-Extra: rabbitmq
46
46
  Requires-Dist: pika>=1.3; extra == 'rabbitmq'
47
47
  Provides-Extra: redis
@@ -49,14 +49,14 @@ Requires-Dist: redis>=5.0; extra == 'redis'
49
49
  Provides-Extra: s3
50
50
  Provides-Extra: test
51
51
  Requires-Dist: confluent-kafka>=2.0; extra == 'test'
52
- Requires-Dist: cryptography>=42.0; extra == 'test'
52
+ Requires-Dist: cryptography>=50.0.0; extra == 'test'
53
53
  Requires-Dist: firebird-driver>=1.10; extra == 'test'
54
- Requires-Dist: mysql-connector-python>=9.0; extra == 'test'
54
+ Requires-Dist: mysql-connector-python>=9.1.0; extra == 'test'
55
55
  Requires-Dist: openapi-spec-validator>=0.7; extra == 'test'
56
56
  Requires-Dist: pika>=1.3; extra == 'test'
57
57
  Requires-Dist: psycopg2-binary>=2.9; extra == 'test'
58
58
  Requires-Dist: pymemcache>=4.0; extra == 'test'
59
- Requires-Dist: pymongo>=4.18.2; extra == 'test'
59
+ Requires-Dist: pymongo>=4.18.3; extra == 'test'
60
60
  Requires-Dist: pymssql>=2.3; extra == 'test'
61
61
  Requires-Dist: pyodbc>=5.0; extra == 'test'
62
62
  Requires-Dist: redis>=5.0; extra == 'test'
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "tina4-python"
3
- version = "3.13.162"
3
+ version = "3.13.164"
4
4
  description = "Tina4 Python v3 — Zero-dependency, lightweight web framework"
5
5
  authors = [
6
6
  {name = "Andre van Zuydam", email = "andrevanzuydam@gmail.com"}
@@ -16,10 +16,10 @@ dependencies = []
16
16
  [project.optional-dependencies]
17
17
  # Database drivers — install what you need
18
18
  postgres = ["psycopg2-binary>=2.9"]
19
- mysql = ["mysql-connector-python>=9.0"]
19
+ mysql = ["mysql-connector-python>=9.1.0"]
20
20
  mssql = ["pymssql>=2.3"]
21
21
  firebird = ["firebird-driver>=1.10"]
22
- mongo = ["pymongo>=4.18.2"]
22
+ mongo = ["pymongo>=4.18.3"]
23
23
  odbc = ["pyodbc>=5.0"]
24
24
 
25
25
  # Graph engine drivers — install what you need (loaded lazily on first use).
@@ -51,15 +51,15 @@ rabbitmq = ["pika>=1.3"]
51
51
  # cannot reach a safe OpenSSL, so the cryptography package runs instead. Install
52
52
  # it there (or pin it with TINA4_PUSH_BACKEND=cryptography); the wire output is
53
53
  # identical either way. See tina4_python/push/_libcrypto.py.
54
- push = ["cryptography>=42.0"]
54
+ push = ["cryptography>=50.0.0"]
55
55
 
56
56
  # All database drivers
57
57
  all-db = [
58
58
  "psycopg2-binary>=2.9",
59
- "mysql-connector-python>=9.0",
59
+ "mysql-connector-python>=9.1.0",
60
60
  "pymssql>=2.3",
61
61
  "firebird-driver>=1.10",
62
- "pymongo>=4.18.2",
62
+ "pymongo>=4.18.3",
63
63
  "pyodbc>=5.0",
64
64
  ]
65
65
 
@@ -85,10 +85,10 @@ all-db = [
85
85
  # the urllib3 advisories they carried.
86
86
  test = [
87
87
  "psycopg2-binary>=2.9",
88
- "mysql-connector-python>=9.0",
88
+ "mysql-connector-python>=9.1.0",
89
89
  "pymssql>=2.3",
90
90
  "firebird-driver>=1.10",
91
- "pymongo>=4.18.2",
91
+ "pymongo>=4.18.3",
92
92
  "pyodbc>=5.0",
93
93
  "redis>=5.0",
94
94
  "pymemcache>=4.0",
@@ -99,7 +99,7 @@ test = [
99
99
  # runtime dependency — the swagger generator itself stays zero-dependency.
100
100
  "openapi-spec-validator>=0.7",
101
101
  # TEST-ONLY: exercises Feature 140's optional native crypto capability.
102
- "cryptography>=42.0",
102
+ "cryptography>=50.0.0",
103
103
  ]
104
104
 
105
105
  [dependency-groups]
@@ -37,6 +37,7 @@ the wrong one is a loud ``ImportError``/``AttributeError``, never a silent
37
37
  change of call semantics.
38
38
  """
39
39
 
40
+ from tina4_python._testing_async import _AsyncRunner, _AsyncRunnerError, _RunAborted
40
41
  import sys
41
42
  import traceback
42
43
 
@@ -88,12 +89,40 @@ def tests(*assertions):
88
89
 
89
90
  # ── Runner ──────────────────────────────────────────────────────────
90
91
 
91
- def run_all(quiet: bool = False, failfast: bool = False) -> dict:
92
+ def run_all(quiet: bool = False, failfast: bool = False, timeout: float | None = 30.0) -> dict:
92
93
  """Discover and run every ``@tests``-decorated function.
93
94
 
94
95
  Returns a dict with keys ``passed``, ``failed``, ``errors``, ``details``.
96
+
97
+ An ``async def`` test function is awaited, and judged on what it returns;
98
+ so is any test function whose call returns an awaitable (a coroutine, a
99
+ Future, an object with ``__await__``).
100
+ Every async test in one run shares ONE event loop, created here and closed
101
+ when the run ends, so an object bound to a loop (an ``asyncio.Queue``, a
102
+ pooled connection) works across assertions. Called from inside a running
103
+ event loop, an async test cannot be awaited without blocking that loop, so
104
+ it is reported as an error asking for a synchronous caller. An async test
105
+ still awaiting after ``timeout`` seconds (``None``: no limit) is cancelled
106
+ and reported as an error, after up to one second for its cleanup. The
107
+ timeout cannot pre-empt code that never yields (``time.sleep`` inside an
108
+ ``async def``). A test that is still running after that second (it ignored
109
+ its cancellation) is abandoned: anything it raises afterwards, such as a
110
+ ``SystemExit``, is no longer attributed to it and ends the run as it would
111
+ from a sync test; the same holds for a task a test leaves running. A test
112
+ that tampers with the runner's own loop internals is outside these
113
+ guarantees.
95
114
  """
96
115
  results = {"passed": 0, "failed": 0, "errors": 0, "details": []}
116
+ runner = _AsyncRunner(timeout)
117
+ try:
118
+ return _run_all(results, runner, quiet, failfast)
119
+ except _RunAborted as stop:
120
+ raise stop.args[0] from None
121
+ finally:
122
+ runner.close()
123
+
124
+
125
+ def _run_all(results: dict, runner: "_AsyncRunner", quiet: bool, failfast: bool) -> dict:
97
126
 
98
127
  for entry in _registry:
99
128
  fn = entry["fn"]
@@ -106,7 +135,7 @@ def run_all(quiet: bool = False, failfast: bool = False) -> dict:
106
135
  for assertion in entry["assertions"]:
107
136
  label = _assertion_label(assertion, name)
108
137
  try:
109
- _run_assertion(fn, assertion)
138
+ _run_assertion(fn, assertion, runner)
110
139
  results["passed"] += 1
111
140
  results["details"].append({"name": label, "status": "passed"})
112
141
  if not quiet:
@@ -135,36 +164,27 @@ def run_all(quiet: bool = False, failfast: bool = False) -> dict:
135
164
 
136
165
  # ── Internals ───────────────────────────────────────────────────────
137
166
 
138
- def _run_assertion(fn, assertion: dict):
167
+
168
+ def _run_assertion(fn, assertion: dict, runner: _AsyncRunner):
139
169
  atype = assertion["type"]
140
170
  args = assertion["args"]
141
171
 
142
172
  if atype == "equal":
143
- result = fn(*args)
173
+ result = runner.call(fn, args)
144
174
  expected = assertion["expected"]
145
175
  if result != expected:
146
176
  raise AssertionError(f"expected {expected!r}, got {result!r}")
147
177
 
148
178
  elif atype == "raises":
149
- exc_class = assertion["exception"]
150
- try:
151
- fn(*args)
152
- except exc_class:
153
- return # success
154
- except Exception as other:
155
- raise AssertionError(
156
- f"expected {exc_class.__name__}, got {type(other).__name__}: {other}"
157
- )
158
- else:
159
- raise AssertionError(f"expected {exc_class.__name__} to be raised")
179
+ _run_raises(fn, args, assertion["exception"], runner)
160
180
 
161
181
  elif atype == "true":
162
- result = fn(*args)
182
+ result = runner.call(fn, args)
163
183
  if not result:
164
184
  raise AssertionError(f"expected truthy, got {result!r}")
165
185
 
166
186
  elif atype == "false":
167
- result = fn(*args)
187
+ result = runner.call(fn, args)
168
188
  if result:
169
189
  raise AssertionError(f"expected falsy, got {result!r}")
170
190
 
@@ -172,6 +192,21 @@ def _run_assertion(fn, assertion: dict):
172
192
  raise ValueError(f"unknown assertion type: {atype!r}")
173
193
 
174
194
 
195
+ def _run_raises(fn, args, exc_class: type, runner: _AsyncRunner):
196
+ try:
197
+ runner.call(fn, args)
198
+ except (_AsyncRunnerError, _RunAborted):
199
+ raise # the runner failed or the run is ending: never a pass
200
+ except exc_class:
201
+ return # success
202
+ except Exception as other:
203
+ raise AssertionError(
204
+ f"expected {exc_class.__name__}, got {type(other).__name__}: {other}"
205
+ )
206
+ else:
207
+ raise AssertionError(f"expected {exc_class.__name__} to be raised")
208
+
209
+
175
210
  def _assertion_label(assertion: dict, fn_name: str) -> str:
176
211
  atype = assertion["type"]
177
212
  args = assertion["args"]
@@ -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.162"
60
+ return "3.13.164"
61
61
 
62
62
 
63
63
  __version__ = _resolve_version()
@@ -0,0 +1,173 @@
1
+ # Copyright (c) 2026 Code Infinity
2
+ # SPDX-License-Identifier: MPL-2.0
3
+ # This Source Code Form is subject to the terms of the Mozilla Public
4
+ # License, v. 2.0. If a copy of the MPL was not distributed with this
5
+ # file, You can obtain one at https://mozilla.org/MPL/2.0/.
6
+ """Awaiting async inline tests for :mod:`tina4_python.Testing`.
7
+
8
+ One event loop per ``run_all()``; every test's awaitable runs as a task the
9
+ runner watches from outside the loop, so nothing a test does can cancel, hang
10
+ or abort the runner itself.
11
+ """
12
+ import asyncio
13
+ import inspect
14
+ import numbers
15
+
16
+ # How long a cancelled test task gets to finish before the runner moves on.
17
+ _CANCEL_GRACE = 1.0
18
+
19
+
20
+ class _AsyncRunnerError(RuntimeError):
21
+ """The runner could not run a test, which is never the test's own exception."""
22
+
23
+
24
+ class _RunAborted(BaseException):
25
+ """A SystemExit / KeyboardInterrupt that did not come from the test being
26
+ judged (a Ctrl-C, or a task an earlier test left running). It ends the run,
27
+ as it would from a sync test, and no assertion can catch it as its own."""
28
+
29
+
30
+ def _check_timeout(timeout):
31
+ """Seconds as a float (infinity allowed), or None for no limit."""
32
+ if timeout is None:
33
+ return None
34
+ if isinstance(timeout, bool) or not isinstance(timeout, numbers.Real):
35
+ raise TypeError(f"timeout must be a number of seconds or None, got {timeout!r}")
36
+ try:
37
+ seconds = float(timeout)
38
+ except OverflowError:
39
+ return None # larger than any float: no limit
40
+ if seconds != seconds or seconds < 0:
41
+ raise ValueError(f"timeout must be zero or more seconds, got {timeout!r}")
42
+ return seconds
43
+
44
+
45
+ def _run_for(loop, tasks, timeout) -> None:
46
+ """Run ``loop`` until every task in ``tasks`` is done or ``timeout`` passes.
47
+
48
+ It waits on a plain future, not a task, so nothing a test does through
49
+ ``asyncio.all_tasks()`` (a "cancel every other task" teardown) can reach the
50
+ runner itself. An ordinary exception out of the loop (a test stopped it) is
51
+ the runner's failure, never the test's own exception.
52
+ """
53
+ pending = [t for t in tasks if not t.done()]
54
+ if not pending:
55
+ return
56
+ waiter = loop.create_future()
57
+
58
+ def wake(_=None, expired=False):
59
+ if not waiter.done() and (expired or all(t.done() for t in pending)):
60
+ waiter.set_result(None)
61
+
62
+ for t in pending:
63
+ t.add_done_callback(wake)
64
+ handle = loop.call_later(timeout, wake, None, True) if timeout is not None else None
65
+ try:
66
+ loop.run_until_complete(waiter)
67
+ except (Exception, asyncio.CancelledError) as exc:
68
+ raise _AsyncRunnerError(f"the test runner's event loop failed: {exc!r}") from exc
69
+ finally:
70
+ if handle is not None:
71
+ handle.cancel()
72
+ for t in pending:
73
+ t.remove_done_callback(wake)
74
+
75
+
76
+ def _settle(loop, tasks) -> None:
77
+ """Give ``tasks`` the cancel grace while the run is closing. Results are
78
+ already in: a SystemExit from a task an earlier test abandoned must not turn
79
+ a failed run into exit status 0, nor skip the cleanup of the others."""
80
+ try:
81
+ _run_for(loop, tasks, _CANCEL_GRACE)
82
+ except (_AsyncRunnerError, SystemExit):
83
+ pass
84
+
85
+
86
+ class _AsyncRunner:
87
+ """Runs awaitable test results to completion on one loop per run_all()."""
88
+
89
+ def __init__(self, timeout: float | None = 30.0):
90
+ self._timeout = _check_timeout(timeout)
91
+ self._loop = None
92
+
93
+ def call(self, fn, args):
94
+ """Call ``fn(*args)``; an awaitable result is awaited and its value returned."""
95
+ result = fn(*args)
96
+ if not inspect.isawaitable(result):
97
+ return result
98
+ try:
99
+ asyncio.get_running_loop()
100
+ except RuntimeError:
101
+ pass
102
+ else:
103
+ if inspect.iscoroutine(result):
104
+ result.close() # never started: no "was never awaited" warning
105
+ raise _AsyncRunnerError(
106
+ "async test function: run_all() was called from inside a running "
107
+ "event loop and cannot await it; call run_all() from synchronous code"
108
+ )
109
+ return self._await(result)
110
+
111
+ def _await(self, result):
112
+ if self._loop is None:
113
+ self._loop = asyncio.new_event_loop()
114
+ # A task watched from outside, not wait_for: a TimeoutError the test
115
+ # raises itself must reach the assertion as the test's own exception.
116
+ try:
117
+ task = asyncio.ensure_future(result, loop=self._loop)
118
+ except Exception as exc: # a foreign-loop future, a broken task factory
119
+ raise _AsyncRunnerError(f"could not schedule the async test: {exc!r}") from exc
120
+ try:
121
+ _run_for(self._loop, [task], self._timeout)
122
+ except _AsyncRunnerError:
123
+ self._stop(task) # e.g. the test stopped the loop: it must not run on
124
+ raise
125
+ except BaseException as exc:
126
+ # A SystemExit / KeyboardInterrupt out of the loop is the test's own
127
+ # only when its task finished with exactly that exception.
128
+ if task.done() and not task.cancelled() and task.exception() is exc:
129
+ raise
130
+ self._stop(task)
131
+ raise _RunAborted(exc) from None
132
+ return self._judge(task)
133
+
134
+ def _stop(self, task):
135
+ if not task.done():
136
+ task.cancel()
137
+ try:
138
+ _run_for(self._loop, [task], _CANCEL_GRACE)
139
+ except _AsyncRunnerError:
140
+ pass
141
+
142
+ def _judge(self, task):
143
+ if not task.done():
144
+ # Bounded: a test that swallows CancelledError must not hang the run.
145
+ self._stop(task)
146
+ raise _AsyncRunnerError(f"async test function did not finish within {self._timeout}s")
147
+ if task.cancelled():
148
+ # The test cancelled itself (raised CancelledError). That is a
149
+ # BaseException and would abort the whole run; report it instead.
150
+ raise _AsyncRunnerError("async test function was cancelled")
151
+ return task.result()
152
+
153
+ def close(self):
154
+ if self._loop is None:
155
+ return
156
+ loop, self._loop = self._loop, None
157
+ try:
158
+ loop.set_task_factory(None) # a test may have installed a broken one
159
+ pending = asyncio.all_tasks(loop)
160
+ for task in pending:
161
+ task.cancel()
162
+ # Twice: a SystemExit from one abandoned task stops the loop before
163
+ # the others have run their cleanup.
164
+ _settle(loop, pending)
165
+ _settle(loop, pending)
166
+ # Bounded the same way: a generator whose cleanup swallows
167
+ # CancelledError must not hang the run.
168
+ shutdown = loop.create_task(loop.shutdown_asyncgens())
169
+ _settle(loop, [shutdown])
170
+ shutdown.cancel()
171
+ _settle(loop, [shutdown])
172
+ finally:
173
+ loop.close()
@@ -495,12 +495,12 @@ def generate_context(tool_name: str = "claude-code") -> str:
495
495
 
496
496
  @get("/api/users")
497
497
  async def list_users(request, response):
498
- return response({{"users": []}})
498
+ return response({"users": []})
499
499
 
500
- @post("/api/users")
501
500
  @noauth()
501
+ @post("/api/users")
502
502
  async def create_user(request, response):
503
- return response({{"created": request.body["name"]}}, 201)'''
503
+ return response({"created": request.body["name"]}, 201)'''
504
504
 
505
505
  _orm_example = '''from tina4_python.orm import ORM, IntegerField, StringField
506
506
 
@@ -719,7 +719,7 @@ This project uses Tina4 Python. All features are built in — do not install ext
719
719
  ## CLI
720
720
 
721
721
  ```bash
722
- tina4python serve # Dev server on port 7145
722
+ tina4python serve # Dev server on port 7146
723
723
  tina4python migrate # Run migrations
724
724
  tina4python test # Run tests
725
725
  tina4python routes # List routes
@@ -288,7 +288,7 @@ from tina4_python.core.port_takeover import ( # noqa: E402
288
288
  )
289
289
 
290
290
 
291
- def _kill_process_on_port(port: int) -> bool:
291
+ def _kill_process_on_port(port: int, host: str | None = None) -> bool:
292
292
  """Reclaim *port* from a stale Tina4 dev server, only when it is safe.
293
293
 
294
294
  Routes through the shared identity-checked takeover (TAKEOVER-DEC-01/02):
@@ -297,9 +297,12 @@ def _kill_process_on_port(port: int) -> bool:
297
297
  printed; takeover is also skipped in a container, outside dev mode, and when
298
298
  opted out (`TINA4_NO_TAKEOVER` / `tina4 serve --no-kill`).
299
299
 
300
+ *host* is the address serve will bind; when given, a port that binds there
301
+ is reported as free instead of "in use".
302
+
300
303
  Returns True only when a Tina4 holder was actually signalled.
301
304
  """
302
- result = take_over_port(port, dev=is_dev(), no_takeover=no_takeover_opted_out())
305
+ result = take_over_port(port, dev=is_dev(), no_takeover=no_takeover_opted_out(), host=host)
303
306
  if result.reclaimed:
304
307
  print(f" ⚠ {result.message}")
305
308
  return True
@@ -864,7 +867,8 @@ def _serve(args):
864
867
 
865
868
  # Reclaim the port from a stale Tina4 dev server only (identity-checked).
866
869
  port = cli_port or int(os.environ.get("PORT", os.environ.get("TINA4_PORT", "7146")))
867
- _kill_process_on_port(port)
870
+ from tina4_python.core.server import resolve_config
871
+ _kill_process_on_port(port, host=resolve_config(cli_host=cli_host, cli_port=port)[0])
868
872
 
869
873
  from tina4_python.core import run
870
874
  run(host=cli_host, port=cli_port, no_browser=no_browser, no_reload=no_reload)
@@ -317,6 +317,18 @@ def _cors_warn_once(reason: str, message: str) -> None:
317
317
  logging.getLogger("tina4").warning(message)
318
318
 
319
319
 
320
+ _CORS_ENV_KEYS = (
321
+ "TINA4_CORS_ORIGINS", "TINA4_CORS_METHODS", "TINA4_CORS_HEADERS",
322
+ "TINA4_CORS_MAX_AGE", "TINA4_CORS_CREDENTIALS",
323
+ )
324
+
325
+
326
+ def cors_env() -> tuple:
327
+ """The TINA4_CORS_* settings ``CorsMiddleware`` reads, as they stand now."""
328
+ return tuple(os.environ.get(key) for key in _CORS_ENV_KEYS)
329
+
330
+
331
+
320
332
  class CorsMiddleware:
321
333
  """CORS handler — reads config from env, injects headers.
322
334
 
@@ -360,6 +372,10 @@ class CorsMiddleware:
360
372
  return request, response
361
373
 
362
374
  def __init__(self):
375
+ # What this instance was built from; the server's singleton is rebuilt
376
+ # in place when the environment no longer matches it (a policy set
377
+ # only in .env).
378
+ self._env_read = cors_env()
363
379
  # Default is EMPTY, not "*" — deny by default (ADR-0018).
364
380
  self.origins = os.environ.get("TINA4_CORS_ORIGINS", "")
365
381
  self.methods = os.environ.get(
@@ -373,6 +389,9 @@ class CorsMiddleware:
373
389
  self.credentials = os.environ.get(
374
390
  "TINA4_CORS_CREDENTIALS", "false"
375
391
  ).lower() in ("true", "1", "yes")
392
+ # Everything as built, so a refresh can tell the instance was changed
393
+ # by hand (a policy field, or an override set on it) and leave it be.
394
+ self._as_built = dict(vars(self))
376
395
 
377
396
  @property
378
397
  def allowed_origins(self) -> list:
@@ -44,6 +44,7 @@ from __future__ import annotations
44
44
 
45
45
  import os
46
46
  import signal
47
+ import socket
47
48
  import subprocess
48
49
  import sys
49
50
  from dataclasses import dataclass, field
@@ -233,6 +234,49 @@ def _port_holders(port: int) -> list[str]:
233
234
  return []
234
235
 
235
236
 
237
+ def _bindable(host: str, port: int) -> bool:
238
+ """True when a plain TCP listener on *host*:*port* binds right now.
239
+
240
+ SO_REUSEADDR off Windows only, as the server's own bind does: on POSIX it
241
+ lets a TIME_WAIT leftover pass but still fails against a live listener;
242
+ on Windows it would let the probe bind over a live listener.
243
+ """
244
+ family = socket.AF_INET6 if ":" in host else socket.AF_INET
245
+ try:
246
+ with socket.socket(family, socket.SOCK_STREAM) as probe:
247
+ if sys.platform != "win32":
248
+ probe.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
249
+ probe.bind((host.strip("[]"), port))
250
+ probe.listen(1)
251
+ except (OSError, ValueError, OverflowError):
252
+ return False
253
+ return True
254
+
255
+
256
+ def _refusal(port: int, dev: bool, no_takeover: bool, host: str | None) -> TakeoverResult | None:
257
+ """The result to return before any holder lookup, or None to carry on.
258
+
259
+ Takeover is refused when opted out or outside dev mode. Before a bind, the
260
+ caller passes the host it will bind: if that bind succeeds, nothing holds
261
+ the port, so there is nothing to refuse and nothing to say.
262
+ """
263
+ if dev and not no_takeover:
264
+ return None
265
+ if host is not None and _bindable(host, port):
266
+ return TakeoverResult(NOTHING, port)
267
+ if no_takeover:
268
+ return TakeoverResult(
269
+ REFUSED_OPTOUT, port,
270
+ message=(f"Port {port} is in use and takeover is disabled "
271
+ f"(TINA4_NO_TAKEOVER/--no-kill) -- free it or choose another port."),
272
+ )
273
+ return TakeoverResult(
274
+ REFUSED_PROD, port,
275
+ message=(f"Port {port} is in use; takeover is disabled outside dev mode "
276
+ f"-- free it or choose another port."),
277
+ )
278
+
279
+
236
280
  # ── the ONE takeover entry point (CLI + runtime both call this) ────────────
237
281
 
238
282
  def take_over_port(
@@ -242,6 +286,7 @@ def take_over_port(
242
286
  no_takeover: bool,
243
287
  base_dir: str | None = None,
244
288
  grace: float = 0.5,
289
+ host: str | None = None,
245
290
  ) -> TakeoverResult:
246
291
  """Reclaim *port* ONLY from an identity-confirmed Tina4 dev server.
247
292
 
@@ -257,19 +302,15 @@ def take_over_port(
257
302
 
258
303
  ``dev`` and ``no_takeover`` are passed in so this stays pure and directly
259
304
  testable; the callers resolve them from :func:`is_dev` / :func:`no_takeover_opted_out`.
305
+
306
+ Before a bind, the caller passes the ``host`` it will bind. When takeover
307
+ would be refused and that bind succeeds, nothing holds the port: there is
308
+ nothing to refuse and nothing to say (NOTHING, no message). Without it, every
309
+ start with debug off or ``--no-kill`` said a free port was in use.
260
310
  """
261
- if no_takeover:
262
- return TakeoverResult(
263
- REFUSED_OPTOUT, port,
264
- message=(f"Port {port} is in use and takeover is disabled "
265
- f"(TINA4_NO_TAKEOVER/--no-kill) -- free it or choose another port."),
266
- )
267
- if not dev:
268
- return TakeoverResult(
269
- REFUSED_PROD, port,
270
- message=(f"Port {port} is in use; takeover is disabled outside dev mode "
271
- f"-- free it or choose another port."),
272
- )
311
+ early = _refusal(port, dev, no_takeover, host)
312
+ if early is not None:
313
+ return early
273
314
  if in_container():
274
315
  return TakeoverResult(SKIPPED_CONTAINER, port)
275
316
 
@@ -87,8 +87,12 @@ def get_framework_frond():
87
87
  # Sync custom filters/globals from the user engine
88
88
  if _framework_frond is not None:
89
89
  user_engine = get_frond()
90
- _framework_frond._filters.update(user_engine._filters)
91
- _framework_frond._globals.update(user_engine._globals)
90
+ # Instance filters only: class filters already reach every engine.
91
+ for name, fn in user_engine._local_filters.items():
92
+ _framework_frond.add_filter(name, fn)
93
+ # Only the user engine's own (instance) globals: class globals are
94
+ # already live on every engine, so copying them would freeze them.
95
+ _framework_frond._globals.maps[0].update(user_engine._globals.maps[0])
92
96
  return _framework_frond
93
97
 
94
98