tina4-python 0.2.110__tar.gz → 0.2.111__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 (48) hide show
  1. {tina4_python-0.2.110 → tina4_python-0.2.111}/PKG-INFO +1 -1
  2. {tina4_python-0.2.110 → tina4_python-0.2.111}/pyproject.toml +1 -1
  3. {tina4_python-0.2.110 → tina4_python-0.2.111}/tina4_python/Database.py +5 -2
  4. {tina4_python-0.2.110 → tina4_python-0.2.111}/tina4_python/ORM.py +5 -5
  5. {tina4_python-0.2.110 → tina4_python-0.2.111}/tina4_python/Router.py +12 -1
  6. {tina4_python-0.2.110 → tina4_python-0.2.111}/tina4_python/Webserver.py +22 -6
  7. {tina4_python-0.2.110 → tina4_python-0.2.111}/tina4_python/__init__.py +1 -1
  8. {tina4_python-0.2.110 → tina4_python-0.2.111}/.gitignore +0 -0
  9. {tina4_python-0.2.110 → tina4_python-0.2.111}/README.md +0 -0
  10. {tina4_python-0.2.110 → tina4_python-0.2.111}/tina4_python/Auth.py +0 -0
  11. {tina4_python-0.2.110 → tina4_python-0.2.111}/tina4_python/Constant.py +0 -0
  12. {tina4_python-0.2.110 → tina4_python-0.2.111}/tina4_python/DatabaseResult.py +0 -0
  13. {tina4_python-0.2.110 → tina4_python-0.2.111}/tina4_python/DatabaseTypes.py +0 -0
  14. {tina4_python-0.2.110 → tina4_python-0.2.111}/tina4_python/Debug.py +0 -0
  15. {tina4_python-0.2.110 → tina4_python-0.2.111}/tina4_python/Env.py +0 -0
  16. {tina4_python-0.2.110 → tina4_python-0.2.111}/tina4_python/Localization.py +0 -0
  17. {tina4_python-0.2.110 → tina4_python-0.2.111}/tina4_python/Messages.py +0 -0
  18. {tina4_python-0.2.110 → tina4_python-0.2.111}/tina4_python/MiddleWare.py +0 -0
  19. {tina4_python-0.2.110 → tina4_python-0.2.111}/tina4_python/Migration.py +0 -0
  20. {tina4_python-0.2.110 → tina4_python-0.2.111}/tina4_python/Queue.py +0 -0
  21. {tina4_python-0.2.110 → tina4_python-0.2.111}/tina4_python/Request.py +0 -0
  22. {tina4_python-0.2.110 → tina4_python-0.2.111}/tina4_python/Response.py +0 -0
  23. {tina4_python-0.2.110 → tina4_python-0.2.111}/tina4_python/Session.py +0 -0
  24. {tina4_python-0.2.110 → tina4_python-0.2.111}/tina4_python/ShellColors.py +0 -0
  25. {tina4_python-0.2.110 → tina4_python-0.2.111}/tina4_python/Swagger.py +0 -0
  26. {tina4_python-0.2.110 → tina4_python-0.2.111}/tina4_python/Template.py +0 -0
  27. {tina4_python-0.2.110 → tina4_python-0.2.111}/tina4_python/Websocket.py +0 -0
  28. {tina4_python-0.2.110 → tina4_python-0.2.111}/tina4_python/messages.pot +0 -0
  29. {tina4_python-0.2.110 → tina4_python-0.2.111}/tina4_python/public/css/readme.md +0 -0
  30. {tina4_python-0.2.110 → tina4_python-0.2.111}/tina4_python/public/favicon.ico +0 -0
  31. {tina4_python-0.2.110 → tina4_python-0.2.111}/tina4_python/public/images/403.png +0 -0
  32. {tina4_python-0.2.110 → tina4_python-0.2.111}/tina4_python/public/images/404.png +0 -0
  33. {tina4_python-0.2.110 → tina4_python-0.2.111}/tina4_python/public/images/500.png +0 -0
  34. {tina4_python-0.2.110 → tina4_python-0.2.111}/tina4_python/public/images/logo.png +0 -0
  35. {tina4_python-0.2.110 → tina4_python-0.2.111}/tina4_python/public/images/readme.md +0 -0
  36. {tina4_python-0.2.110 → tina4_python-0.2.111}/tina4_python/public/js/readme.md +0 -0
  37. {tina4_python-0.2.110 → tina4_python-0.2.111}/tina4_python/public/js/reconnecting-websocket.js +0 -0
  38. {tina4_python-0.2.110 → tina4_python-0.2.111}/tina4_python/public/js/tina4helper.js +0 -0
  39. {tina4_python-0.2.110 → tina4_python-0.2.111}/tina4_python/public/swagger/index.html +0 -0
  40. {tina4_python-0.2.110 → tina4_python-0.2.111}/tina4_python/public/swagger/oauth2-redirect.html +0 -0
  41. {tina4_python-0.2.110 → tina4_python-0.2.111}/tina4_python/templates/errors/403.twig +0 -0
  42. {tina4_python-0.2.110 → tina4_python-0.2.111}/tina4_python/templates/errors/404.twig +0 -0
  43. {tina4_python-0.2.110 → tina4_python-0.2.111}/tina4_python/templates/errors/500.twig +0 -0
  44. {tina4_python-0.2.110 → tina4_python-0.2.111}/tina4_python/templates/readme.md +0 -0
  45. {tina4_python-0.2.110 → tina4_python-0.2.111}/tina4_python/translations/en/LC_MESSAGES/messages.mo +0 -0
  46. {tina4_python-0.2.110 → tina4_python-0.2.111}/tina4_python/translations/en/LC_MESSAGES/messages.po +0 -0
  47. {tina4_python-0.2.110 → tina4_python-0.2.111}/tina4_python/translations/fr/LC_MESSAGES/messages.mo +0 -0
  48. {tina4_python-0.2.110 → tina4_python-0.2.111}/tina4_python/translations/fr/LC_MESSAGES/messages.po +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: tina4-python
3
- Version: 0.2.110
3
+ Version: 0.2.111
4
4
  Summary: Tina4Python - This is not another framework for Python
5
5
  Author-email: Andre van Zuydam <andrevanzuydam@gmail.com>
6
6
  Requires-Python: <4.0,>=3.12
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "tina4-python"
3
- version = "0.2.110"
3
+ version = "0.2.111"
4
4
  description = "Tina4Python - This is not another framework for Python"
5
5
  authors = [
6
6
  {name = "Andre van Zuydam",email = "andrevanzuydam@gmail.com"}
@@ -141,7 +141,6 @@ class Database:
141
141
  :return: bool : True if table exists, else False
142
142
  """
143
143
 
144
- sql = ""
145
144
  if self.database_engine == MSSQL:
146
145
  sql = "select count(*) as count_table from sys.tables WHERE name = '"+table_name.upper()+"'"
147
146
  elif self.database_engine == SQLITE:
@@ -158,7 +157,11 @@ class Database:
158
157
  else:
159
158
  return False
160
159
 
161
- record = self.fetch_one(sql)
160
+ try:
161
+ record = self.fetch_one(sql)
162
+ except Exception as e:
163
+ raise Exception (f"Error checking if table {table_name} exists: "+str(e))
164
+
162
165
  if record:
163
166
  if record["count_table"] > 0:
164
167
  return True
@@ -330,16 +330,16 @@ class ORM:
330
330
  self.__populate_orm({})
331
331
 
332
332
  # Debug("Checking for", self.__table_name__, TINA4_LOG_INFO)
333
- if self.__dba__:
333
+ if self.__dba__ is not None:
334
334
  self.__table_exists = self.__dba__.table_exists(self.__table_name__)
335
335
  if not self.__table_exists:
336
336
  sql = self.__create_table__(self.__table_name__)
337
337
  filename = root_path + os.sep + "migrations" + os.sep + "__" + self.__table_name__ + ".sql"
338
338
  os.makedirs(os.path.dirname(filename), exist_ok=True)
339
- with open(filename, "w") as f:
340
- f.write(sql)
341
- f.close()
342
- # Debug("Table Exists", self.__table_exists, TINA4_LOG_INFO)
339
+ #with open(filename, "w") as f:
340
+ # f.write(sql)
341
+ # f.close()
342
+ Debug.warning("Create Table ? ", sql)
343
343
  else:
344
344
  self.__table_exists = False
345
345
 
@@ -143,6 +143,7 @@ class Router:
143
143
  Request.headers = headers # Add the headers
144
144
  Request.params = request["params"]
145
145
  Request.body = request["body"] if "body" in request else None
146
+ Request.files = request["files"] if "files" in request else None
146
147
  Request.session = session
147
148
  Request.raw_data = request["raw_data"] if "raw_data" in request else None
148
149
  Request.raw_request = request["raw_request"] if "raw_request" in request else None
@@ -151,6 +152,7 @@ class Router:
151
152
  Request.transport = request["transport"] if "transport" in request else None
152
153
  Request.asgi_response = request["asgi_response"] if "asgi_response" in request else None
153
154
 
155
+
154
156
  tina4_python.tina4_current_request = Request
155
157
 
156
158
  old_stdout = sys.stdout # Memorize the default stdout stream
@@ -166,7 +168,16 @@ class Router:
166
168
  Request, Response = middleware_runner.call_before_methods(Request, Response)
167
169
  Request, Response = middleware_runner.call_any_methods(Request, Response)
168
170
 
169
- result = await router_response(request=Request, response=Response.Response)
171
+ try:
172
+ result = await router_response(request=Request, response=Response.Response)
173
+ except Exception as e:
174
+ error_string = tina4_python.global_exception_handler(e)
175
+ if Constant.TINA4_LOG_DEBUG in os.getenv("TINA4_DEBUG_LEVEL") or Constant.TINA4_LOG_ALL in os.getenv("TINA4_DEBUG_LEVEL"):
176
+ html = Template.render_twig_template("errors/500.twig",
177
+ {"server": {"url": url}, "error_message": error_string})
178
+ return Response.Response(html, Constant.HTTP_SERVER_ERROR, Constant.TEXT_HTML)
179
+ else:
180
+ return Response.Response(error_string, Constant.HTTP_SERVER_ERROR, Constant.TEXT_HTML)
170
181
 
171
182
  # we have found a result ... make sure we reflect this if the user didn't actually put the correct http response code in
172
183
  if result is not None:
@@ -64,6 +64,7 @@ class Webserver:
64
64
  content = b"\r\n" + content
65
65
  data_array = content.split(str.encode(boundary))
66
66
  body = {}
67
+ files = {}
67
68
  for data in data_array:
68
69
  data = data.split(b"\r\n\r\n")
69
70
  data_names = data[0].decode("utf-8").split("; ")
@@ -91,10 +92,24 @@ class Webserver:
91
92
  if "Content-Type" in meta_data:
92
93
  content_type = meta_data["Content-Type"]
93
94
 
94
- body[key_name] = {"file_name": file_name, "content_type": content_type,
95
- "content": base64.encodebytes(data_value).decode("utf-8").replace(
96
- "\n", "")}
97
- return body
95
+
96
+ if key_name in body:
97
+ body[key_name] = [body[key_name]]
98
+ body[key_name].append({"file_name": file_name, "content_type": content_type,"content": base64.encodebytes(data_value).decode("utf-8").replace(
99
+ "\n", "")})
100
+ else:
101
+ body[key_name] = {"file_name": file_name, "content_type": content_type,"content": base64.encodebytes(data_value).decode("utf-8").replace(
102
+ "\n", "")}
103
+
104
+ if key_name in files:
105
+ files[key_name] = [files[key_name]]
106
+ files[key_name].append({"file_name": file_name, "content_type": content_type,"content": base64.encodebytes(data_value).decode("utf-8").replace(
107
+ "\n", "")})
108
+ else:
109
+ files[key_name] = {"file_name": file_name, "content_type": content_type,"content": base64.encodebytes(data_value).decode("utf-8").replace(
110
+ "\n", "")}
111
+
112
+ return body, files
98
113
 
99
114
  return {"data": base64.encodebytes(content).decode("utf-8").replace("\n", "")}
100
115
 
@@ -181,11 +196,12 @@ class Webserver:
181
196
 
182
197
  content_length = await self.get_content_length()
183
198
  if method != Constant.TINA4_GET:
184
- body = await self.get_content_body(content_length)
199
+ body, files = await self.get_content_body(content_length)
185
200
  else:
186
201
  body = None
202
+ files = None
187
203
 
188
- request = {"params": params, "body": body, "raw_data": self.request, "url": self.path, "session": self.session,
204
+ request = {"params": params, "body": body, "files": files, "raw_data": self.request, "url": self.path, "session": self.session,
189
205
  "headers": self.lowercase_headers, "raw_request": self.request_raw, "raw_content": self.content_raw,
190
206
  "transport": transport, "asgi_response": asgi_response}
191
207
 
@@ -82,7 +82,7 @@ def global_exception_handler(exception):
82
82
  or debug_level in os.getenv("TINA4_DEBUG_LEVEL", [Constant.TINA4_LOG_ALL])):
83
83
  pass
84
84
  else:
85
- error_string = ""
85
+ error_string = "An exception happened"
86
86
  return error_string
87
87
 
88
88
  def start_in_thread(target, exception_hook=None):
File without changes