phanterpwa 13.23.0__py3-none-any.whl → 13.26.0__py3-none-any.whl
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.
- phanterpwa/__init__.py +1 -1
- phanterpwa/backend/decorators.py +19 -0
- phanterpwa/backend/request_handlers/credentials.py +28 -18
- phanterpwa/server.py +59 -44
- {phanterpwa-13.23.0.dist-info → phanterpwa-13.26.0.dist-info}/METADATA +1 -1
- {phanterpwa-13.23.0.dist-info → phanterpwa-13.26.0.dist-info}/RECORD +11 -11
- {phanterpwa-13.23.0.dist-info → phanterpwa-13.26.0.dist-info}/LICENSE +0 -0
- {phanterpwa-13.23.0.dist-info → phanterpwa-13.26.0.dist-info}/WHEEL +0 -0
- {phanterpwa-13.23.0.dist-info → phanterpwa-13.26.0.dist-info}/dependency_links.txt +0 -0
- {phanterpwa-13.23.0.dist-info → phanterpwa-13.26.0.dist-info}/entry_points.txt +0 -0
- {phanterpwa-13.23.0.dist-info → phanterpwa-13.26.0.dist-info}/top_level.txt +0 -0
phanterpwa/__init__.py
CHANGED
phanterpwa/backend/decorators.py
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import asyncio
|
|
2
|
+
import sqlite3
|
|
1
3
|
from functools import wraps
|
|
2
4
|
from .security import (
|
|
3
5
|
Serialize,
|
|
@@ -8,6 +10,23 @@ from .security import (
|
|
|
8
10
|
from inspect import currentframe, getframeinfo, getfile
|
|
9
11
|
|
|
10
12
|
|
|
13
|
+
def async_retry_on_locked(max_retries=3, delay=0.1):
|
|
14
|
+
def decorator(func):
|
|
15
|
+
@wraps(func)
|
|
16
|
+
async def wrapper(*args, **kwargs):
|
|
17
|
+
for attempt in range(max_retries):
|
|
18
|
+
try:
|
|
19
|
+
return await func(*args, **kwargs)
|
|
20
|
+
except sqlite3.OperationalError as e:
|
|
21
|
+
if "locked" in str(e) and attempt < max_retries - 1:
|
|
22
|
+
await asyncio.sleep(delay * (2 ** attempt)) # ✅ Async sleep
|
|
23
|
+
continue
|
|
24
|
+
raise
|
|
25
|
+
return await func(*args, **kwargs)
|
|
26
|
+
return wrapper
|
|
27
|
+
return decorator
|
|
28
|
+
|
|
29
|
+
|
|
11
30
|
def check_application():
|
|
12
31
|
def decorator(f):
|
|
13
32
|
@wraps(f)
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import sqlite3
|
|
1
2
|
from datetime import (
|
|
2
3
|
datetime,
|
|
3
4
|
timedelta
|
|
@@ -5,7 +6,8 @@ from datetime import (
|
|
|
5
6
|
from phanterpwa.backend.decorators import (
|
|
6
7
|
check_application,
|
|
7
8
|
check_client_token,
|
|
8
|
-
check_user_token
|
|
9
|
+
check_user_token,
|
|
10
|
+
async_retry_on_locked
|
|
9
11
|
)
|
|
10
12
|
from phanterpwa.i18n import browser_language
|
|
11
13
|
from phanterpwa.third_parties.xss import xssescape as E
|
|
@@ -27,6 +29,7 @@ from datetime import (
|
|
|
27
29
|
timedelta
|
|
28
30
|
)
|
|
29
31
|
|
|
32
|
+
CLEANUP_TIME = datetime.now()
|
|
30
33
|
|
|
31
34
|
class SignClient(web.RequestHandler):
|
|
32
35
|
"""
|
|
@@ -89,23 +92,8 @@ class SignClient(web.RequestHandler):
|
|
|
89
92
|
return summary
|
|
90
93
|
|
|
91
94
|
@check_application()
|
|
92
|
-
def get(self, *args, **kargs):
|
|
93
|
-
|
|
94
|
-
anonymous_expire_date = datetime.now() - timedelta(seconds=self.projectConfig['BACKEND'][self.app_name]['default_time_csrf_token_expire'])
|
|
95
|
-
deactived_user_expire_date = datetime.now() - timedelta(seconds=self.projectConfig['BACKEND'][self.app_name]['default_time_user_token_expire_remember_me'])
|
|
96
|
-
str_expire_date = expire_date.strftime('%Y-%m-%d %H:%M:%S')
|
|
97
|
-
str_anonymous_expire_date = anonymous_expire_date.strftime('%Y-%m-%d %H:%M:%S')
|
|
98
|
-
self.DALDatabase(
|
|
99
|
-
(self.DALDatabase.client.date_created < str_expire_date)
|
|
100
|
-
).delete()
|
|
101
|
-
self.DALDatabase(
|
|
102
|
-
(self.DALDatabase.client.auth_user == None)
|
|
103
|
-
& (self.DALDatabase.client.date_created < str_anonymous_expire_date)
|
|
104
|
-
).delete()
|
|
105
|
-
self.DALDatabase(
|
|
106
|
-
(self.DALDatabase.auth_user.activated == False)
|
|
107
|
-
& ((self.DALDatabase.auth_user.date_created < deactived_user_expire_date) | (self.DALDatabase.auth_user.date_created == None))
|
|
108
|
-
).delete()
|
|
95
|
+
async def get(self, *args, **kargs):
|
|
96
|
+
await self._cleanup()
|
|
109
97
|
self.phanterpwa_client_token = self.request.headers.get('phanterpwa-client-token')
|
|
110
98
|
self.phanterpwa_authorization = self.request.headers.get('phanterpwa-authorization')
|
|
111
99
|
t_client = Serialize(
|
|
@@ -390,6 +378,28 @@ class SignClient(web.RequestHandler):
|
|
|
390
378
|
self.set_status(200)
|
|
391
379
|
return self.write({"status": "OK"})
|
|
392
380
|
|
|
381
|
+
@async_retry_on_locked()
|
|
382
|
+
async def _cleanup(self):
|
|
383
|
+
global CLEANUP_TIME
|
|
384
|
+
expire_date = datetime.now() - timedelta(seconds=self.projectConfig['BACKEND'][self.app_name]['default_time_client_token_expire'])
|
|
385
|
+
anonymous_expire_date = datetime.now() - timedelta(seconds=self.projectConfig['BACKEND'][self.app_name]['default_time_csrf_token_expire'])
|
|
386
|
+
deactived_user_expire_date = datetime.now() - timedelta(seconds=self.projectConfig['BACKEND'][self.app_name]['default_time_user_token_expire_remember_me'])
|
|
387
|
+
str_expire_date = expire_date.strftime('%Y-%m-%d %H:%M:%S')
|
|
388
|
+
str_anonymous_expire_date = anonymous_expire_date.strftime('%Y-%m-%d %H:%M:%S')
|
|
389
|
+
if CLEANUP_TIME is None or CLEANUP_TIME > (datetime.now() - timedelta(60 * 60 * 12)):
|
|
390
|
+
self.DALDatabase(
|
|
391
|
+
(self.DALDatabase.client.date_created < str_expire_date)
|
|
392
|
+
).delete()
|
|
393
|
+
self.DALDatabase(
|
|
394
|
+
(self.DALDatabase.client.auth_user == None)
|
|
395
|
+
& (self.DALDatabase.client.date_created < str_anonymous_expire_date)
|
|
396
|
+
).delete()
|
|
397
|
+
self.DALDatabase(
|
|
398
|
+
(self.DALDatabase.auth_user.activated == False)
|
|
399
|
+
& ((self.DALDatabase.auth_user.date_created < deactived_user_expire_date) | (self.DALDatabase.auth_user.date_created == None))
|
|
400
|
+
).delete()
|
|
401
|
+
CLEANUP_TIME = datetime.now()
|
|
402
|
+
|
|
393
403
|
|
|
394
404
|
class SignForms(web.RequestHandler):
|
|
395
405
|
"""
|
phanterpwa/server.py
CHANGED
|
@@ -79,52 +79,67 @@ class PhanterPWATornado(object):
|
|
|
79
79
|
self.cpu_number = int(self.projectConfig["PROJECT"].get('cpu_number', os.cpu_count()))
|
|
80
80
|
if os.name == "nt":
|
|
81
81
|
self.cpu_number = 1
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
handlers_app = importlib.import_module("backapps.{0}.handlers".format(x))
|
|
86
|
-
if isinstance(handlers_app.HANDLER, (list, tuple)):
|
|
87
|
-
app = web.Application(
|
|
88
|
-
handlers_app.HANDLER,
|
|
89
|
-
**handlers_app.SETTINGS
|
|
90
|
-
)
|
|
91
|
-
else:
|
|
92
|
-
app = handlers_app.HANDLER
|
|
93
|
-
# app_http_server = httpserver.HTTPServer(app)
|
|
94
|
-
# if self.cpu_number == 1:
|
|
95
|
-
# app_http_server.listen(int(current_port))
|
|
96
|
-
# else:
|
|
97
|
-
# app_http_server.bind(int(current_port), reuse_port=True)
|
|
98
|
-
# app_http_server.start(self.cpu_number)
|
|
99
|
-
configs.append([app, current_port])
|
|
82
|
+
needs_fork = self.cpu_number != 1 and self.cpu_number > -1
|
|
83
|
+
if needs_fork:
|
|
84
|
+
process.fork_processes(self.cpu_number)
|
|
100
85
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
# else:
|
|
115
|
-
# app_http_server.bind(int(current_port), reuse_port=True)
|
|
116
|
-
# app_http_server.start(self.cpu_number)
|
|
117
|
-
configs.append([app, current_port])
|
|
118
|
-
if self.cpu_number == 1:
|
|
119
|
-
for x in configs:
|
|
120
|
-
app_http_server = httpserver.HTTPServer(x[0])
|
|
121
|
-
app_http_server.listen(int(x[1]))
|
|
122
|
-
else:
|
|
123
|
-
for x in configs:
|
|
124
|
-
socket = netutil.bind_sockets(x[1])
|
|
125
|
-
app_http_server = httpserver.HTTPServer(x[0])
|
|
86
|
+
for x in self.projectConfig['BACKEND']:
|
|
87
|
+
current_port = self.projectConfig['BACKEND'][x]['port']
|
|
88
|
+
handlers_app = importlib.import_module("backapps.{0}.handlers".format(x))
|
|
89
|
+
if isinstance(handlers_app.HANDLER, (list, tuple)):
|
|
90
|
+
app = web.Application(
|
|
91
|
+
handlers_app.HANDLER,
|
|
92
|
+
**handlers_app.SETTINGS
|
|
93
|
+
)
|
|
94
|
+
else:
|
|
95
|
+
app = handlers_app.HANDLER
|
|
96
|
+
|
|
97
|
+
socket = netutil.bind_sockets(current_port)
|
|
98
|
+
app_http_server = httpserver.HTTPServer(app)
|
|
126
99
|
app_http_server.add_sockets(socket)
|
|
127
|
-
|
|
100
|
+
|
|
101
|
+
for x in self.projectConfig['FRONTEND']:
|
|
102
|
+
current_port = self.projectConfig['FRONTEND'][x]['port']
|
|
103
|
+
handlers_app = importlib.import_module("frontapps.{0}.handlers".format(x))
|
|
104
|
+
if isinstance(handlers_app.HANDLER, (list, tuple)):
|
|
105
|
+
app = web.Application(
|
|
106
|
+
handlers_app.HANDLER,
|
|
107
|
+
**handlers_app.SETTINGS
|
|
108
|
+
)
|
|
109
|
+
else:
|
|
110
|
+
app = handlers_app.HANDLER
|
|
111
|
+
|
|
112
|
+
socket = netutil.bind_sockets(current_port)
|
|
113
|
+
app_http_server = httpserver.HTTPServer(app)
|
|
114
|
+
app_http_server.add_sockets(socket)
|
|
115
|
+
else:
|
|
116
|
+
for x in self.projectConfig['BACKEND']:
|
|
117
|
+
current_port = self.projectConfig['BACKEND'][x]['port']
|
|
118
|
+
handlers_app = importlib.import_module("backapps.{0}.handlers".format(x))
|
|
119
|
+
if isinstance(handlers_app.HANDLER, (list, tuple)):
|
|
120
|
+
app = web.Application(
|
|
121
|
+
handlers_app.HANDLER,
|
|
122
|
+
**handlers_app.SETTINGS
|
|
123
|
+
)
|
|
124
|
+
else:
|
|
125
|
+
app = handlers_app.HANDLER
|
|
126
|
+
|
|
127
|
+
app_http_server = httpserver.HTTPServer(app)
|
|
128
|
+
app_http_server.listen(current_port)
|
|
129
|
+
|
|
130
|
+
for x in self.projectConfig['FRONTEND']:
|
|
131
|
+
current_port = self.projectConfig['FRONTEND'][x]['port']
|
|
132
|
+
handlers_app = importlib.import_module("frontapps.{0}.handlers".format(x))
|
|
133
|
+
if isinstance(handlers_app.HANDLER, (list, tuple)):
|
|
134
|
+
app = web.Application(
|
|
135
|
+
handlers_app.HANDLER,
|
|
136
|
+
**handlers_app.SETTINGS
|
|
137
|
+
)
|
|
138
|
+
else:
|
|
139
|
+
app = handlers_app.HANDLER
|
|
140
|
+
|
|
141
|
+
app_http_server = httpserver.HTTPServer(app)
|
|
142
|
+
app_http_server.listen(current_port)
|
|
128
143
|
|
|
129
144
|
|
|
130
145
|
autoreload.watch(os.path.join(self.projectPath, "config.json"))
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
phanterpwa/__init__.py,sha256=
|
|
1
|
+
phanterpwa/__init__.py,sha256=nrVnSugtS6Gm2UejYsK6FjjlXoZDnWZguS25mqhcRPo,397
|
|
2
2
|
phanterpwa/__main__.py,sha256=1vSHtv6-sgAgpZiklf9bwarXX1b-fmKx1rjwJw4h78o,4017
|
|
3
3
|
phanterpwa/compiler.py,sha256=Je3qtVO_cZ69_PPWcXKyBgnRfQ-Ev-zkZ3UTN-ddOTQ,47478
|
|
4
4
|
phanterpwa/configer.py,sha256=O0IO5rf-hwFNdBjcz94OF-fqXKTWbqPElTsfS5V2beY,26327
|
|
5
5
|
phanterpwa/helpers.py,sha256=gUoSd6OeMtA08jwFMrOCsuou58nwech-aGdiPSCX9GI,12138
|
|
6
6
|
phanterpwa/mail.py,sha256=YrsiIQY_SpqySIc7mi6MfyY881DIsoYAJ5dPAz8vorE,5741
|
|
7
7
|
phanterpwa/reversexml.py,sha256=YJeI8VuzEPw0D2z0Cz-HLt2n27WyJawZh6HRNZX5Ujg,10764
|
|
8
|
-
phanterpwa/server.py,sha256=
|
|
8
|
+
phanterpwa/server.py,sha256=X8ab8cyNJvnIb3MiqDNEp-2fwnUbUz7UPSZdvFiaNx8,14088
|
|
9
9
|
phanterpwa/sms.py,sha256=XUULyDSk5gPjBqupchIcaGv-C6kX66XxrXpmzfnSp_A,1313
|
|
10
10
|
phanterpwa/tools.py,sha256=SKwqx_suix-b1DP72a7z98jlnSWDmtGNWgCQq_ogB1I,46173
|
|
11
11
|
phanterpwa/xmlconstructor.py,sha256=DMtc9BXI2NMGGmLszZXh2A63Iv0D1qgoWtn0aKyrmoo,162695
|
|
12
12
|
phanterpwa/backend/__init__.py,sha256=zB8rm2I9O3f448YsuaupgBlAoqZAiVM5vEoWnOOGvdw,68
|
|
13
13
|
phanterpwa/backend/dataforms.py,sha256=HwR8D-4vBNXdN5MSpZmjelo-Az92lVvOTIzpbHnPpsg,64543
|
|
14
|
-
phanterpwa/backend/decorators.py,sha256=
|
|
14
|
+
phanterpwa/backend/decorators.py,sha256=gPqFjUe8BCci59hBv72j2wvKZB3L5HLZIE-3ESA2wLU,56094
|
|
15
15
|
phanterpwa/backend/security.py,sha256=USPky7nqTKASAN60yYs7-NnoR82LMZlf9aGlfz1QbXM,1300
|
|
16
16
|
phanterpwa/backend/pydal/__init__.py,sha256=lpPDHcS9anJ5ceRSW9fBVuAgKK5qtjSoMsVjp3_nCdw,55
|
|
17
17
|
phanterpwa/backend/pydal/auth.py,sha256=g_HToe-Lewtz4MmD9_KBtFmDl1SfBel0Pp_NDX36Y44,8558
|
|
@@ -24,7 +24,7 @@ phanterpwa/backend/request_handlers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQ
|
|
|
24
24
|
phanterpwa/backend/request_handlers/admin.py,sha256=QnpoCTMRBuviSCdB84G0pUb13kIg6ky8Wv4DEVB7tRQ,63978
|
|
25
25
|
phanterpwa/backend/request_handlers/auth.py,sha256=epJ2ura3u6YDKNRmvyYGR7FzF1nrgwTpneibP0z9zzw,177284
|
|
26
26
|
phanterpwa/backend/request_handlers/cas.py,sha256=TeeQaodcHVkhu-cUqesh9NeAuo0oXylzcPXpQ9wG6H4,24996
|
|
27
|
-
phanterpwa/backend/request_handlers/credentials.py,sha256=
|
|
27
|
+
phanterpwa/backend/request_handlers/credentials.py,sha256=kML1meL2IJeni2MXiLfG4derOazyeCCR6DTACI1rZJ8,51663
|
|
28
28
|
phanterpwa/backend/request_handlers/errors.py,sha256=x3SMdpkO4mxaSRZZQQxtH1zUFh47C06kssfI4CoPokc,4472
|
|
29
29
|
phanterpwa/backend/request_handlers/i18n_server.py,sha256=p3LQxOdcLHIjgaFs4wO1V2_7gKpfcDT7pDPa7m0-UbQ,3205
|
|
30
30
|
phanterpwa/backend/request_handlers/internal_messages.py,sha256=w_u3NYw0KZfuCIS8tHJhV12tj_UA0_aBekk22nR3oCc,17382
|
|
@@ -435,10 +435,10 @@ phanterpwa/usual_sass/preloaders/indefined_text.sass,sha256=z4JuUtBrzoqH3HuNFXvN
|
|
|
435
435
|
phanterpwa/usual_sass/preloaders/run_points.sass,sha256=EYl93ljfgAc-ZLJ0VScrCoIlHP7Nr6NLdxj1zk2wm_E,3367
|
|
436
436
|
phanterpwa/usual_sass/preloaders/square.sass,sha256=TOsh9muP4zkYLUJcw4i1LeRs60NrtgRWBk_1oMt2_58,1348
|
|
437
437
|
phanterpwa/usual_sass/preloaders/squares.sass,sha256=kH1I89qEfmbvYxCtKFVNcxP5bWIjnqbheXVnyGF0VNo,3862
|
|
438
|
-
phanterpwa-13.
|
|
439
|
-
phanterpwa-13.
|
|
440
|
-
phanterpwa-13.
|
|
441
|
-
phanterpwa-13.
|
|
442
|
-
phanterpwa-13.
|
|
443
|
-
phanterpwa-13.
|
|
444
|
-
phanterpwa-13.
|
|
438
|
+
phanterpwa-13.26.0.dist-info/LICENSE,sha256=lGEW1PRSZOkug2-d0IJgryCjqt6zhxN5x9pFgy3lx2E,1087
|
|
439
|
+
phanterpwa-13.26.0.dist-info/METADATA,sha256=Ws_680J-DTzgitiwWY_rY6-ySIP9Mh2yI3Py9i9Vne8,1939
|
|
440
|
+
phanterpwa-13.26.0.dist-info/WHEEL,sha256=G16H4A3IeoQmnOrYV4ueZGKSjhipXx8zc8nu9FGlvMA,92
|
|
441
|
+
phanterpwa-13.26.0.dist-info/dependency_links.txt,sha256=Pslekmz-4l1SpBO0x2aYkYZPCScmbrB9HUq1YvXYUzM,40
|
|
442
|
+
phanterpwa-13.26.0.dist-info/entry_points.txt,sha256=siJH2lFXIdsUBDRgcXV4blOb2_iku1vcbqxJ-trIQrw,56
|
|
443
|
+
phanterpwa-13.26.0.dist-info/top_level.txt,sha256=nF1WJ8AByxBv3bLKp3xySR2l2Twrj5n5n7C404lULSk,5319
|
|
444
|
+
phanterpwa-13.26.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|