velocity-python 0.0.15__py3-none-any.whl → 0.0.17__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.

Potentially problematic release.


This version of velocity-python might be problematic. Click here for more details.

velocity/__init__.py CHANGED
@@ -1,4 +1,4 @@
1
- __version__ = version = "0.0.15"
1
+ __version__ = version = "0.0.17"
2
2
 
3
3
  from . import aws
4
4
  from . import db
@@ -2,9 +2,11 @@ import support.app
2
2
 
3
3
  engine = support.app.postgres()
4
4
 
5
+
5
6
  @engine.transaction
6
7
  class Context:
7
- def __init__(self, args, postdata, response, aws_event, session, aws_context):
8
+
9
+ def __init__(self, aws_event, aws_context, args, postdata, response, session):
8
10
  self.__args = args
9
11
  self.__postdata = postdata
10
12
  self.__response = response
@@ -12,10 +14,9 @@ class Context:
12
14
  self.__aws_event = aws_event
13
15
  self.__aws_context = aws_context
14
16
 
15
-
16
17
  def postdata(self, keys=-1, default=None):
17
18
  if keys == -1:
18
- return self.__postdata
19
+ return self.__postdata
19
20
  if not isinstance(keys, list):
20
21
  keys = [keys]
21
22
  data = self.__postdata
@@ -25,22 +26,30 @@ class Context:
25
26
  else:
26
27
  return default
27
28
  return data
28
-
29
-
29
+
30
30
  def payload(self, keys=-1, default={}):
31
- if 'payload' not in self.__postdata:
32
- return default
31
+ if "payload" not in self.__postdata:
32
+ return default
33
33
  if keys == -1:
34
- return self.__postdata['payload']
34
+ return self.__postdata["payload"]
35
35
  if not isinstance(keys, list):
36
36
  keys = [keys]
37
- data = self.__postdata['payload']
37
+ data = self.__postdata["payload"]
38
38
  for key in keys:
39
39
  if key in data:
40
40
  data = data[key]
41
41
  else:
42
42
  return default
43
43
  return data
44
-
44
+
45
45
  def action(self):
46
- return self.__postdata('action', self.__args('action', ''))
46
+ return self.__postdata.get("action", self.__args.get("action", ""))
47
+
48
+ def args(self):
49
+ return self.__args
50
+
51
+ def response(self):
52
+ return self.__response
53
+
54
+ def session(self):
55
+ return self.__session
@@ -5,16 +5,18 @@ 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)
10
- from response import Response
8
+
9
+ from velocity.aws.handlers import Response
10
+
11
+ from . import context
12
+
11
13
 
12
14
  class LambdaHandler:
13
15
  def __init__(self, aws_event, aws_context):
14
16
  self.aws_event = aws_event
15
17
  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
18
+ self.serve_action_default = True # Set to False to disable OnActionDefault
19
+ self.skip_action = False # Set to True to skip all actions
18
20
 
19
21
  requestContext = aws_event.get("requestContext") or {}
20
22
  identity = requestContext.get("identity") or {}
@@ -76,7 +78,7 @@ class LambdaHandler:
76
78
 
77
79
  def serve(self, tx):
78
80
  response = Response()
79
- body = self.event.get("body")
81
+ body = self.aws_event.get("body")
80
82
  postdata = {}
81
83
  if isinstance(body, str) and len(body) > 0:
82
84
  try:
@@ -92,17 +94,18 @@ class LambdaHandler:
92
94
  except:
93
95
  postdata = {"raw_body": body}
94
96
 
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)
97
+ req_params = self.aws_event.get("queryStringParameters") or {}
98
+ local_context = context.Context(
99
+ aws_event=self.aws_event,
100
+ aws_context=self.aws_context,
101
+ args=req_params,
102
+ postdata=postdata,
103
+ response=response,
104
+ session=self.session,
105
+ )
103
106
  try:
104
107
  if hasattr(self, "beforeAction"):
105
- self.beforeAction(context)
108
+ self.beforeAction(local_context)
106
109
  actions = []
107
110
  action = postdata.get("action", req_params.get("action"))
108
111
  if action:
@@ -117,19 +120,19 @@ class LambdaHandler:
117
120
  if self.skip_action:
118
121
  break
119
122
  if hasattr(self, action):
120
- result = getattr(self, action)(context)
123
+ result = getattr(self, action)(local_context)
121
124
  if result and result != response:
122
125
  response.set_body(result)
123
126
  break
124
127
  if hasattr(self, "afterAction"):
125
- self.afterAction(context)
128
+ self.afterAction(local_context)
126
129
  except AlertError as e:
127
130
  response.alert(e.get_payload())
128
131
  except Exception as e:
129
132
  response.exception()
130
133
  if hasattr(self, "onError"):
131
134
  self.onError(
132
- context,
135
+ local_context,
133
136
  exc=e.__class__.__name__,
134
137
  tb=traceback.format_exc(),
135
138
  )
@@ -156,4 +159,4 @@ class LambdaHandler:
156
159
  self.track(tx, postdata.get("payload", {}).get("data", {}))
157
160
 
158
161
  def enqueue(self, tx, action, payload={}):
159
- return enqueue(tx, action, payload, self.session["email_address"])
162
+ return enqueue(tx, action, payload, self.session["email_address"])
@@ -5,9 +5,10 @@ import os
5
5
  import traceback
6
6
  from velocity.aws import DEBUG
7
7
 
8
+
8
9
  class SqsHandler:
9
- def __init__(self, event, aws_context):
10
- self.event = event
10
+ def __init__(self, aws_event, aws_context):
11
+ self.aws_event = aws_event
11
12
  self.aws_context = aws_context
12
13
  self.serve_action_default = True
13
14
  self.skip_action = False
@@ -39,7 +40,7 @@ class SqsHandler:
39
40
  tx.table("sys_log").insert(data)
40
41
 
41
42
  def serve(self, tx):
42
- records = self.event.get("Records", [])
43
+ records = self.aws_event.get("Records", [])
43
44
  for record in records:
44
45
  attrs = record.get("attributes")
45
46
  try:
@@ -82,4 +83,4 @@ class SqsHandler:
82
83
  attrs: {str(attrs)}
83
84
  postdata: {str(postdata)}
84
85
  """
85
- )
86
+ )
@@ -1,2 +1,2 @@
1
- import iconv
2
- import oconv
1
+ from . import iconv
2
+ from . import oconv
@@ -2,7 +2,7 @@ import re
2
2
  import codecs
3
3
  import decimal
4
4
  from email.utils import parseaddr
5
- from datetime import datetime, date, time
5
+ from datetime import datetime
6
6
 
7
7
 
8
8
  def none(data):
@@ -1,7 +1,6 @@
1
1
  import re
2
2
  import codecs
3
3
  import decimal
4
- from email.utils import parseaddr
5
4
  from datetime import datetime, date, time
6
5
  from pprint import pformat
7
6
 
@@ -29,7 +28,7 @@ def day_of_week(data, abbrev=False):
29
28
  if isinstance(data, list):
30
29
  new = []
31
30
  for day in data:
32
- new.append(oconv.day_of_week(day, abbrev=abbrev))
31
+ new.append(day_of_week(day, abbrev=abbrev))
33
32
  return ','.join(new)
34
33
  if data == None:
35
34
  return ''
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: velocity-python
3
- Version: 0.0.15
3
+ Version: 0.0.17
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
@@ -1,10 +1,10 @@
1
- velocity/__init__.py,sha256=dS3F-P5z7oQRT9ZCnPWehiGh--JKf7DaecuiTg6ixFQ,91
1
+ velocity/__init__.py,sha256=_wSZTf8oi9YjNisjKV8-cfMfkKyqXEBfHbQ3cQrejjk,91
2
2
  velocity/aws/__init__.py,sha256=ukvGrS0R8p6HtYajexOAJ7Kn9CJNlx6yb58W7o-JrAg,620
3
3
  velocity/aws/handlers/__init__.py,sha256=xnpFZJVlC2uoeeFW4zuPST8wA8ajaQDky5Y6iXZzi3A,172
4
- velocity/aws/handlers/context.py,sha256=fxEGsF-hs7W2VI5IJ8hhrY79zTxDC43xtkauSZjnQto,1295
5
- velocity/aws/handlers/lambda_handler.py,sha256=NWkzy32HrJfnM1qVcIgwlbqZ60en7iX6uQamGBX-DQw,6147
4
+ velocity/aws/handlers/context.py,sha256=b4WPTUekKDCcUi5oqJRkS3idmJWwnceQjUbtMG2XW30,1443
5
+ velocity/aws/handlers/lambda_handler.py,sha256=B-58EIkJnyajni-wZd4faGir_ClzR5-lB1VnYlI96IA,6185
6
6
  velocity/aws/handlers/response.py,sha256=VN4uFI_wtHiqAyBLX-eeQlmCwj1hdIvokvZLjsOyCnw,3915
7
- velocity/aws/handlers/sqs_handler.py,sha256=LmAuvwvlk3YJg1_ivODLCoaekWsn6MaCWtPgpkXU-O4,3026
7
+ velocity/aws/handlers/sqs_handler.py,sha256=pPXUaKSWoC-gy6rRfB8Gt9m2qCt2_XdO3FDnksXRBHk,3044
8
8
  velocity/db/__init__.py,sha256=vrn2AFNAKaqTdnPwLFS0OcREcCtzUCOodlmH54U7ADg,200
9
9
  velocity/db/core/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
10
10
  velocity/db/core/column.py,sha256=vB7dCrcIWFvRG1fgyzDQnEu7j_0KYxUuDSTCWVCYlPc,6153
@@ -30,11 +30,11 @@ velocity/misc/format.py,sha256=2GwdWOpUqmQjtLJKrHjQjTMFrATF6G1IXkLI1xVPB7U,2301
30
30
  velocity/misc/mail.py,sha256=fKfJtEkRKO3f_JbHNw9ThxKHJnChlBMsQwmEDFgj264,2096
31
31
  velocity/misc/merge.py,sha256=hBYPJy6lGL8lzb0wK1i1oEAyzragTWKF1rW9_PGHm6s,918
32
32
  velocity/misc/timer.py,sha256=wMbV-1yNXeCJo_UPi5sTSslu9hPzokLaIKgd98tyG_4,536
33
- velocity/misc/conv/__init__.py,sha256=yFPQtFxihlyQWYhOb25eeJmWj0IxvwOeG5lyNHVjzDA,25
34
- velocity/misc/conv/iconv.py,sha256=JQZzm_xTjHt4R9Hj5rV20eaaWT70sPXjtvtWav8dEsQ,4297
35
- velocity/misc/conv/oconv.py,sha256=b9sKmO16tEZA0ijLwVOGIht58qPHhf0zGBMSewXuLQo,4161
36
- velocity_python-0.0.15.dist-info/LICENSE,sha256=aoN245GG8s9oRUU89KNiGTU4_4OtnNmVi4hQeChg6rM,1076
37
- velocity_python-0.0.15.dist-info/METADATA,sha256=HgK4HcL_eecJRWWUvu9tPhLmvbd4wkDT28qeh8X5uoQ,8522
38
- velocity_python-0.0.15.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
39
- velocity_python-0.0.15.dist-info/top_level.txt,sha256=JW2vJPmodgdgSz7H6yoZvnxF8S3fTMIv-YJWCT1sNW0,9
40
- velocity_python-0.0.15.dist-info/RECORD,,
33
+ velocity/misc/conv/__init__.py,sha256=-caOuiqo0mzjP30Rh-3T0bSlt4M-SzJ4SPr2COk9wmg,39
34
+ velocity/misc/conv/iconv.py,sha256=48cXXeDpGPnOixB4CJoS_Ejf5fljzryaRgzwdGZBtcU,4285
35
+ velocity/misc/conv/oconv.py,sha256=TGC6vTcOACtwp_Gpce33ZiVmgqBYQnwBcMNQ1MP6Qdc,4121
36
+ velocity_python-0.0.17.dist-info/LICENSE,sha256=aoN245GG8s9oRUU89KNiGTU4_4OtnNmVi4hQeChg6rM,1076
37
+ velocity_python-0.0.17.dist-info/METADATA,sha256=dc41-gReA3C2oVFef-VhDjUn5aXLCbRm4CnokELQQZA,8522
38
+ velocity_python-0.0.17.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
39
+ velocity_python-0.0.17.dist-info/top_level.txt,sha256=JW2vJPmodgdgSz7H6yoZvnxF8S3fTMIv-YJWCT1sNW0,9
40
+ velocity_python-0.0.17.dist-info/RECORD,,