velocity-python 0.0.22__py3-none-any.whl → 0.0.24__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,6 +1,5 @@
1
- __version__ = version = "0.0.22"
1
+ __version__ = version = "0.0.24"
2
2
 
3
3
  from . import aws
4
4
  from . import db
5
- from . import misc
6
-
5
+ from . import misc
@@ -12,7 +12,7 @@ from . import context
12
12
 
13
13
 
14
14
  class LambdaHandler:
15
- def __init__(self, aws_event, aws_context):
15
+ def __init__(self, aws_event, aws_context, context_class=context.Context):
16
16
  self.aws_event = aws_event
17
17
  self.aws_context = aws_context
18
18
  self.serve_action_default = True # Set to False to disable OnActionDefault
@@ -48,6 +48,8 @@ class LambdaHandler:
48
48
  else:
49
49
  self.session["device_type"] = "unknown"
50
50
 
51
+ self.ContextClass = context_class
52
+
51
53
  def log(self, tx, message, function=None):
52
54
  if not function:
53
55
  function = "<Unknown>"
@@ -95,7 +97,7 @@ class LambdaHandler:
95
97
  postdata = {"raw_body": body}
96
98
 
97
99
  req_params = self.aws_event.get("queryStringParameters") or {}
98
- local_context = context.Context(
100
+ local_context = self.ContextClass(
99
101
  aws_event=self.aws_event,
100
102
  aws_context=self.aws_context,
101
103
  args=req_params,
@@ -3,15 +3,17 @@ import json
3
3
  import sys
4
4
  import os
5
5
  import traceback
6
- from support.app import DEBUG
6
+ from velocity.aws import DEBUG
7
+ from velocity.aws.handlers import context
7
8
 
8
9
 
9
10
  class SqsHandler:
10
- def __init__(self, aws_event, aws_context):
11
+ def __init__(self, aws_event, aws_context, context_class=context.Context):
11
12
  self.aws_event = aws_event
12
13
  self.aws_context = aws_context
13
14
  self.serve_action_default = True
14
15
  self.skip_action = False
16
+ self.ContextClass = context_class
15
17
 
16
18
  def log(self, tx, message, function=None):
17
19
  if not function:
@@ -47,10 +49,17 @@ class SqsHandler:
47
49
  postdata = {}
48
50
  if record.get("body"):
49
51
  postdata = json.loads(record.get("body"))
52
+
53
+ local_context = self.ContextClass(
54
+ aws_event=self.aws_event,
55
+ aws_context=self.aws_context,
56
+ args=attrs,
57
+ postdata=postdata,
58
+ )
50
59
  if hasattr(self, "beforeAction"):
51
- self.beforeAction(attrs=attrs, postdata=postdata)
60
+ self.beforeAction(local_context)
52
61
  actions = []
53
- action = postdata.get("action")
62
+ action = local_context.action()
54
63
  if action:
55
64
  actions.append(
56
65
  f"on action {action.replace('-', ' ').replace('_', ' ')}".title().replace(
@@ -63,24 +72,23 @@ class SqsHandler:
63
72
  if self.skip_action:
64
73
  return
65
74
  if hasattr(self, action):
66
- getattr(self, action)(attrs=attrs, postdata=postdata)
75
+ getattr(self, action)(local_context)
67
76
  break
68
77
  if hasattr(self, "afterAction"):
69
- self.afterAction(attrs=attrs, postdata=postdata)
78
+ self.afterAction(local_context)
70
79
  except Exception as e:
71
80
  if hasattr(self, "onError"):
72
81
  self.onError(
73
- attrs=attrs,
74
- postdata=postdata,
82
+ local_context,
75
83
  exc=e.__class__.__name__,
76
84
  tb=traceback.format_exc(),
77
85
  )
78
86
 
79
- def OnActionDefault(self, tx, attrs, postdata):
87
+ def OnActionDefault(self, tx, context):
80
88
  print(
81
89
  f"""
82
90
  [Warn] Action handler not found. Calling default action `SqsHandler.OnActionDefault` with the following parameters for attrs, and postdata:
83
- attrs: {str(attrs)}
84
- postdata: {str(postdata)}
91
+ attrs: {str(context.args())}
92
+ postdata: {str(context.postdata())}
85
93
  """
86
94
  )
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: velocity-python
3
- Version: 0.0.22
3
+ Version: 0.0.24
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=9dy4ndePnxfh9P6bfWUBWWycbVl_W3S_9RHSghSYLVY,91
1
+ velocity/__init__.py,sha256=0KjYGexgpGZxQbpjJkDZ_NDCeG46QHSnSHRZGipSHlE,88
2
2
  velocity/aws/__init__.py,sha256=ukvGrS0R8p6HtYajexOAJ7Kn9CJNlx6yb58W7o-JrAg,620
3
3
  velocity/aws/handlers/__init__.py,sha256=xnpFZJVlC2uoeeFW4zuPST8wA8ajaQDky5Y6iXZzi3A,172
4
4
  velocity/aws/handlers/context.py,sha256=UIjNR83y2NSIyK8HMPX8t5tpJHFNabiZvNgmmdQL3HA,1822
5
- velocity/aws/handlers/lambda_handler.py,sha256=OTraH0vvtloQLBI-kAaVVHHbsyCXhGQtbWiDiKkn3BI,6233
5
+ velocity/aws/handlers/lambda_handler.py,sha256=RfEFIIn6a2k0W25AMEOMWCqbpUkXF13kV6vXFVKz0b0,6309
6
6
  velocity/aws/handlers/response.py,sha256=PlbrTFWZ6-2s7MGqaGAYENVuL63wOC7FlW7ZogFyTKo,3869
7
- velocity/aws/handlers/sqs_handler.py,sha256=yf7eFfIB2sYeZ4BspWTAYU8IeayQQm7QVCUxbgafyV0,3043
7
+ velocity/aws/handlers/sqs_handler.py,sha256=d0vvWNeGLQ7TLh4_yDiaJ-gpdfxCgHDY9_n9VpzQFns,3315
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
@@ -33,8 +33,8 @@ velocity/misc/timer.py,sha256=wMbV-1yNXeCJo_UPi5sTSslu9hPzokLaIKgd98tyG_4,536
33
33
  velocity/misc/conv/__init__.py,sha256=-caOuiqo0mzjP30Rh-3T0bSlt4M-SzJ4SPr2COk9wmg,39
34
34
  velocity/misc/conv/iconv.py,sha256=V-PcpDXq7wCmyxZ3sXfzpmVH5Nc9OHScvMH26K7N3bI,4375
35
35
  velocity/misc/conv/oconv.py,sha256=TGC6vTcOACtwp_Gpce33ZiVmgqBYQnwBcMNQ1MP6Qdc,4121
36
- velocity_python-0.0.22.dist-info/LICENSE,sha256=aoN245GG8s9oRUU89KNiGTU4_4OtnNmVi4hQeChg6rM,1076
37
- velocity_python-0.0.22.dist-info/METADATA,sha256=2aL3C67s0MXBoO-OptRQ7LqnQob81n7KvSS1iLrnAlw,8522
38
- velocity_python-0.0.22.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
39
- velocity_python-0.0.22.dist-info/top_level.txt,sha256=JW2vJPmodgdgSz7H6yoZvnxF8S3fTMIv-YJWCT1sNW0,9
40
- velocity_python-0.0.22.dist-info/RECORD,,
36
+ velocity_python-0.0.24.dist-info/LICENSE,sha256=aoN245GG8s9oRUU89KNiGTU4_4OtnNmVi4hQeChg6rM,1076
37
+ velocity_python-0.0.24.dist-info/METADATA,sha256=YRlbTDrO1DbglL1yZ4tRiBsX_W-1zVX35l_ppIsmlsw,8522
38
+ velocity_python-0.0.24.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
39
+ velocity_python-0.0.24.dist-info/top_level.txt,sha256=JW2vJPmodgdgSz7H6yoZvnxF8S3fTMIv-YJWCT1sNW0,9
40
+ velocity_python-0.0.24.dist-info/RECORD,,