tina4-python 3.13.151__tar.gz → 3.13.152__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 (202) hide show
  1. {tina4_python-3.13.151 → tina4_python-3.13.152}/PKG-INFO +1 -1
  2. {tina4_python-3.13.151 → tina4_python-3.13.152}/pyproject.toml +1 -1
  3. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/__init__.py +1 -1
  4. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/cli/__init__.py +154 -33
  5. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/core/server.py +3 -2
  6. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/database/postgres.py +89 -3
  7. {tina4_python-3.13.151 → tina4_python-3.13.152}/.gitignore +0 -0
  8. {tina4_python-3.13.151 → tina4_python-3.13.152}/COMMERCIAL-LICENSE.md +0 -0
  9. {tina4_python-3.13.151 → tina4_python-3.13.152}/LICENSE +0 -0
  10. {tina4_python-3.13.151 → tina4_python-3.13.152}/NOTICE +0 -0
  11. {tina4_python-3.13.151 → tina4_python-3.13.152}/README.md +0 -0
  12. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/.tina4-metrics.json +0 -0
  13. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/CLAUDE.md +0 -0
  14. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/HtmlElement.py +0 -0
  15. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/Testing.py +0 -0
  16. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/_import_helper.py +0 -0
  17. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/ai/__init__.py +0 -0
  18. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/ai/client.py +0 -0
  19. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/api/__init__.py +0 -0
  20. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/auth/__init__.py +0 -0
  21. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/cache/__init__.py +0 -0
  22. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/container/__init__.py +0 -0
  23. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/context/__init__.py +0 -0
  24. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/context/chunker.py +0 -0
  25. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/core/__init__.py +0 -0
  26. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/core/cache.py +0 -0
  27. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/core/constants.py +0 -0
  28. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/core/csp.py +0 -0
  29. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/core/events.py +0 -0
  30. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/core/middleware.py +0 -0
  31. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/core/port_takeover.py +0 -0
  32. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/core/rate_limiter.py +0 -0
  33. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/core/request.py +0 -0
  34. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/core/response.py +0 -0
  35. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/core/router.py +0 -0
  36. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/crud/__init__.py +0 -0
  37. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/crud/page.py +0 -0
  38. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/crud/page_render.py +0 -0
  39. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/database/__init__.py +0 -0
  40. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/database/adapter.py +0 -0
  41. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/database/async_api.py +0 -0
  42. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/database/connection.py +0 -0
  43. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/database/database_url.py +0 -0
  44. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/database/firebird.py +0 -0
  45. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/database/mongodb.py +0 -0
  46. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/database/mssql.py +0 -0
  47. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/database/mysql.py +0 -0
  48. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/database/odbc.py +0 -0
  49. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/database/pool.py +0 -0
  50. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/database/sql_translator.py +0 -0
  51. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/database/sqlite.py +0 -0
  52. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/debug/__init__.py +0 -0
  53. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/debug/error_overlay.py +0 -0
  54. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/dev_admin/__init__.py +0 -0
  55. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/dev_admin/metrics.py +0 -0
  56. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/dev_admin/plan.py +0 -0
  57. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/dev_admin/project_index.py +0 -0
  58. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/docs.py +0 -0
  59. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/docstore/__init__.py +0 -0
  60. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/dotenv/__init__.py +0 -0
  61. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/env.py +0 -0
  62. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/frond/FROND.md +0 -0
  63. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/frond/__init__.py +0 -0
  64. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/frond/compiler.py +0 -0
  65. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/frond/engine.py +0 -0
  66. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/frond/parser.py +0 -0
  67. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/gallery/auth/meta.json +0 -0
  68. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/gallery/auth/src/routes/api/gallery_auth.py +0 -0
  69. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/gallery/database/meta.json +0 -0
  70. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/gallery/database/src/routes/api/gallery_db.py +0 -0
  71. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/gallery/error-overlay/meta.json +0 -0
  72. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/gallery/error-overlay/src/routes/api/gallery_crash.py +0 -0
  73. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/gallery/orm/meta.json +0 -0
  74. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/gallery/orm/src/orm/Product.py +0 -0
  75. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/gallery/orm/src/routes/api/gallery_products.py +0 -0
  76. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/gallery/queue/meta.json +0 -0
  77. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/gallery/queue/src/routes/api/gallery_queue.py +0 -0
  78. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/gallery/rest-api/meta.json +0 -0
  79. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/gallery/rest-api/src/routes/api/gallery_hello.py +0 -0
  80. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/gallery/templates/meta.json +0 -0
  81. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/gallery/templates/src/routes/gallery_page.py +0 -0
  82. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/gallery/templates/src/templates/gallery_page.twig +0 -0
  83. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/graph/__init__.py +0 -0
  84. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/graph/adapter.py +0 -0
  85. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/graph/adapters/__init__.py +0 -0
  86. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/graph/adapters/arango.py +0 -0
  87. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/graph/adapters/bolt.py +0 -0
  88. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/graph/adapters/ultipa.py +0 -0
  89. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/graph/graph_url.py +0 -0
  90. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/graphql/__init__.py +0 -0
  91. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/i18n/__init__.py +0 -0
  92. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/mcp/__init__.py +0 -0
  93. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/mcp/protocol.py +0 -0
  94. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/mcp/tools.py +0 -0
  95. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/messenger/__init__.py +0 -0
  96. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/migration/__init__.py +0 -0
  97. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/migration/runner.py +0 -0
  98. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/mqtt/__init__.py +0 -0
  99. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/mqtt/message.py +0 -0
  100. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/orm/__init__.py +0 -0
  101. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/orm/async_api.py +0 -0
  102. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/orm/collection.py +0 -0
  103. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/orm/fields.py +0 -0
  104. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/orm/model.py +0 -0
  105. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/orm/point.py +0 -0
  106. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/public/THIRD-PARTY-NOTICES.md +0 -0
  107. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/public/__feedback/widget.js +0 -0
  108. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/public/bundled-component-provenance.json +0 -0
  109. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/public/css/tina4.css +0 -0
  110. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/public/css/tina4.min.css +0 -0
  111. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/public/favicon.ico +0 -0
  112. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/public/images/logo.svg +0 -0
  113. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/public/images/tina4-logo-icon.webp +0 -0
  114. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/public/js/frond.js +0 -0
  115. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/public/js/frond.min.js +0 -0
  116. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/public/js/tina4-dev-admin-split.html +0 -0
  117. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/public/js/tina4-dev-admin.min.js +0 -0
  118. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/public/js/tina4.min.js +0 -0
  119. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/public/js/tina4js.min.js +0 -0
  120. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/public/licenses/swagger-ui-3.10.0-original-notice.txt +0 -0
  121. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/public/licenses/swagger-ui-5.17.14-NOTICE.txt +0 -0
  122. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/public/licenses/swagger-ui-Apache-2.0.txt +0 -0
  123. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/public/licenses/tina4-css-MIT.txt +0 -0
  124. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/public/licenses/tina4-dev-admin-components.json +0 -0
  125. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/public/licenses/tina4-dev-admin-third-party.txt +0 -0
  126. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/public/licenses/tina4-js-MIT.txt +0 -0
  127. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/public/swagger/index.html +0 -0
  128. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/public/swagger/oauth2-redirect.html +0 -0
  129. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/push/__init__.py +0 -0
  130. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/push/_base.py +0 -0
  131. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/push/_cryptography.py +0 -0
  132. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/push/_libcrypto.py +0 -0
  133. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/query_builder/__init__.py +0 -0
  134. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/queue/__init__.py +0 -0
  135. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/queue/amqp_url.py +0 -0
  136. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/queue/job.py +0 -0
  137. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/queue/kafka_backend.py +0 -0
  138. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/queue/lite_backend.py +0 -0
  139. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/queue/mongo_backend.py +0 -0
  140. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/queue/rabbitmq_backend.py +0 -0
  141. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/queue/topic_dead_letter.py +0 -0
  142. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/queue_backends/__init__.py +0 -0
  143. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/queue_backends/kafka_backend.py +0 -0
  144. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/queue_backends/mongo_backend.py +0 -0
  145. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/queue_backends/rabbitmq_backend.py +0 -0
  146. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/realtime/__init__.py +0 -0
  147. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/realtime/models/Attachment.py +0 -0
  148. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/realtime/models/Channel.py +0 -0
  149. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/realtime/models/ChannelMember.py +0 -0
  150. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/realtime/models/Message.py +0 -0
  151. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/realtime/models/Workspace.py +0 -0
  152. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/realtime/models/__init__.py +0 -0
  153. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/realtime/s3_client.py +0 -0
  154. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/realtime/storage.py +0 -0
  155. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/seeder/__init__.py +0 -0
  156. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/service/__init__.py +0 -0
  157. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/session/__init__.py +0 -0
  158. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/session_handlers/__init__.py +0 -0
  159. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/session_handlers/memcached_handler.py +0 -0
  160. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/session_handlers/mongodb_handler.py +0 -0
  161. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/session_handlers/redis_handler.py +0 -0
  162. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/session_handlers/valkey_handler.py +0 -0
  163. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/sso.py +0 -0
  164. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/ssrf.py +0 -0
  165. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/swagger/__init__.py +0 -0
  166. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/templates/components/crud.twig +0 -0
  167. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/templates/crud/form.twig +0 -0
  168. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/templates/crud/modals.twig +0 -0
  169. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/templates/crud/page.twig +0 -0
  170. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/templates/crud/table.twig +0 -0
  171. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/templates/docker/distroless/Dockerfile +0 -0
  172. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/templates/docker/poetry/Dockerfile +0 -0
  173. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/templates/docker/python/Dockerfile +0 -0
  174. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/templates/docker/uv/Dockerfile +0 -0
  175. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/templates/errors/302.twig +0 -0
  176. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/templates/errors/401.twig +0 -0
  177. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/templates/errors/403.twig +0 -0
  178. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/templates/errors/404.twig +0 -0
  179. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/templates/errors/500.twig +0 -0
  180. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/templates/errors/502.twig +0 -0
  181. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/templates/errors/503.twig +0 -0
  182. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/templates/errors/base.twig +0 -0
  183. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/templates/frontend/README.md +0 -0
  184. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/templates/readme.md +0 -0
  185. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/test/__init__.py +0 -0
  186. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/test_client/__init__.py +0 -0
  187. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/translations/af/LC_MESSAGES/messages.mo +0 -0
  188. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/translations/af/LC_MESSAGES/messages.po +0 -0
  189. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/translations/en/LC_MESSAGES/messages.mo +0 -0
  190. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/translations/en/LC_MESSAGES/messages.po +0 -0
  191. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/translations/es/LC_MESSAGES/messages.mo +0 -0
  192. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/translations/es/LC_MESSAGES/messages.po +0 -0
  193. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/translations/fr/LC_MESSAGES/messages.mo +0 -0
  194. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/translations/fr/LC_MESSAGES/messages.po +0 -0
  195. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/translations/ja/LC_MESSAGES/messages.mo +0 -0
  196. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/translations/ja/LC_MESSAGES/messages.po +0 -0
  197. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/translations/zh/LC_MESSAGES/messages.mo +0 -0
  198. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/translations/zh/LC_MESSAGES/messages.po +0 -0
  199. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/validator/__init__.py +0 -0
  200. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/websocket/__init__.py +0 -0
  201. {tina4_python-3.13.151 → tina4_python-3.13.152}/tina4_python/websocket/backplane.py +0 -0
  202. {tina4_python-3.13.151 → tina4_python-3.13.152}/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.151
3
+ Version: 3.13.152
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
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "tina4-python"
3
- version = "3.13.151"
3
+ version = "3.13.152"
4
4
  description = "Tina4 Python v3 — Zero-dependency, lightweight web framework"
5
5
  authors = [
6
6
  {name = "Andre van Zuydam", email = "andrevanzuydam@gmail.com"}
@@ -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.151"
60
+ return "3.13.152"
61
61
 
62
62
 
63
63
  __version__ = _resolve_version()
@@ -25,6 +25,7 @@ and reached by DELEGATION (see DELEGATED / _delegate_to_client below), so
25
25
  `tina4python doctor` behaves exactly like `tina4 doctor` without cloning the
26
26
  client's implementation into four languages.
27
27
  """
28
+ import difflib
28
29
  import os
29
30
  import re
30
31
  import secrets
@@ -176,13 +177,18 @@ def _parse_flags(args: list[str]) -> tuple[dict, list[str]]:
176
177
  """Parse --key value and --flag from args. Returns (flags, positional)."""
177
178
  # Boolean-only flags that never take a value argument
178
179
  boolean_flags = {"no-browser", "no-reload", "no-kill", "production", "managed", "all", "clear",
179
- "json", "public", "no-migration", "once", "dry-run", "fix", "no-install"}
180
+ "json", "public", "no-migration", "no-templates", "skip-model", "once", "dry-run",
181
+ "fix", "no-install"}
180
182
 
181
183
  flags = {}
182
184
  positional = []
183
185
  i = 0
184
186
  while i < len(args):
185
- if args[i].startswith("--"):
187
+ if args[i].startswith("--") and "=" in args[i]:
188
+ key, _, value = args[i][2:].partition("=")
189
+ flags[key] = value
190
+ i += 1
191
+ elif args[i].startswith("--"):
186
192
  key = args[i][2:]
187
193
  if key in boolean_flags:
188
194
  flags[key] = True
@@ -381,10 +387,13 @@ def _delegate_to_client(command: str, args: list) -> int:
381
387
 
382
388
  # ── Main entry point ─────────────────────────────────────────────────
383
389
 
390
+ HELP_FLAGS = ("--help", "-h")
391
+
392
+
384
393
  def main():
385
394
  """CLI entry point."""
386
395
  args = sys.argv[1:]
387
- if not args:
396
+ if not args or args[0].lower() in HELP_FLAGS:
388
397
  _help()
389
398
  return
390
399
 
@@ -396,6 +405,15 @@ def main():
396
405
  # `commands --json` manifest, so dispatch, help, and discovery never drift.
397
406
  spec = COMMANDS.get(command)
398
407
  if spec:
408
+ # `--help` / `-h` anywhere after a command prints that command's usage
409
+ # and touches nothing. Handlers never looked for it, so it ran the
410
+ # command for real: `generate model --help` wrote a model named
411
+ # `--help`, `lint --help` installed ruff, `migrate --help` made app.db.
412
+ # Delegated commands are left alone - the client answers --help itself.
413
+ if command != "help" and any(a in HELP_FLAGS for a in cmd_args):
414
+ _command_help(command, cmd_args)
415
+ return
416
+ _check_options(command, cmd_args)
399
417
  spec["handler"](cmd_args)
400
418
  elif command in DELEGATED:
401
419
  sys.exit(_delegate_to_client(command, cmd_args))
@@ -453,6 +471,93 @@ def _env_migrate(args):
453
471
  print(f" original kept at {backup} (delete once you've verified)")
454
472
 
455
473
 
474
+ def _command_help(command: str, args: list) -> None:
475
+ """Usage for one command (or one generator), from the same registries."""
476
+ if command == "generate":
477
+ kind = next((a.lower() for a in args if not a.startswith("-")), None)
478
+ gen = GENERATORS.get(kind) if kind else None
479
+ if gen:
480
+ print(f"Usage: tina4python generate {kind} {gen.get('usage', '')}".rstrip())
481
+ print(f"\n {gen['summary']}")
482
+ return
483
+ print("Usage: tina4python generate <what> <name> [options]\n\nGenerators:")
484
+ pad = max(len(name) for name in GENERATORS)
485
+ for name, gen in GENERATORS.items():
486
+ print(f" {name:<{pad}} {gen['summary']}")
487
+ return
488
+ spec = COMMANDS[command]
489
+ print(f"Usage: tina4python {command} {spec.get('usage', '')}".rstrip())
490
+ print(f"\n {spec['summary']}")
491
+ if spec.get("subcommands"):
492
+ print(f" Subcommands: {', '.join(spec['subcommands'])}")
493
+
494
+
495
+ def _accepted_options(command: str, args: list) -> dict | None:
496
+ """The options `command` accepts ({name: takes_value}), or None when its
497
+ arguments are not ours to check (`test` hands them to pytest, an unknown
498
+ generator or queue subcommand is reported by its own handler)."""
499
+ if command == "generate":
500
+ kind = args[0].lower() if args else ""
501
+ gen = GENERATORS.get(kind)
502
+ if gen is None:
503
+ return None
504
+ accepted = dict(gen.get("flags", {}))
505
+ if kind in _RESOLUTION_TARGETS:
506
+ accepted.update(_RESOLUTION_FLAGS)
507
+ return accepted
508
+ if command == "queue":
509
+ return _QUEUE_FLAGS.get(args[0].lower() if args else "")
510
+ return COMMANDS[command].get("flags", {})
511
+
512
+
513
+ def _check_options(command: str, args: list) -> None:
514
+ """Refuse an option the command doesn't have, or a value option given no
515
+ value. Both used to slip through: `--feilds` was silently dropped (the
516
+ model came out without its fields) and a bare `--fields` crashed."""
517
+ accepted = _accepted_options(command, args)
518
+ if accepted is None:
519
+ return
520
+ label = f"{command} {args[0].lower()}" if command in ("generate", "queue") else command
521
+ i = 0
522
+ while i < len(args):
523
+ problem, consumed = _option_problem(args, i, accepted, label)
524
+ if problem:
525
+ print(problem)
526
+ sys.exit(1)
527
+ i += 1 + consumed
528
+
529
+
530
+ def _option_problem(args: list, i: int, accepted: dict, label: str) -> tuple[str | None, int]:
531
+ """What is wrong with args[i] (None if nothing), and how many following
532
+ arguments it consumes as its value."""
533
+ arg = args[i]
534
+ if not arg.startswith("-") or arg == "-":
535
+ return None, 0
536
+ name, has_value, _ = arg.lstrip("-").partition("=")
537
+ if not arg.startswith("--") or name not in accepted:
538
+ return _unknown_option_message(arg, name, accepted, label), 0
539
+ if not accepted[name] or has_value:
540
+ return None, 0
541
+ if i + 1 >= len(args) or args[i + 1].startswith("-"):
542
+ return f'Option --{name} for "{label}" needs a value: --{name} <value>', 0
543
+ return None, 1
544
+
545
+
546
+ def _unknown_option_message(arg: str, name: str, accepted: dict, label: str) -> str:
547
+ close = difflib.get_close_matches(name, list(accepted), n=1, cutoff=0.6)
548
+ hint = f" Did you mean --{close[0]}?" if close else ""
549
+ return (f'Unknown option {arg.partition("=")[0]} for "{label}".{hint}\n'
550
+ f'Run "tina4python {label} --help" for its options.')
551
+
552
+
553
+ def _reject_flag_like_name(name: str, what: str) -> None:
554
+ """Refuse a name that is really a mistyped option (`--fields` with no
555
+ name before it, `-x`): it would otherwise become a file called `--fields`."""
556
+ if name.startswith("-"):
557
+ print(f"Invalid {what} name: {name!r} - names can't start with '-'.")
558
+ sys.exit(1)
559
+
560
+
456
561
  def _help(args=None):
457
562
  """Print the human-readable command reference.
458
563
 
@@ -1130,7 +1235,7 @@ def _ai(args):
1130
1235
  """Install AI coding assistant context files."""
1131
1236
  from tina4_python.ai import show_menu, install_selected, install_context
1132
1237
 
1133
- if args and args[0].lower() == "all":
1238
+ if args and args[0].lower() in ("all", "--all"):
1134
1239
  install_context(".")
1135
1240
  else:
1136
1241
  selection = show_menu(".")
@@ -1156,6 +1261,8 @@ def _ai(args):
1156
1261
  # validator, seeder, websocket, listener, auth, test, form, view) keep their
1157
1262
  # existing behaviour — this is the minimum surface the plan calls out.
1158
1263
  _RESOLUTION_TARGETS = {"model", "route", "migration", "middleware", "queue"}
1264
+ # Options every resolution-aware generator accepts on top of its own.
1265
+ _RESOLUTION_FLAGS = {"json": False, "dry-run": False}
1159
1266
 
1160
1267
  # Envelope schema version. Bump when the SHAPE changes; adding an optional
1161
1268
  # key on the resolution object is not a break.
@@ -1659,6 +1766,8 @@ def _generate(args):
1659
1766
  sys.exit(1)
1660
1767
 
1661
1768
  name = args[1] if len(args) > 1 else ""
1769
+ if what not in no_name_generators:
1770
+ _reject_flag_like_name(name, what)
1662
1771
  flags, _ = _parse_flags(args[2:] if len(args) > 2 else [])
1663
1772
 
1664
1773
  # ADR-0062: the four wired generators expose a JSON envelope and a
@@ -1984,7 +2093,9 @@ def _gen_crud(name: str, flags: dict):
1984
2093
 
1985
2094
  # 1. Model + migration (emit_test=False — crud emits its own broader gate
1986
2095
  # test at step 4, so the sub-generators stay quiet to avoid double-emit).
1987
- _gen_model(name, flags, emit_test=False)
2096
+ # --skip-model: the model already exists (`generate model` suggests this).
2097
+ if "skip-model" not in flags:
2098
+ _gen_model(name, flags, emit_test=False)
1988
2099
 
1989
2100
  # 2. Admin page route: registers AutoCrud (secure-by-default; --public opens
1990
2101
  # writes) and renders the to_crud admin UI at /admin/<table>.
@@ -3908,6 +4019,14 @@ def _queue_clear(args):
3908
4019
 
3909
4020
  # Sub-dispatch table for the `queue` command — the single source for its
3910
4021
  # subcommands (drives _queue dispatch AND the manifest's queue.subcommands).
4022
+ # Options per queue subcommand (name -> takes a value), checked by main().
4023
+ _QUEUE_FLAGS = {
4024
+ "work": {"once": False, "poll": True, "services": True},
4025
+ "stats": {"json": False},
4026
+ "retry": {},
4027
+ "clear": {},
4028
+ }
4029
+
3911
4030
  _QUEUE_SUBCOMMANDS = {
3912
4031
  "work": _queue_work,
3913
4032
  "stats": _queue_stats,
@@ -4024,52 +4143,54 @@ def _commands(args=None):
4024
4143
  # (_help), AND the machine-readable manifest (commands --json). Add a command
4025
4144
  # in ONE place and it appears everywhere — there is no second list to sync.
4026
4145
  #
4027
- # GENERATORS[name] = {"handler": fn(name, flags), "usage": str, "summary": str}
4146
+ # GENERATORS[name] = {"handler": fn(name, flags), "flags": {...}, "usage": str, "summary": str}
4028
4147
  # COMMANDS[name] = {"handler": fn(args), "summary": str,
4148
+ # "flags"?: {name: bool}, # options main() accepts; True = takes a value.
4149
+ # # Absent = none. None = not checked (test -> pytest)
4029
4150
  # "usage"?: str, # arg/flag hint for _help (human only)
4030
4151
  # "args"?: [str], # positional args for the manifest ("x?" = optional)
4031
4152
  # "subcommands"?: [str]} # sub-names for the manifest (generate)
4032
4153
 
4033
4154
  GENERATORS = {
4034
- "model": {"handler": _gen_model, "usage": '<Name> [--fields "name:string,price:float"] [--table-name <name>]', "summary": "ORM model + matching migration"},
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)"},
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"},
4039
- "migration": {"handler": _gen_migration, "usage": "<description>", "summary": "Timestamped migration file (UP/DOWN)"},
4040
- "middleware": {"handler": _gen_middleware, "usage": "<Name>", "summary": "Middleware with before/after hooks"},
4041
- "test": {"handler": _gen_test, "usage": "<name> [--model Name]", "summary": "pytest test file"},
4042
- "form": {"handler": _gen_form, "usage": '<Name> [--fields "..."]', "summary": "Form template with inputs matching model fields"},
4043
- "view": {"handler": _gen_view, "usage": '<Name> [--fields "..."]', "summary": "List + detail view templates"},
4044
- "auth": {"handler": _gen_auth, "usage": "", "summary": "Login/register routes + User model + templates"},
4045
- "service": {"handler": _gen_service, "usage": '<Name> [--every 5m | --cron "..."]', "summary": "Scheduled ServiceRunner task (src/services/)"},
4046
- "queue": {"handler": _gen_queue, "usage": "<topic>", "summary": "Producer + consumer worker (src/services/)"},
4047
- "validator": {"handler": _gen_validator, "usage": "<Name>", "summary": "Request-body Validator (src/validators/)"},
4048
- "seeder": {"handler": _gen_seeder, "usage": "<Model>", "summary": "FakeData + seed_orm seeder (src/seeds/)"},
4049
- "websocket": {"handler": _gen_websocket, "usage": "<path>", "summary": "@websocket handler (src/routes/)"},
4050
- "listener": {"handler": _gen_listener, "usage": "<event>", "summary": "@on(event) listener (src/listeners/)"},
4155
+ "model": {"handler": _gen_model, "flags": {"fields": True, "table-name": True, "no-migration": False}, "usage": '<Name> [--fields "name:string,price:float"] [--table-name <name>]', "summary": "ORM model + matching migration"},
4156
+ "route": {"handler": _gen_route, "flags": {"model": True, "public": False}, "usage": "<name> [--model Name] [--public]", "summary": "CRUD route file, secure by default (--public opens writes)"},
4157
+ "base": {"handler": _gen_base, "flags": {}, "usage": "", "summary": "Frond base template + index page + pages/ folder"},
4158
+ "page": {"handler": _gen_page, "flags": {}, "usage": "<name>", "summary": "Page that extends base.twig (auto-creates pages/ + base)"},
4159
+ "crud": {"handler": _gen_crud, "flags": {"fields": True, "table-name": True, "public": False, "no-templates": False, "no-migration": False, "skip-model": False}, "usage": '<Name> [--fields "..."] [--public] [--no-templates] [--skip-model]', "summary": "Model + migration + AutoCrud-backed admin page (to_crud) + editable crud/ templates + gate test"},
4160
+ "migration": {"handler": _gen_migration, "flags": {"fields": True}, "usage": "<description>", "summary": "Timestamped migration file (UP/DOWN)"},
4161
+ "middleware": {"handler": _gen_middleware, "flags": {}, "usage": "<Name>", "summary": "Middleware with before/after hooks"},
4162
+ "test": {"handler": _gen_test, "flags": {"model": True, "public": False}, "usage": "<name> [--model Name]", "summary": "pytest test file"},
4163
+ "form": {"handler": _gen_form, "flags": {"fields": True, "table-name": True}, "usage": '<Name> [--fields "..."]', "summary": "Form template with inputs matching model fields"},
4164
+ "view": {"handler": _gen_view, "flags": {"fields": True, "table-name": True}, "usage": '<Name> [--fields "..."]', "summary": "List + detail view templates"},
4165
+ "auth": {"handler": _gen_auth, "flags": {"fields": True, "table-name": True, "no-migration": False}, "usage": "", "summary": "Login/register routes + User model + templates"},
4166
+ "service": {"handler": _gen_service, "flags": {"every": True, "cron": True}, "usage": '<Name> [--every 5m | --cron "..."]', "summary": "Scheduled ServiceRunner task (src/services/)"},
4167
+ "queue": {"handler": _gen_queue, "flags": {}, "usage": "<topic>", "summary": "Producer + consumer worker (src/services/)"},
4168
+ "validator": {"handler": _gen_validator, "flags": {}, "usage": "<Name>", "summary": "Request-body Validator (src/validators/)"},
4169
+ "seeder": {"handler": _gen_seeder, "flags": {"table-name": True}, "usage": "<Model>", "summary": "FakeData + seed_orm seeder (src/seeds/)"},
4170
+ "websocket": {"handler": _gen_websocket, "flags": {}, "usage": "<path>", "summary": "@websocket handler (src/routes/)"},
4171
+ "listener": {"handler": _gen_listener, "flags": {}, "usage": "<event>", "summary": "@on(event) listener (src/listeners/)"},
4051
4172
  }
4052
4173
 
4053
4174
  COMMANDS = {
4054
- "init": {"handler": _init, "usage": "[dir]", "args": ["dir?"], "summary": "Scaffold a new project"},
4055
- "serve": {"handler": _serve, "usage": "[--port P] [--no-browser] [--no-reload]", "summary": "Start dev server (default: 0.0.0.0:7146)"},
4056
- "start": {"handler": _serve, "summary": "Alias for serve"},
4175
+ "init": {"handler": _init, "flags": {"ai": False, "production": False}, "usage": "[dir]", "args": ["dir?"], "summary": "Scaffold a new project"},
4176
+ "serve": {"handler": _serve, "flags": {"port": True, "host": True, "no-browser": False, "no-reload": False, "no-kill": False, "production": False, "managed": False}, "usage": "[--port P] [--no-browser] [--no-reload]", "summary": "Start dev server (default: 0.0.0.0:7146)"},
4177
+ "start": {"handler": _serve, "flags": {"port": True, "host": True, "no-browser": False, "no-reload": False, "no-kill": False, "production": False, "managed": False}, "summary": "Alias for serve"},
4057
4178
  "migrate": {"handler": _migrate, "summary": "Run pending database migrations"},
4058
- "migrate:create": {"handler": _migrate_create, "usage": "<desc>", "args": ["description"], "summary": "Create a new migration file"},
4179
+ "migrate:create": {"handler": _migrate_create, "flags": {"fields": True, "table-name": True, "json": False, "dry-run": False}, "usage": "<desc>", "args": ["description"], "summary": "Create a new migration file"},
4059
4180
  "migrate:rollback": {"handler": _migrate_rollback, "summary": "Rollback last migration batch"},
4060
4181
  "migrate:status": {"handler": _migrate_status, "summary": "Show migration status"},
4061
4182
  "env-migrate": {"handler": _env_migrate, "usage": "[path]", "args": ["path?"], "summary": "Rewrite .env to TINA4_-prefixed names (v3.12 migration)"},
4062
4183
  "seed": {"handler": _seed, "summary": "Run database seeders"},
4063
4184
  "routes": {"handler": _routes, "summary": "List all registered routes"},
4064
- "test": {"handler": _test, "summary": "Run test suite"},
4185
+ "test": {"handler": _test, "flags": None, "summary": "Run test suite"},
4065
4186
  "queue": {"handler": _queue, "usage": "<work|stats|retry|clear> [topic]", "subcommands": list(_QUEUE_SUBCOMMANDS), "summary": "Run queue workers and manage jobs"},
4066
- "build": {"handler": _build, "usage": "[--tag NAME] [--file PATH]", "summary": "Build the deployable Docker image"},
4067
- "lint": {"handler": _lint, "usage": "[--fix] [--no-install]", "summary": "Lint src/ + app.py (installs ruff dev-only on demand; zero-dep syntax baseline with --no-install)"},
4068
- "ai": {"handler": _ai, "usage": "[--all]", "summary": "Install AI coding assistant context"},
4187
+ "build": {"handler": _build, "flags": {"tag": True, "file": True}, "usage": "[--tag NAME] [--file PATH]", "summary": "Build the deployable Docker image"},
4188
+ "lint": {"handler": _lint, "flags": {"fix": False, "no-install": False}, "usage": "[--fix] [--no-install]", "summary": "Lint src/ + app.py (installs ruff dev-only on demand; zero-dep syntax baseline with --no-install)"},
4189
+ "ai": {"handler": _ai, "flags": {"all": False}, "usage": "[--all]", "summary": "Install AI coding assistant context"},
4069
4190
  "generate": {"handler": _generate, "usage": "<what> <name> [options]", "subcommands": list(GENERATORS), "summary": "Generate scaffolding (see Generators below)"},
4070
4191
  "console": {"handler": _console, "summary": "Start interactive REPL with framework loaded"},
4071
- "commands": {"handler": _commands, "usage": "[--json]", "summary": "List available commands (add --json for machine form)"},
4072
- "help": {"handler": _help, "summary": "Show this help"},
4192
+ "commands": {"handler": _commands, "flags": {"json": False}, "usage": "[--json]", "summary": "List available commands (add --json for machine form)"},
4193
+ "help": {"handler": _help, "flags": None, "summary": "Show this help"},
4073
4194
  }
4074
4195
 
4075
4196
  # Commands the `tina4` client OWNS and this CLI reaches by delegation — see the
@@ -1657,9 +1657,10 @@ async def _handle_dev_admin(request: Request, response: Response) -> Response:
1657
1657
  from tina4_python.dev_admin import get_api_handlers, _dev_request_denial, split_view_html
1658
1658
  # ADR-0082: ONE gate for every /__dev request, reads and writes alike -
1659
1659
  # Host allow-list (DNS rebinding), same-origin (CSRF and cross-site reads)
1660
- # and loopback peer. Scoped to /__dev so the deliberately cross-origin
1660
+ # and loopback peer. Scoped to /__dev and the dev-admin routes outside it
1661
+ # (the AI proxy and service probes) so the deliberately cross-origin
1661
1662
  # /__feedback widget is unaffected.
1662
- if request.path.startswith("/__dev"):
1663
+ if request.path.startswith("/__dev") or request.path in _DEV_EXTRA_PATHS:
1663
1664
  _denial = _dev_request_denial(request)
1664
1665
  if _denial is not None:
1665
1666
  response.status(_denial[0]).json({"ok": False, "error": _denial[1]})
@@ -33,6 +33,7 @@ class PostgreSQLAdapter(SqlCrudMixin, DatabaseAdapter):
33
33
  def __init__(self):
34
34
  super().__init__()
35
35
  self._conn = None
36
+ self._connect_args = None
36
37
  self._in_transaction: bool = False
37
38
  self.last_error: str | None = None
38
39
 
@@ -147,11 +148,92 @@ class PostgreSQLAdapter(SqlCrudMixin, DatabaseAdapter):
147
148
  diagnose, and the heal step also defers to explicit txns.
148
149
  """
149
150
  self._heal_aborted_txn()
151
+ nothing_pending = self._nothing_pending()
152
+ try:
153
+ self._safe_execute(cursor, sql, params)
154
+ return cursor
155
+ except Exception as e:
156
+ if self._in_transaction or not self._connection_is_dead():
157
+ self._on_query_error(e, sql, params)
158
+ raise
159
+ self._reconnect()
160
+ if not nothing_pending:
161
+ # Uncommitted work went down with the old connection, so the
162
+ # statement is not retried on its own; the caller sees the error.
163
+ self._on_query_error(e, sql, params)
164
+ raise
165
+ self._log_reconnect_retry(e, sql)
166
+ cursor = self._conn.cursor(cursor_factory=type(cursor))
150
167
  try:
151
168
  self._safe_execute(cursor, sql, params)
152
169
  except Exception as e:
153
170
  self._on_query_error(e, sql, params)
154
171
  raise
172
+ return cursor
173
+
174
+ def _connection_is_dead(self) -> bool:
175
+ """True when psycopg2 has marked the link closed under us (the server
176
+ dropped it, or the socket was reset). An adapter the caller closed
177
+ itself has ``_conn = None`` and is not "dead" - it stays closed.
178
+ """
179
+ return self._conn is not None and self._conn.closed != 0
180
+
181
+ def _nothing_pending(self) -> bool:
182
+ """True when the connection holds no uncommitted work, so a statement
183
+ that fails because the link died can be run again on a new one."""
184
+ try:
185
+ import psycopg2.extensions as _ext
186
+ return self._conn.info.transaction_status == _ext.TRANSACTION_STATUS_IDLE
187
+ except Exception:
188
+ return False
189
+
190
+ def _reconnect(self):
191
+ """Replace a dropped connection with a new one, opened from the
192
+ arguments the original :meth:`connect` received. Session state set with
193
+ ``SET`` after connecting does not carry over; connect ``options`` do.
194
+ """
195
+ try:
196
+ self._conn.close()
197
+ except Exception:
198
+ pass
199
+ connection_string, username, password, kwargs = self._connect_args
200
+ self.connect(connection_string, username, password, **kwargs)
201
+ try:
202
+ from tina4_python.debug import Log
203
+ Log.warning("PostgreSQL connection was closed by the server - reconnected.")
204
+ except Exception:
205
+ pass
206
+
207
+ def _ensure_connection(self):
208
+ """Rebuild a server-dropped connection BEFORE a cursor is opened on it.
209
+
210
+ #236 recovers a link that dies DURING a statement, but execute()/fetch()
211
+ build the cursor first, and ``self._conn.cursor()`` raises
212
+ ``InterfaceError: connection already closed`` on an already-closed link,
213
+ before the reconnect path can run. That is the state a FAILED reconnect
214
+ leaves behind - a failover where ``_reconnect`` closed the old link and
215
+ the replacement connect could not reach the new primary - after which
216
+ every later statement wedged there until the process restarted (#242).
217
+ Healing here, when the link is dead and no explicit transaction owns it,
218
+ lets a later statement recover once the server returns. A reconnect that
219
+ fails again propagates, but leaves the link dead, so the NEXT statement
220
+ retries rather than giving up for good.
221
+ """
222
+ if not self._in_transaction and self._connection_is_dead():
223
+ self._reconnect()
224
+
225
+ def _log_reconnect_retry(self, exc: Exception, sql: str):
226
+ try:
227
+ from tina4_python.debug import Log
228
+ preview = sql.strip().splitlines()[0][:200] if sql else "<no sql>"
229
+ Log.warning(
230
+ f"PostgreSQL statement hit a dropped connection "
231
+ f"({exc.__class__.__name__}: {str(exc).strip()}) - retrying once "
232
+ f"on the new connection.",
233
+ sql=preview,
234
+ )
235
+ except Exception:
236
+ pass
155
237
 
156
238
  def _on_query_error(self, exc: Exception, sql: str, params=None):
157
239
  """Handle a failed query: log, store, auto-rollback if implicit.
@@ -286,6 +368,7 @@ class PostgreSQLAdapter(SqlCrudMixin, DatabaseAdapter):
286
368
  " uv add tina4-python[all-db] # all five database drivers"
287
369
  )
288
370
 
371
+ self._connect_args = (connection_string, username, password, dict(kwargs))
289
372
  parsed = urlparse(connection_string)
290
373
 
291
374
  # Percent-DECODED: urlparse leaves userinfo escaped.
@@ -328,8 +411,9 @@ class PostgreSQLAdapter(SqlCrudMixin, DatabaseAdapter):
328
411
  re.search(r"\bRETURNING\b", sql, re.IGNORECASE)
329
412
  )
330
413
 
414
+ self._ensure_connection()
331
415
  cursor = self._conn.cursor(cursor_factory=psycopg2.extras.RealDictCursor)
332
- self._exec_with_handling(cursor, sql, params)
416
+ cursor = self._exec_with_handling(cursor, sql, params)
333
417
 
334
418
  # Capture rowcount NOW, before the lastval()/SAVEPOINT probes below run
335
419
  # their own cursor.execute() calls and overwrite cursor.rowcount. A
@@ -424,6 +508,7 @@ class PostgreSQLAdapter(SqlCrudMixin, DatabaseAdapter):
424
508
  # (2.28x), byte-identical output incl. native types (int/bool/Decimal/None)
425
509
  # -- cursor_factory only chooses the row CONTAINER, never value coercion,
426
510
  # so psycopg2's type adaptation is unchanged.
511
+ self._ensure_connection()
427
512
  cursor = self._conn.cursor()
428
513
 
429
514
  # #133: a write that returns rows (INSERT ... RETURNING) can be
@@ -441,7 +526,7 @@ class PostgreSQLAdapter(SqlCrudMixin, DatabaseAdapter):
441
526
  # crashed on the server, which is the swap ADR-0024 exists to protect.
442
527
  paginated = not (is_write or limit is None or limit <= 0 or self._has_trailing_limit(sql))
443
528
  paginated_sql, paginated_params = self._paginate_sql(sql, params, limit, offset, paginated)
444
- self._exec_with_handling(cursor, paginated_sql, paginated_params)
529
+ cursor = self._exec_with_handling(cursor, paginated_sql, paginated_params)
445
530
  columns = [d[0] for d in cursor.description] if cursor.description else []
446
531
  indexes = range(len(columns))
447
532
  rows = [
@@ -501,8 +586,9 @@ class PostgreSQLAdapter(SqlCrudMixin, DatabaseAdapter):
501
586
  # v3.13.12: see fetch() — trailing semicolons break the wrappers.
502
587
  sql = self._strip_trailing_semicolons(sql)
503
588
  sql = self._translate_sql(sql, bool(params))
589
+ self._ensure_connection()
504
590
  cursor = self._conn.cursor(cursor_factory=psycopg2.extras.RealDictCursor)
505
- self._exec_with_handling(cursor, sql, params)
591
+ cursor = self._exec_with_handling(cursor, sql, params)
506
592
  row = cursor.fetchone()
507
593
  result = self._decode_blobs(dict(row)) if row else None
508
594
  # v3.13.15 (#51): close the implicit transaction so the connection
File without changes
File without changes