velocity-python 0.0.12__tar.gz → 0.0.14__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.
Potentially problematic release.
This version of velocity-python might be problematic. Click here for more details.
- {velocity-python-0.0.12/src/velocity_python.egg-info → velocity-python-0.0.14}/PKG-INFO +1 -1
- {velocity-python-0.0.12 → velocity-python-0.0.14}/pyproject.toml +1 -1
- {velocity-python-0.0.12 → velocity-python-0.0.14}/src/velocity/__init__.py +1 -1
- velocity-python-0.0.14/src/velocity/aws/handlers/context.py +52 -0
- {velocity-python-0.0.12 → velocity-python-0.0.14}/src/velocity/aws/handlers/lambda_handler.py +23 -18
- {velocity-python-0.0.12 → velocity-python-0.0.14}/src/velocity/aws/handlers/sqs_handler.py +2 -2
- {velocity-python-0.0.12 → velocity-python-0.0.14/src/velocity_python.egg-info}/PKG-INFO +1 -1
- {velocity-python-0.0.12 → velocity-python-0.0.14}/src/velocity_python.egg-info/SOURCES.txt +1 -1
- velocity-python-0.0.12/src/velocity/aws/context.py +0 -0
- {velocity-python-0.0.12 → velocity-python-0.0.14}/LICENSE +0 -0
- {velocity-python-0.0.12 → velocity-python-0.0.14}/README.md +0 -0
- {velocity-python-0.0.12 → velocity-python-0.0.14}/setup.cfg +0 -0
- {velocity-python-0.0.12 → velocity-python-0.0.14}/src/velocity/aws/__init__.py +0 -0
- {velocity-python-0.0.12 → velocity-python-0.0.14}/src/velocity/aws/handlers/__init__.py +0 -0
- {velocity-python-0.0.12 → velocity-python-0.0.14}/src/velocity/aws/handlers/response.py +0 -0
- {velocity-python-0.0.12 → velocity-python-0.0.14}/src/velocity/db/__init__.py +0 -0
- {velocity-python-0.0.12 → velocity-python-0.0.14}/src/velocity/db/core/__init__.py +0 -0
- {velocity-python-0.0.12 → velocity-python-0.0.14}/src/velocity/db/core/column.py +0 -0
- {velocity-python-0.0.12 → velocity-python-0.0.14}/src/velocity/db/core/database.py +0 -0
- {velocity-python-0.0.12 → velocity-python-0.0.14}/src/velocity/db/core/decorators.py +0 -0
- {velocity-python-0.0.12 → velocity-python-0.0.14}/src/velocity/db/core/engine.py +0 -0
- {velocity-python-0.0.12 → velocity-python-0.0.14}/src/velocity/db/core/exceptions.py +0 -0
- {velocity-python-0.0.12 → velocity-python-0.0.14}/src/velocity/db/core/result.py +0 -0
- {velocity-python-0.0.12 → velocity-python-0.0.14}/src/velocity/db/core/row.py +0 -0
- {velocity-python-0.0.12 → velocity-python-0.0.14}/src/velocity/db/core/sequence.py +0 -0
- {velocity-python-0.0.12 → velocity-python-0.0.14}/src/velocity/db/core/table.py +0 -0
- {velocity-python-0.0.12 → velocity-python-0.0.14}/src/velocity/db/core/transaction.py +0 -0
- {velocity-python-0.0.12 → velocity-python-0.0.14}/src/velocity/db/servers/__init__.py +0 -0
- {velocity-python-0.0.12 → velocity-python-0.0.14}/src/velocity/db/servers/mysql.py +0 -0
- {velocity-python-0.0.12 → velocity-python-0.0.14}/src/velocity/db/servers/postgres.py +0 -0
- {velocity-python-0.0.12 → velocity-python-0.0.14}/src/velocity/db/servers/sql.py +0 -0
- {velocity-python-0.0.12 → velocity-python-0.0.14}/src/velocity/db/servers/sqlite.py +0 -0
- {velocity-python-0.0.12 → velocity-python-0.0.14}/src/velocity/db/servers/sqlserver.py +0 -0
- {velocity-python-0.0.12 → velocity-python-0.0.14}/src/velocity/misc/__init__.py +0 -0
- {velocity-python-0.0.12 → velocity-python-0.0.14}/src/velocity/misc/conv.py +0 -0
- {velocity-python-0.0.12 → velocity-python-0.0.14}/src/velocity/misc/db.py +0 -0
- {velocity-python-0.0.12 → velocity-python-0.0.14}/src/velocity/misc/export.py +0 -0
- {velocity-python-0.0.12 → velocity-python-0.0.14}/src/velocity/misc/format.py +0 -0
- {velocity-python-0.0.12 → velocity-python-0.0.14}/src/velocity/misc/mail.py +0 -0
- {velocity-python-0.0.12 → velocity-python-0.0.14}/src/velocity/misc/merge.py +0 -0
- {velocity-python-0.0.12 → velocity-python-0.0.14}/src/velocity/misc/timer.py +0 -0
- {velocity-python-0.0.12 → velocity-python-0.0.14}/src/velocity_python.egg-info/dependency_links.txt +0 -0
- {velocity-python-0.0.12 → velocity-python-0.0.14}/src/velocity_python.egg-info/requires.txt +0 -0
- {velocity-python-0.0.12 → velocity-python-0.0.14}/src/velocity_python.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: velocity-python
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.14
|
|
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
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import support.app
|
|
2
|
+
|
|
3
|
+
engine = support.app.postgres()
|
|
4
|
+
|
|
5
|
+
@engine.transaction
|
|
6
|
+
class Context:
|
|
7
|
+
def __init__(self,
|
|
8
|
+
args,
|
|
9
|
+
postdata,
|
|
10
|
+
response,
|
|
11
|
+
event,
|
|
12
|
+
session,
|
|
13
|
+
aws_context):
|
|
14
|
+
self.__args = args
|
|
15
|
+
self.__postdata = postdata,
|
|
16
|
+
self.__response = response,
|
|
17
|
+
self.__session = session,
|
|
18
|
+
self.__aws_event = event,
|
|
19
|
+
self.__aws_context = aws_context
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def postdata(self, keys=-1, default=None):
|
|
23
|
+
if keys == -1:
|
|
24
|
+
return self.__postdata
|
|
25
|
+
if not isinstance(keys, list):
|
|
26
|
+
keys = [keys]
|
|
27
|
+
data = self.__postdata
|
|
28
|
+
for key in keys:
|
|
29
|
+
if key in data:
|
|
30
|
+
data = data[key]
|
|
31
|
+
else:
|
|
32
|
+
return default
|
|
33
|
+
return data
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def payload(self, keys=-1, default={}):
|
|
37
|
+
if 'payload' not in self.__postdata:
|
|
38
|
+
return default
|
|
39
|
+
if keys == -1:
|
|
40
|
+
return self.__postdata['payload']
|
|
41
|
+
if not isinstance(keys, list):
|
|
42
|
+
keys = [keys]
|
|
43
|
+
data = self.__postdata['payload']
|
|
44
|
+
for key in keys:
|
|
45
|
+
if key in data:
|
|
46
|
+
data = data[key]
|
|
47
|
+
else:
|
|
48
|
+
return default
|
|
49
|
+
return data
|
|
50
|
+
|
|
51
|
+
def action(self):
|
|
52
|
+
return self.__postdata('action', self.__args('action', ''))
|
{velocity-python-0.0.12 → velocity-python-0.0.14}/src/velocity/aws/handlers/lambda_handler.py
RENAMED
|
@@ -5,18 +5,20 @@ import os
|
|
|
5
5
|
import traceback
|
|
6
6
|
from velocity.aws import DEBUG
|
|
7
7
|
from support.app import helpers, AlertError, enqueue
|
|
8
|
+
import velocity.aws.handlers
|
|
9
|
+
print(velocity.aws.handlers)
|
|
8
10
|
from response import Response
|
|
9
11
|
|
|
10
12
|
class LambdaHandler:
|
|
11
|
-
def __init__(self,
|
|
12
|
-
self.
|
|
13
|
-
self.
|
|
14
|
-
self.serve_action_default = True
|
|
15
|
-
self.skip_action = False
|
|
13
|
+
def __init__(self, aws_event, aws_context):
|
|
14
|
+
self.aws_event = aws_event
|
|
15
|
+
self.aws_context = aws_context
|
|
16
|
+
self.serve_action_default = True # Set to False to disable OnActionDefault
|
|
17
|
+
self.skip_action = False # Set to True to skip all actions
|
|
16
18
|
|
|
17
|
-
requestContext =
|
|
19
|
+
requestContext = aws_event.get("requestContext") or {}
|
|
18
20
|
identity = requestContext.get("identity") or {}
|
|
19
|
-
headers =
|
|
21
|
+
headers = aws_event.get("headers") or {}
|
|
20
22
|
auth = identity.get("cognitoAuthenticationProvider")
|
|
21
23
|
self.session = {
|
|
22
24
|
"authentication_provider": identity.get("cognitoAuthenticationProvider"),
|
|
@@ -27,7 +29,7 @@ class LambdaHandler:
|
|
|
27
29
|
"is_smart_tv": headers.get("CloudFront-Is-SmartTV-Viewer") == "true",
|
|
28
30
|
"is_tablet": headers.get("CloudFront-Is-Tablet-Viewer") == "true",
|
|
29
31
|
"origin": headers.get("origin"),
|
|
30
|
-
"path":
|
|
32
|
+
"path": aws_event.get("path"),
|
|
31
33
|
"referer": headers.get("Referer"),
|
|
32
34
|
"source_ip": identity.get("sourceIp"),
|
|
33
35
|
"user_agent": identity.get("userAgent"),
|
|
@@ -91,9 +93,16 @@ class LambdaHandler:
|
|
|
91
93
|
postdata = {"raw_body": body}
|
|
92
94
|
|
|
93
95
|
req_params = self.event.get("queryStringParameters") or {}
|
|
96
|
+
context = Context(
|
|
97
|
+
args=req_params,
|
|
98
|
+
postdata=postdata,
|
|
99
|
+
response=response,
|
|
100
|
+
event=self.aws_event,
|
|
101
|
+
session=self.session,
|
|
102
|
+
aws_context=self.aws_context)
|
|
94
103
|
try:
|
|
95
104
|
if hasattr(self, "beforeAction"):
|
|
96
|
-
self.beforeAction(
|
|
105
|
+
self.beforeAction(context)
|
|
97
106
|
actions = []
|
|
98
107
|
action = postdata.get("action", req_params.get("action"))
|
|
99
108
|
if action:
|
|
@@ -108,23 +117,19 @@ class LambdaHandler:
|
|
|
108
117
|
if self.skip_action:
|
|
109
118
|
break
|
|
110
119
|
if hasattr(self, action):
|
|
111
|
-
result = getattr(self, action)(
|
|
112
|
-
args=req_params, postdata=postdata, response=response
|
|
113
|
-
)
|
|
120
|
+
result = getattr(self, action)(context)
|
|
114
121
|
if result and result != response:
|
|
115
122
|
response.set_body(result)
|
|
116
123
|
break
|
|
117
124
|
if hasattr(self, "afterAction"):
|
|
118
|
-
self.afterAction(
|
|
125
|
+
self.afterAction(context)
|
|
119
126
|
except AlertError as e:
|
|
120
127
|
response.alert(e.get_payload())
|
|
121
128
|
except Exception as e:
|
|
122
129
|
response.exception()
|
|
123
130
|
if hasattr(self, "onError"):
|
|
124
131
|
self.onError(
|
|
125
|
-
|
|
126
|
-
postdata=postdata,
|
|
127
|
-
response=response,
|
|
132
|
+
context,
|
|
128
133
|
exc=e.__class__.__name__,
|
|
129
134
|
tb=traceback.format_exc(),
|
|
130
135
|
)
|
|
@@ -144,8 +149,8 @@ class LambdaHandler:
|
|
|
144
149
|
)
|
|
145
150
|
tx.table(helpers.get_tracking_table(user or self.session)).insert(data)
|
|
146
151
|
|
|
147
|
-
def OnActionDefault(self, tx,
|
|
148
|
-
return {"event": self.
|
|
152
|
+
def OnActionDefault(self, tx, context):
|
|
153
|
+
return {"event": self.aws_event, "postdata": context.postdata}
|
|
149
154
|
|
|
150
155
|
def OnActionTracking(self, tx, args, postdata, response):
|
|
151
156
|
self.track(tx, postdata.get("payload", {}).get("data", {}))
|
|
@@ -6,9 +6,9 @@ import traceback
|
|
|
6
6
|
from velocity.aws import DEBUG
|
|
7
7
|
|
|
8
8
|
class SqsHandler:
|
|
9
|
-
def __init__(self, event,
|
|
9
|
+
def __init__(self, event, aws_context):
|
|
10
10
|
self.event = event
|
|
11
|
-
self.
|
|
11
|
+
self.aws_context = aws_context
|
|
12
12
|
self.serve_action_default = True
|
|
13
13
|
self.skip_action = False
|
|
14
14
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: velocity-python
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.14
|
|
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
|
|
@@ -3,8 +3,8 @@ README.md
|
|
|
3
3
|
pyproject.toml
|
|
4
4
|
src/velocity/__init__.py
|
|
5
5
|
src/velocity/aws/__init__.py
|
|
6
|
-
src/velocity/aws/context.py
|
|
7
6
|
src/velocity/aws/handlers/__init__.py
|
|
7
|
+
src/velocity/aws/handlers/context.py
|
|
8
8
|
src/velocity/aws/handlers/lambda_handler.py
|
|
9
9
|
src/velocity/aws/handlers/response.py
|
|
10
10
|
src/velocity/aws/handlers/sqs_handler.py
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{velocity-python-0.0.12 → velocity-python-0.0.14}/src/velocity_python.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
{velocity-python-0.0.12 → velocity-python-0.0.14}/src/velocity_python.egg-info/top_level.txt
RENAMED
|
File without changes
|