tina4-python 0.1.57__tar.gz → 0.2.64__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {tina4_python-0.1.57 → tina4_python-0.2.64}/PKG-INFO +175 -19
- {tina4_python-0.1.57 → tina4_python-0.2.64}/README.md +410 -257
- {tina4_python-0.1.57 → tina4_python-0.2.64}/pyproject.toml +33 -27
- {tina4_python-0.1.57 → tina4_python-0.2.64}/tina4_python/Auth.py +193 -155
- {tina4_python-0.1.57 → tina4_python-0.2.64}/tina4_python/Constant.py +42 -38
- tina4_python-0.2.64/tina4_python/Database.py +573 -0
- tina4_python-0.2.64/tina4_python/DatabaseResult.py +101 -0
- {tina4_python-0.1.57 → tina4_python-0.2.64}/tina4_python/Debug.py +91 -46
- {tina4_python-0.1.57 → tina4_python-0.2.64}/tina4_python/Env.py +37 -32
- {tina4_python-0.1.57 → tina4_python-0.2.64}/tina4_python/Localization.py +42 -42
- {tina4_python-0.1.57 → tina4_python-0.2.64}/tina4_python/Messages.py +30 -30
- tina4_python-0.2.64/tina4_python/MiddleWare.py +75 -0
- tina4_python-0.2.64/tina4_python/Migration.py +99 -0
- tina4_python-0.2.64/tina4_python/ORM.py +519 -0
- tina4_python-0.2.64/tina4_python/Queue.py +495 -0
- tina4_python-0.2.64/tina4_python/Request.py +18 -0
- tina4_python-0.2.64/tina4_python/Response.py +98 -0
- tina4_python-0.2.64/tina4_python/Router.py +385 -0
- tina4_python-0.2.64/tina4_python/Session.py +252 -0
- {tina4_python-0.1.57 → tina4_python-0.2.64}/tina4_python/ShellColors.py +20 -20
- tina4_python-0.2.64/tina4_python/Swagger.py +228 -0
- tina4_python-0.2.64/tina4_python/Template.py +91 -0
- tina4_python-0.2.64/tina4_python/Webserver.py +385 -0
- {tina4_python-0.1.57 → tina4_python-0.2.64}/tina4_python/__init__.py +267 -181
- {tina4_python-0.1.57 → tina4_python-0.2.64}/tina4_python/messages.pot +83 -83
- tina4_python-0.2.64/tina4_python/public/favicon.ico +0 -0
- tina4_python-0.2.64/tina4_python/public/images/403.png +0 -0
- tina4_python-0.2.64/tina4_python/public/images/404.png +0 -0
- tina4_python-0.2.64/tina4_python/public/images/500.png +0 -0
- tina4_python-0.2.64/tina4_python/public/images/logo.png +0 -0
- tina4_python-0.2.64/tina4_python/public/js/tina4helper.js +397 -0
- tina4_python-0.2.64/tina4_python/public/swagger/index.html +90 -0
- tina4_python-0.2.64/tina4_python/public/swagger/oauth2-redirect.html +63 -0
- {tina4_python-0.1.57 → tina4_python-0.2.64}/tina4_python/templates/errors/403.twig +10 -11
- {tina4_python-0.1.57 → tina4_python-0.2.64}/tina4_python/templates/errors/404.twig +10 -11
- tina4_python-0.2.64/tina4_python/templates/errors/500.twig +11 -0
- {tina4_python-0.1.57 → tina4_python-0.2.64}/tina4_python/translations/en/LC_MESSAGES/messages.po +80 -80
- {tina4_python-0.1.57 → tina4_python-0.2.64}/tina4_python/translations/fr/LC_MESSAGES/messages.po +84 -84
- tina4_python-0.1.57/tina4_python/Migration.py +0 -45
- tina4_python-0.1.57/tina4_python/Request.py +0 -21
- tina4_python-0.1.57/tina4_python/Response.py +0 -40
- tina4_python-0.1.57/tina4_python/Router.py +0 -210
- tina4_python-0.1.57/tina4_python/Session.py +0 -115
- tina4_python-0.1.57/tina4_python/Template.py +0 -48
- tina4_python-0.1.57/tina4_python/Webserver.py +0 -228
- tina4_python-0.1.57/tina4_python/public/favicon.ico +0 -0
- tina4_python-0.1.57/tina4_python/public/images/403.png +0 -0
- tina4_python-0.1.57/tina4_python/public/images/404.png +0 -0
- tina4_python-0.1.57/tina4_python/public/images/logo.png +0 -0
- {tina4_python-0.1.57 → tina4_python-0.2.64}/tina4_python/public/css/readme.md +0 -0
- {tina4_python-0.1.57 → tina4_python-0.2.64}/tina4_python/public/images/readme.md +0 -0
- {tina4_python-0.1.57 → tina4_python-0.2.64}/tina4_python/public/js/readme.md +0 -0
- {tina4_python-0.1.57 → tina4_python-0.2.64}/tina4_python/templates/readme.md +0 -0
- {tina4_python-0.1.57 → tina4_python-0.2.64}/tina4_python/translations/en/LC_MESSAGES/messages.mo +0 -0
- {tina4_python-0.1.57 → tina4_python-0.2.64}/tina4_python/translations/fr/LC_MESSAGES/messages.mo +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.3
|
|
2
2
|
Name: tina4-python
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.2.64
|
|
4
4
|
Summary: Tina4Python - This is not another framework for Python
|
|
5
5
|
Author: Andre van Zuydam
|
|
6
6
|
Author-email: andrevanzuydam@gmail.com
|
|
@@ -9,9 +9,12 @@ Classifier: Programming Language :: Python :: 3
|
|
|
9
9
|
Classifier: Programming Language :: Python :: 3.10
|
|
10
10
|
Classifier: Programming Language :: Python :: 3.11
|
|
11
11
|
Classifier: Programming Language :: Python :: 3.12
|
|
12
|
-
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
13
|
+
Requires-Dist: Jinja2 (>=3.1.4,<4.0.0)
|
|
14
|
+
Requires-Dist: bcrypt (>=4.1.3,<5.0.0)
|
|
13
15
|
Requires-Dist: cryptography (>=42.0.5,<43.0.0)
|
|
14
16
|
Requires-Dist: libsass (>=0.22.0,<0.23.0)
|
|
17
|
+
Requires-Dist: litequeue (>=0.9,<0.10)
|
|
15
18
|
Requires-Dist: mypy (>=0.991,<0.992)
|
|
16
19
|
Requires-Dist: pyjwt (>=2.8.0,<3.0.0)
|
|
17
20
|
Requires-Dist: python-dotenv (>=1.0.1,<2.0.0)
|
|
@@ -56,6 +59,22 @@ If you are developing on Tina4, make sure you copy the public folder from tina4_
|
|
|
56
59
|
|
|
57
60
|
### Installation
|
|
58
61
|
|
|
62
|
+
Virtual environment
|
|
63
|
+
|
|
64
|
+
Linux / Mac
|
|
65
|
+
```bash
|
|
66
|
+
python3 -m venv venv
|
|
67
|
+
source ./venv/bin/activate
|
|
68
|
+
pip install poetry
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
Windows
|
|
72
|
+
```bash
|
|
73
|
+
python -m venv venv
|
|
74
|
+
.\venv\Scripts\activate
|
|
75
|
+
pip install poetry
|
|
76
|
+
```
|
|
77
|
+
|
|
59
78
|
#### Windows
|
|
60
79
|
|
|
61
80
|
1.) Install Poetry:
|
|
@@ -201,6 +220,16 @@ async def capture_get(request, response):
|
|
|
201
220
|
@post("/capture")
|
|
202
221
|
async def capture_post(request, response):
|
|
203
222
|
return response(request.body)
|
|
223
|
+
|
|
224
|
+
@get("/simple")
|
|
225
|
+
async def simple_get(request, response):
|
|
226
|
+
print("<h1>Hello World!</h1>")
|
|
227
|
+
|
|
228
|
+
@get("/redirect")
|
|
229
|
+
async def simple_get(request, response):
|
|
230
|
+
|
|
231
|
+
return response.redirect("/test")
|
|
232
|
+
|
|
204
233
|
```
|
|
205
234
|
|
|
206
235
|
In your ```src/__init__.py``` add the following code
|
|
@@ -224,33 +253,150 @@ For ease of use you can supply an `API_KEY` param to your .env with a secret of
|
|
|
224
253
|
API_KEY=somehash
|
|
225
254
|
```
|
|
226
255
|
|
|
256
|
+
### Suppressing the default webservice
|
|
257
|
+
|
|
258
|
+
You may want to use your Tina4 project as a library in another project so suppressing the default webservice is probably needed.
|
|
259
|
+
|
|
260
|
+
```.env
|
|
261
|
+
TINA4_DEFAULT_WEBSERVER="False"
|
|
262
|
+
```
|
|
263
|
+
or in your `__init__.py` file
|
|
264
|
+
```python
|
|
265
|
+
import os
|
|
266
|
+
os.environ["TINA4_DEFAULT_WEBSERVER"] = "False"
|
|
267
|
+
```
|
|
268
|
+
Additionally, it will require you to rename `src` to the name of your package
|
|
227
269
|
|
|
228
270
|
### Features
|
|
229
|
-
| Completed | To Do
|
|
230
|
-
|
|
231
|
-
| Python pip package |
|
|
232
|
-
| Basic environment handling |
|
|
233
|
-
|
|
|
234
|
-
| Enhanced
|
|
235
|
-
| CSS Support |
|
|
236
|
-
| Image Support |
|
|
237
|
-
| Localization |
|
|
238
|
-
| Error Pages |
|
|
239
|
-
| Template handling |
|
|
240
|
-
| Form posting |
|
|
241
|
-
|
|
|
271
|
+
| Completed | To Do |
|
|
272
|
+
|----------------------------|-------|
|
|
273
|
+
| Python pip package | |
|
|
274
|
+
| Basic environment handling | |
|
|
275
|
+
| Routing with Swagger | |
|
|
276
|
+
| Enhanced Routing | |
|
|
277
|
+
| CSS Support | |
|
|
278
|
+
| Image Support | |
|
|
279
|
+
| Localization | |
|
|
280
|
+
| Error Pages | |
|
|
281
|
+
| Template handling | |
|
|
282
|
+
| Form posting | |
|
|
283
|
+
| Migrations | |
|
|
284
|
+
| Colored Debugging | |
|
|
285
|
+
| Database Abstraction | |
|
|
286
|
+
|
|
287
|
+
### Database
|
|
288
|
+
|
|
289
|
+
```bash
|
|
290
|
+
|
|
291
|
+
Various databases initialised:
|
|
292
|
+
|
|
293
|
+
dba = Database("sqlite3:test.db", "username", "password")
|
|
294
|
+
dba = Database("mysql:localhost/3306:myschema", "username", "password")
|
|
295
|
+
dba = Database("postgres:localhost/5432:myschema", "username", "password")
|
|
296
|
+
dba = Database("firebird:localhost/3050:/home/database/FIREBIRD.FDB", "username", "password")
|
|
297
|
+
|
|
298
|
+
NoSQL support (Still to be developed):
|
|
299
|
+
|
|
300
|
+
dba = Database("mongodb:localhost/27017:mycollection", "username", "password")
|
|
301
|
+
dba = Database("firebase:https://your_storage.firebaseio.com", "username", "password")
|
|
302
|
+
|
|
303
|
+
Fetching records and passing data as parameters, limit and skip specified:
|
|
304
|
+
|
|
305
|
+
records = dba.fetch("select * from table where something = ? and something2 = ?", params=["something", "something2"], limit=10, skip=5)
|
|
306
|
+
|
|
307
|
+
print (records)
|
|
308
|
+
print (records.to_json())
|
|
309
|
+
{
|
|
310
|
+
id : 1
|
|
311
|
+
something: "something",
|
|
312
|
+
something2: "something2"
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
print(records[0].id)
|
|
316
|
+
1
|
|
317
|
+
|
|
318
|
+
record = dba.fetch_one("select * from table where something = ? and something2 = ?", params=["something", "something2"])
|
|
319
|
+
|
|
320
|
+
print(record.id)
|
|
321
|
+
|
|
322
|
+
print (records.to_json())
|
|
323
|
+
1
|
|
324
|
+
|
|
325
|
+
|
|
326
|
+
Executing sql queries:
|
|
327
|
+
|
|
328
|
+
dba.execute ("update table set something = ? and something2 = ? where id = ?", params=["something", "something2", 1])
|
|
329
|
+
dba.execute ("delete from table where id = ?", params=[1])
|
|
330
|
+
|
|
331
|
+
|
|
332
|
+
Starting a transaction:
|
|
333
|
+
|
|
334
|
+
dba.start_transaction()
|
|
335
|
+
|
|
336
|
+
|
|
337
|
+
Rollback a transaction:
|
|
338
|
+
|
|
339
|
+
dba.roll_back()
|
|
340
|
+
|
|
341
|
+
|
|
342
|
+
Commit a transaction:
|
|
343
|
+
|
|
344
|
+
dba.commit()
|
|
345
|
+
|
|
346
|
+
|
|
347
|
+
Select method (Still in development):
|
|
348
|
+
|
|
349
|
+
dba.select(["id", "something", "something2"], "table_name", filter={"id": 1}, limit=10, skip=0)
|
|
350
|
+
dba.select(["id", "something", "something2"], "table_name", filter=[{"id": 1}, {"id": 2}], limit=10, skip=0)
|
|
351
|
+
dba.select(["id", "something", "sum(id)"])
|
|
352
|
+
.from(["table"])
|
|
353
|
+
.join(["tabel2"])
|
|
354
|
+
.on([""])
|
|
355
|
+
.and([{"id": 1}])
|
|
356
|
+
.where({"id" : 2}, "id = ?", [{"id": 2}])
|
|
357
|
+
.having()
|
|
358
|
+
.group_by()
|
|
359
|
+
.order_by(["id"])
|
|
360
|
+
|
|
361
|
+
|
|
362
|
+
Updating records - records will be found by primary key specified and then updated:
|
|
363
|
+
|
|
364
|
+
dba.update(table_name="table_name", records.fromJSON(json_string))
|
|
365
|
+
dba.update(table_name="table_name", records, primary_key="id")
|
|
366
|
+
dba.update(table_name="table_name", record, primary_key="id") # primary key implied by first key value pair
|
|
367
|
+
|
|
368
|
+
|
|
369
|
+
Inserting records - pass a dictionary for a single record and a list of dictionaries for multiple records:
|
|
370
|
+
|
|
371
|
+
dba.insert(table_name="table_name", dba.from_json(json_string))
|
|
372
|
+
dba.insert(table_name="table_name", {"id": 1, "something": "hello", "something2": "world"})
|
|
373
|
+
dba.insert(table_name="table_name", [{"id": 1, "something": "hello", "something2": "world"},
|
|
374
|
+
{"id": 2, "something": "hello2", "something2": "world2"}])
|
|
375
|
+
|
|
376
|
+
|
|
377
|
+
Deleting records - specify table name. Records can either be found by primary key or filter:
|
|
378
|
+
|
|
379
|
+
dba.delete("table_name", record, primary_key="id")
|
|
380
|
+
dba.delete("table_name", filter={"id": 1})
|
|
381
|
+
dba.delete("table_name", filter=[{"id": 1}, {"id": 2}])
|
|
382
|
+
|
|
383
|
+
Migration updates:
|
|
384
|
+
|
|
385
|
+
- record count added
|
|
386
|
+
- Database result object updated
|
|
387
|
+
```
|
|
242
388
|
|
|
243
389
|
### Building and Deployment
|
|
244
390
|
|
|
245
391
|
#### Using Python
|
|
246
392
|
|
|
247
|
-
Building the package:
|
|
248
|
-
|
|
393
|
+
Building the package without poetry - you will need to request an API key:
|
|
394
|
+
```bash
|
|
249
395
|
python3 -m pip install --upgrade build
|
|
250
396
|
python3 -m build
|
|
251
397
|
python3 -m pip install --upgrade twine
|
|
252
398
|
python3 -m twine upload dist/*
|
|
253
|
-
|
|
399
|
+
```
|
|
254
400
|
|
|
255
401
|
#### Using Poetry
|
|
256
402
|
|
|
@@ -276,3 +422,13 @@ Flake8 Code tests
|
|
|
276
422
|
poetry run flake8 ./tina4_python
|
|
277
423
|
```
|
|
278
424
|
|
|
425
|
+
### Using queues
|
|
426
|
+
|
|
427
|
+
```bash
|
|
428
|
+
docker run -d --hostname=my-kafka --name=some-kafka -p 9092:9092 apache/kafka
|
|
429
|
+
```
|
|
430
|
+
|
|
431
|
+
```bash
|
|
432
|
+
docker run -d --hostname=my-rabbit --name=some-rabbit -p 15672:15672 -p 5672:5672 rabbitmq:3
|
|
433
|
+
```
|
|
434
|
+
|