Commit Graph

111 Commits

Author SHA1 Message Date
Tom Hacohen
9bf118225d Exceptions: fix error when transforming django validation errors. 2021-01-04 10:15:38 +02:00
Tom Hacohen
43dede57d2 Exceptions: fix types. 2021-01-04 10:15:38 +02:00
Tom Hacohen
2e21fe4994 Django db cleanup: explicitly add it to dependencies.
We can't really add it manually, because some of the deps are auto included as
parameters. These were not being decorated which in turn meeant issues.
2020-12-31 10:03:16 +02:00
Tom Hacohen
5b8f667e55 Cleanup django db connections before every request and every dependency.
This is instead of the commit we reverted in the previous commit.
The problem is that django keeps the connection per thread and it relies
on django itself to clean them up before/after connections.
We can't do this, because django is unaware of fastapi, so we have to
manage this ourselves.

The easiest way is to call it at the beginning of evenry route and every dep.
We need to do it for each because unfortunately fastapi may send them to
different worker threads.
2020-12-30 17:16:58 +02:00
Tom Hacohen
6ec03c3d34 Revert "Add a django middleware to cleanup db connections."
This ended up being useless because of the way startlette and fastapi do
thread pools. The middleware is called in one thread, the path in
another, and the dependency in yet another.

This reverts commit 473448246f.
2020-12-30 15:37:59 +02:00
Tom Hacohen
6738c2cf20 Remove unused variable. 2020-12-30 13:55:05 +02:00
Tom Hacohen
64be7f10bd Remove all of the needless async decorators.
The code uses the django ORM which is sync, and fastapi handles sync paths
just fine. So having all of this extra code for handling async was unnecessary.
2020-12-30 10:17:01 +02:00
Tom Hacohen
473448246f Add a django middleware to cleanup db connections.
This severely impacts performance, though without it we are getting
django.db.utils.InterfaceError once connections in the pool go stale.
2020-12-30 09:26:33 +02:00
Tom Hacohen
a7fdb4a108 More typing fixes. 2020-12-29 21:10:03 +02:00
Tom Hacohen
709bc6c1fc Improve typing information. 2020-12-29 18:17:28 +02:00
Tom Hacohen
332f7e2332 Fix Python 3.7 compatibility
Both cached_property and Literal were introduced in Python 3.8 so they
can't be used.
2020-12-29 17:55:55 +02:00
Tom Hacohen
62eb46ec4e msgpack route: use the encode/decode functions from the utils module. 2020-12-29 15:44:52 +02:00
Tom Hacohen
dbdff06e68 Move all the routers under their own dir. 2020-12-29 15:42:41 +02:00
Tom Hacohen
8bf04fc286 Reformat files using black. 2020-12-29 15:37:11 +02:00
Tom Hacohen
e6b47ae1a9 Fix login_challenge to work with get_user_queryset. 2020-12-29 15:17:46 +02:00
Tom Hacohen
794b5f3983 Fix many type errors. 2020-12-29 13:32:19 +02:00
Tom Hacohen
e13f26ec56 Fix handling of legacy accounts that don't have collection type. 2020-12-29 10:27:35 +02:00
Tom Hacohen
f67730f42d Support passing custom middlewares. 2020-12-29 10:12:36 +02:00
Tom Hacohen
a8b97e60d4 Docs: improve metadata. 2020-12-29 09:46:20 +02:00
Tom Hacohen
7714148807 Use ValidationError when appropriate. 2020-12-28 18:49:05 +02:00
Tom Hacohen
f0a8689712 Implement sendfile. 2020-12-28 18:46:37 +02:00
Tom Hacohen
c7f09d3fef implement chunk_download. 2020-12-28 18:25:06 +02:00
Tom Hacohen
53b22602b2 Implement chunk_update. 2020-12-28 18:18:55 +02:00
Tom Hacohen
dcf81aa9ce Fix prefetch medium. 2020-12-28 18:17:41 +02:00
Tom Hacohen
f7858a20b7 Fix user creation. 2020-12-28 17:46:20 +02:00
Tom Hacohen
3d438b9591 Cleanup validation errors. 2020-12-28 17:39:51 +02:00
Tom Hacohen
10ff303b75 Fix formatting. 2020-12-28 17:09:20 +02:00
Tom Hacohen
fa0979dce1 Test reset: clean reset function. 2020-12-28 16:57:09 +02:00
Tom Hacohen
151bec0d9e Fix type error. 2020-12-28 16:44:13 +02:00
Tom Hacohen
586b015eb7 Login: also return username and email upon login. 2020-12-28 16:42:39 +02:00
Tom Hacohen
c2a2e710c9 Move common dependencies to their own file. 2020-12-28 16:42:39 +02:00
Tom Hacohen
3e39aa88a1 Remove unused var. 2020-12-28 16:42:39 +02:00
Tom Hacohen
1bca435d74 Workaround typing issue. 2020-12-28 16:42:39 +02:00
Tom Hacohen
59e30ed988 Signup and logout: make sync. 2020-12-28 16:42:39 +02:00
Tom Hacohen
ca7f2ec73c When converting from ORM convert binary fields to bytes.
The problem is that some ORMs return memoryview which are more efficient but
are not supported by pydantic at the moment.
2020-12-28 16:42:39 +02:00
Tom Hacohen
50f89c48e2 Dashboard url: fix getting dashboard url. 2020-12-28 16:42:39 +02:00
Tom Hacohen
c1f171bde0 Change how we create applications. 2020-12-28 16:42:39 +02:00
Tom Hacohen
b3c170e10d fix getting dashboard URL. 2020-12-28 16:42:39 +02:00
Tom Hacohen
c918d3ed07 Add base64 utils. 2020-12-28 16:42:39 +02:00
Tom Hacohen
4ceb42780e Remove unused django_etebase code. 2020-12-28 16:42:39 +02:00
Tom Hacohen
0fa2f2da3b Make the fastapi application the main asgi one. 2020-12-28 16:42:39 +02:00
Tom Hacohen
b081d0129f Add support for read/write permissions. 2020-12-28 16:42:39 +02:00
Tom Hacohen
63afcc0830 Mount the django application. 2020-12-28 16:42:39 +02:00
Tom Hacohen
ad2205e596 Add trusted host middleware. 2020-12-28 10:57:40 +02:00
Tom Hacohen
38884fead8 Revert "Improve chunks type."
This reverts commit 37f5a4509f.
2020-12-28 10:47:07 +02:00
Tom Hacohen
cf7690a60f Remove usages of EtebaseValidationError. 2020-12-28 10:45:34 +02:00
Tom Hacohen
37f5a4509f Improve chunks type. 2020-12-28 10:41:22 +02:00
Tom Hacohen
1a09393dcb Also add 401 to permission responses. 2020-12-28 10:29:47 +02:00
Tal Leibman
959dc9b576 minor fix 2020-12-28 10:27:49 +02:00
Tom Hacohen
b39f7951e2 chunk first-type. 2020-12-28 10:20:20 +02:00