velocity-python 0.0.64__py3-none-any.whl → 0.0.65__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.
- velocity/__init__.py +1 -1
- velocity/db/core/engine.py +27 -21
- {velocity_python-0.0.64.dist-info → velocity_python-0.0.65.dist-info}/METADATA +3 -2
- {velocity_python-0.0.64.dist-info → velocity_python-0.0.65.dist-info}/RECORD +7 -7
- {velocity_python-0.0.64.dist-info → velocity_python-0.0.65.dist-info}/WHEEL +1 -1
- {velocity_python-0.0.64.dist-info → velocity_python-0.0.65.dist-info/licenses}/LICENSE +0 -0
- {velocity_python-0.0.64.dist-info → velocity_python-0.0.65.dist-info}/top_level.txt +0 -0
velocity/__init__.py
CHANGED
velocity/db/core/engine.py
CHANGED
|
@@ -57,6 +57,8 @@ class Engine:
|
|
|
57
57
|
May also be used to decorate a class, in which case all methods are wrapped in a transaction if they accept `tx`.
|
|
58
58
|
With no arguments, returns a new Transaction directly.
|
|
59
59
|
"""
|
|
60
|
+
# print("Transaction", func_or_cls.__name__, type(func_or_cls))
|
|
61
|
+
|
|
60
62
|
if func_or_cls is None:
|
|
61
63
|
return Transaction(self)
|
|
62
64
|
|
|
@@ -64,15 +66,21 @@ class Engine:
|
|
|
64
66
|
return classmethod(self.transaction(func_or_cls.__func__))
|
|
65
67
|
|
|
66
68
|
if inspect.isfunction(func_or_cls) or inspect.ismethod(func_or_cls):
|
|
69
|
+
names = list(inspect.signature(func_or_cls).parameters.keys())
|
|
70
|
+
# print(func_or_cls.__name__, names)
|
|
71
|
+
if "_tx" in names:
|
|
72
|
+
raise NameError(
|
|
73
|
+
f"In function {func_or_cls.__name__}, '_tx' is not allowed as a parameter."
|
|
74
|
+
)
|
|
67
75
|
|
|
68
76
|
@wraps(func_or_cls)
|
|
69
77
|
def new_function(*args, **kwds):
|
|
70
78
|
tx = None
|
|
71
79
|
names = list(inspect.signature(func_or_cls).parameters.keys())
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
80
|
+
|
|
81
|
+
# print("inside", func_or_cls.__name__)
|
|
82
|
+
# print(names)
|
|
83
|
+
# print(args, kwds)
|
|
76
84
|
|
|
77
85
|
if "tx" not in names:
|
|
78
86
|
# The function doesn't even declare a `tx` parameter, so run normally.
|
|
@@ -91,33 +99,31 @@ class Engine:
|
|
|
91
99
|
if len(args) > pos:
|
|
92
100
|
if isinstance(args[pos], Transaction):
|
|
93
101
|
tx = args[pos]
|
|
94
|
-
|
|
95
|
-
raise TypeError(
|
|
96
|
-
f"In function {func_or_cls.__name__}, positional argument `tx` must be a Transaction object."
|
|
97
|
-
)
|
|
102
|
+
|
|
98
103
|
if tx:
|
|
99
104
|
return self.exec_function(func_or_cls, tx, *args, **kwds)
|
|
105
|
+
|
|
100
106
|
with Transaction(self) as local_tx:
|
|
101
107
|
pos = names.index("tx")
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
args = tuple(args)
|
|
105
|
-
return self.exec_function(func_or_cls, local_tx, *args, **kwds)
|
|
108
|
+
new_args = args[:pos] + (local_tx,) + args[pos:]
|
|
109
|
+
return self.exec_function(func_or_cls, local_tx, *new_args, **kwds)
|
|
106
110
|
|
|
107
111
|
return new_function
|
|
108
112
|
|
|
109
113
|
if inspect.isclass(func_or_cls):
|
|
110
114
|
|
|
111
|
-
|
|
112
|
-
|
|
115
|
+
NewCls = type(func_or_cls.__name__, (func_or_cls,), {})
|
|
116
|
+
|
|
117
|
+
for attr_name in dir(func_or_cls):
|
|
118
|
+
# Optionally skip special methods
|
|
119
|
+
if attr_name.startswith("__") and attr_name.endswith("__"):
|
|
120
|
+
continue
|
|
121
|
+
|
|
122
|
+
attr = getattr(func_or_cls, attr_name)
|
|
123
|
+
|
|
124
|
+
if callable(attr):
|
|
125
|
+
setattr(NewCls, attr_name, self.transaction(attr))
|
|
113
126
|
|
|
114
|
-
for attr_name, attr_value in func_or_cls.__dict__.items():
|
|
115
|
-
if (
|
|
116
|
-
isinstance(attr_value, classmethod)
|
|
117
|
-
or inspect.isfunction(attr_value)
|
|
118
|
-
or inspect.ismethod(attr_value)
|
|
119
|
-
):
|
|
120
|
-
setattr(NewCls, attr_name, self.transaction(attr_value))
|
|
121
127
|
return NewCls
|
|
122
128
|
|
|
123
129
|
return Transaction(self)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: velocity-python
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.65
|
|
4
4
|
Summary: A rapid application development library for interfacing with data storage
|
|
5
5
|
Author-email: Paul Perez <pperez@codeclubs.org>
|
|
6
6
|
Project-URL: Homepage, https://codeclubs.org/projects/velocity
|
|
@@ -20,6 +20,7 @@ Provides-Extra: sqlserver
|
|
|
20
20
|
Requires-Dist: python-tds; extra == "sqlserver"
|
|
21
21
|
Provides-Extra: postgres
|
|
22
22
|
Requires-Dist: psycopg2-binary; extra == "postgres"
|
|
23
|
+
Dynamic: license-file
|
|
23
24
|
|
|
24
25
|
# Velocity.DB
|
|
25
26
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
velocity/__init__.py,sha256=
|
|
1
|
+
velocity/__init__.py,sha256=tnCHtyfWXavmucW3wZZmZgDISzewWOYgOz67mQtdU1U,88
|
|
2
2
|
velocity/aws/__init__.py,sha256=GBTEr02whnCH3TG-BWCpUC3KfHY3uNxD21g0OvsVJnc,598
|
|
3
3
|
velocity/aws/handlers/__init__.py,sha256=xnpFZJVlC2uoeeFW4zuPST8wA8ajaQDky5Y6iXZzi3A,172
|
|
4
4
|
velocity/aws/handlers/context.py,sha256=UIjNR83y2NSIyK8HMPX8t5tpJHFNabiZvNgmmdQL3HA,1822
|
|
@@ -10,7 +10,7 @@ velocity/db/core/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,
|
|
|
10
10
|
velocity/db/core/column.py,sha256=tAr8tL3a2nyaYpNHhGl508FrY_pGZTzyYgjAV5CEBv4,4092
|
|
11
11
|
velocity/db/core/database.py,sha256=3zNGItklu9tZCKsbx2T2vCcU1so8AL9PPL0DLjvaz6s,3554
|
|
12
12
|
velocity/db/core/decorators.py,sha256=ZwwNc6wGx7Qe7xPZGgeHuqqtXEeNqyDXB0M5ROY-40I,4612
|
|
13
|
-
velocity/db/core/engine.py,sha256=
|
|
13
|
+
velocity/db/core/engine.py,sha256=NVsS9HPu13Lzuz7UHjUdsCRuBe2cYVKwgAVf9SLc1E0,13123
|
|
14
14
|
velocity/db/core/exceptions.py,sha256=MOWyA1mlMe8eWbFkEHK0Lp9czdplpRyqbAn2JfGmMrM,707
|
|
15
15
|
velocity/db/core/result.py,sha256=OVqoMwlx3CHNNwr-JGWRx5I8u_YX6hlUpecx99UT5nE,6164
|
|
16
16
|
velocity/db/core/row.py,sha256=aliLYTTFirgJsOvmUsANwJMyxaATuhpGpFJhcu_twwY,6709
|
|
@@ -40,8 +40,8 @@ velocity/misc/timer.py,sha256=cN3aS0t6HLlhYfF2Ir6ihJehxNrWf9ebaLzXUaWRKEA,1637
|
|
|
40
40
|
velocity/misc/conv/__init__.py,sha256=MLYF58QHjzfDSxb1rdnmLnuEQCa3gnhzzZ30CwZVvQo,40
|
|
41
41
|
velocity/misc/conv/iconv.py,sha256=d4_BucW8HTIkGNurJ7GWrtuptqUf-9t79ObzjJ5N76U,10603
|
|
42
42
|
velocity/misc/conv/oconv.py,sha256=h5Lo05DqOQnxoD3y6Px_MQP_V-pBbWf8Hkgkb9Xp1jk,6032
|
|
43
|
-
velocity_python-0.0.
|
|
44
|
-
velocity_python-0.0.
|
|
45
|
-
velocity_python-0.0.
|
|
46
|
-
velocity_python-0.0.
|
|
47
|
-
velocity_python-0.0.
|
|
43
|
+
velocity_python-0.0.65.dist-info/licenses/LICENSE,sha256=aoN245GG8s9oRUU89KNiGTU4_4OtnNmVi4hQeChg6rM,1076
|
|
44
|
+
velocity_python-0.0.65.dist-info/METADATA,sha256=FxYZMXv6FUR5HfLrHLO3e9lox6bKXIVxt5zZrHx1WpI,8541
|
|
45
|
+
velocity_python-0.0.65.dist-info/WHEEL,sha256=tTnHoFhvKQHCh4jz3yCn0WPTYIy7wXx3CJtJ7SJGV7c,91
|
|
46
|
+
velocity_python-0.0.65.dist-info/top_level.txt,sha256=JW2vJPmodgdgSz7H6yoZvnxF8S3fTMIv-YJWCT1sNW0,9
|
|
47
|
+
velocity_python-0.0.65.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|