appier 1.31.4__py2.py3-none-any.whl → 1.32.0__py2.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.
- appier/__init__.py +333 -52
- appier/amqp.py +29 -30
- appier/api.py +214 -212
- appier/asgi.py +54 -55
- appier/async_neo.py +46 -35
- appier/async_old.py +55 -42
- appier/asynchronous.py +7 -13
- appier/base.py +1762 -1429
- appier/bus.py +51 -52
- appier/cache.py +99 -84
- appier/common.py +9 -11
- appier/component.py +17 -19
- appier/compress.py +25 -28
- appier/config.py +96 -73
- appier/controller.py +9 -15
- appier/crypt.py +25 -21
- appier/data.py +73 -57
- appier/defines.py +191 -226
- appier/exceptions.py +103 -63
- appier/execution.py +94 -88
- appier/export.py +90 -88
- appier/extra.py +6 -13
- appier/extra_neo.py +8 -11
- appier/extra_old.py +18 -16
- appier/geo.py +57 -47
- appier/git.py +101 -90
- appier/graph.py +23 -24
- appier/http.py +520 -398
- appier/legacy.py +373 -180
- appier/log.py +90 -97
- appier/meta.py +42 -42
- appier/mock.py +32 -34
- appier/model.py +793 -681
- appier/model_a.py +208 -183
- appier/mongo.py +183 -107
- appier/observer.py +39 -31
- appier/part.py +23 -24
- appier/preferences.py +44 -47
- appier/queuing.py +78 -96
- appier/redisdb.py +40 -35
- appier/request.py +227 -175
- appier/scheduler.py +13 -18
- appier/serialize.py +37 -31
- appier/session.py +161 -147
- appier/settings.py +2 -11
- appier/smtp.py +53 -49
- appier/storage.py +39 -33
- appier/structures.py +50 -45
- appier/test/__init__.py +2 -11
- appier/test/base.py +111 -108
- appier/test/cache.py +28 -35
- appier/test/config.py +10 -19
- appier/test/crypt.py +3 -12
- appier/test/data.py +3 -12
- appier/test/exceptions.py +8 -17
- appier/test/export.py +16 -33
- appier/test/graph.py +27 -60
- appier/test/http.py +42 -54
- appier/test/legacy.py +20 -30
- appier/test/log.py +14 -35
- appier/test/mock.py +27 -123
- appier/test/model.py +79 -91
- appier/test/part.py +5 -14
- appier/test/preferences.py +5 -13
- appier/test/queuing.py +29 -37
- appier/test/request.py +61 -73
- appier/test/serialize.py +12 -23
- appier/test/session.py +10 -19
- appier/test/smtp.py +8 -14
- appier/test/structures.py +20 -24
- appier/test/typesf.py +14 -28
- appier/test/util.py +480 -438
- appier/typesf.py +251 -171
- appier/util.py +578 -407
- appier/validation.py +280 -143
- {appier-1.31.4.dist-info → appier-1.32.0.dist-info}/METADATA +6 -1
- appier-1.32.0.dist-info/RECORD +86 -0
- appier-1.31.4.dist-info/RECORD +0 -86
- {appier-1.31.4.dist-info → appier-1.32.0.dist-info}/LICENSE +0 -0
- {appier-1.31.4.dist-info → appier-1.32.0.dist-info}/WHEEL +0 -0
- {appier-1.31.4.dist-info → appier-1.32.0.dist-info}/top_level.txt +0 -0
appier/redisdb.py
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
# -*- coding: utf-8 -*-
|
|
3
3
|
|
|
4
4
|
# Hive Appier Framework
|
|
5
|
-
# Copyright (c) 2008-
|
|
5
|
+
# Copyright (c) 2008-2024 Hive Solutions Lda.
|
|
6
6
|
#
|
|
7
7
|
# This file is part of Hive Appier Framework.
|
|
8
8
|
#
|
|
@@ -22,16 +22,7 @@
|
|
|
22
22
|
__author__ = "João Magalhães <joamag@hive.pt>"
|
|
23
23
|
""" The author(s) of the module """
|
|
24
24
|
|
|
25
|
-
|
|
26
|
-
""" The version of the module """
|
|
27
|
-
|
|
28
|
-
__revision__ = "$LastChangedRevision$"
|
|
29
|
-
""" The revision number of the module """
|
|
30
|
-
|
|
31
|
-
__date__ = "$LastChangedDate$"
|
|
32
|
-
""" The last change date of the module """
|
|
33
|
-
|
|
34
|
-
__copyright__ = "Copyright (c) 2008-2022 Hive Solutions Lda."
|
|
25
|
+
__copyright__ = "Copyright (c) 2008-2024 Hive Solutions Lda."
|
|
35
26
|
""" The copyright for the module """
|
|
36
27
|
|
|
37
28
|
__license__ = "Apache License, Version 2.0"
|
|
@@ -43,8 +34,10 @@ from . import util
|
|
|
43
34
|
from . import config
|
|
44
35
|
from . import exceptions
|
|
45
36
|
|
|
46
|
-
try:
|
|
47
|
-
|
|
37
|
+
try:
|
|
38
|
+
import redis
|
|
39
|
+
except ImportError:
|
|
40
|
+
redis = None
|
|
48
41
|
|
|
49
42
|
URL = "redis://localhost"
|
|
50
43
|
""" The default URL to be used for the connection when
|
|
@@ -58,58 +51,70 @@ connection = None
|
|
|
58
51
|
""" The global connection object that should persist
|
|
59
52
|
the connection relation with the database service """
|
|
60
53
|
|
|
61
|
-
class Redis(object):
|
|
62
54
|
|
|
63
|
-
|
|
55
|
+
class Redis(object):
|
|
56
|
+
def __init__(self, url=None, pool=None):
|
|
64
57
|
self.url = url
|
|
65
58
|
self.pool = pool
|
|
66
59
|
self._connection = None
|
|
67
60
|
|
|
68
|
-
def get_connection(self, url
|
|
69
|
-
if self._connection:
|
|
61
|
+
def get_connection(self, url=None, pool=None):
|
|
62
|
+
if self._connection:
|
|
63
|
+
return self._connection
|
|
70
64
|
|
|
71
65
|
url_c = config.conf("REDISTOGO_URL", None)
|
|
72
66
|
url_c = config.conf("REDIS_URL", url_c)
|
|
73
|
-
pool_c = config.conf("REDIS_POOL", True, cast
|
|
67
|
+
pool_c = config.conf("REDIS_POOL", True, cast=bool)
|
|
74
68
|
|
|
75
69
|
_url = URL
|
|
76
|
-
if not url_c == None:
|
|
77
|
-
|
|
78
|
-
if not url == None:
|
|
70
|
+
if not url_c == None:
|
|
71
|
+
_url = url_c
|
|
72
|
+
if not self.url == None:
|
|
73
|
+
_url = self.url
|
|
74
|
+
if not url == None:
|
|
75
|
+
_url = url
|
|
79
76
|
|
|
80
77
|
_pool = POOL
|
|
81
|
-
if not pool_c == None:
|
|
82
|
-
|
|
83
|
-
if not pool == None:
|
|
78
|
+
if not pool_c == None:
|
|
79
|
+
_pool = pool_c
|
|
80
|
+
if not self.pool == None:
|
|
81
|
+
_pool = self.pool
|
|
82
|
+
if not pool == None:
|
|
83
|
+
_pool = pool
|
|
84
84
|
|
|
85
85
|
if _pool:
|
|
86
86
|
connection_pool = _redis().BlockingConnectionPool.from_url(_url)
|
|
87
|
-
self._connection = _redis().Redis(connection_pool
|
|
87
|
+
self._connection = _redis().Redis(connection_pool=connection_pool)
|
|
88
88
|
else:
|
|
89
89
|
self._connection = _redis().from_url(_url)
|
|
90
90
|
|
|
91
91
|
return self._connection
|
|
92
92
|
|
|
93
|
-
|
|
93
|
+
|
|
94
|
+
def get_connection(url=URL):
|
|
94
95
|
global connection
|
|
95
|
-
if connection:
|
|
96
|
+
if connection:
|
|
97
|
+
return connection
|
|
96
98
|
url = config.conf("REDISTOGO_URL", url)
|
|
97
99
|
url = config.conf("REDIS_URL", url)
|
|
98
|
-
pool = config.conf("REDIS_POOL", True, cast
|
|
100
|
+
pool = config.conf("REDIS_POOL", True, cast=bool)
|
|
99
101
|
if pool:
|
|
100
102
|
connection_pool = _redis().BlockingConnectionPool.from_url(url)
|
|
101
|
-
connection = _redis().Redis(connection_pool
|
|
103
|
+
connection = _redis().Redis(connection_pool=connection_pool)
|
|
102
104
|
else:
|
|
103
105
|
connection = _redis().from_url(url)
|
|
104
106
|
return connection
|
|
105
107
|
|
|
108
|
+
|
|
106
109
|
def dumps(*args):
|
|
107
110
|
return json.dumps(*args)
|
|
108
111
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
112
|
+
|
|
113
|
+
def _redis(verify=True):
|
|
114
|
+
if verify:
|
|
115
|
+
util.verify(
|
|
116
|
+
not redis == None,
|
|
117
|
+
message="RedisPy library not available",
|
|
118
|
+
exception=exceptions.OperationalError,
|
|
119
|
+
)
|
|
115
120
|
return redis
|