cloudoll 2.2.7__tar.gz → 2.2.8__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.
- {cloudoll-2.2.7 → cloudoll-2.2.8}/PKG-INFO +1 -1
- cloudoll-2.2.8/cloudoll/__init__.py +1 -0
- {cloudoll-2.2.7 → cloudoll-2.2.8}/cloudoll/orm/field.py +1 -1
- {cloudoll-2.2.7 → cloudoll-2.2.8}/cloudoll/orm/model.py +18 -7
- {cloudoll-2.2.7 → cloudoll-2.2.8}/cloudoll/utils/watch.py +0 -1
- {cloudoll-2.2.7 → cloudoll-2.2.8}/cloudoll/web/__init__.py +17 -7
- {cloudoll-2.2.7 → cloudoll-2.2.8}/cloudoll.egg-info/PKG-INFO +1 -1
- cloudoll-2.2.7/cloudoll/__init__.py +0 -1
- {cloudoll-2.2.7 → cloudoll-2.2.8}/LICENSE +0 -0
- {cloudoll-2.2.7 → cloudoll-2.2.8}/README.md +0 -0
- {cloudoll-2.2.7 → cloudoll-2.2.8}/cloudoll/__main__.py +0 -0
- {cloudoll-2.2.7 → cloudoll-2.2.8}/cloudoll/cli.py +0 -0
- {cloudoll-2.2.7 → cloudoll-2.2.8}/cloudoll/error/__init__.py +0 -0
- {cloudoll-2.2.7 → cloudoll-2.2.8}/cloudoll/error/errors.py +0 -0
- {cloudoll-2.2.7 → cloudoll-2.2.8}/cloudoll/logging/__init__.py +0 -0
- {cloudoll-2.2.7 → cloudoll-2.2.8}/cloudoll/mail/__init__.py +0 -0
- {cloudoll-2.2.7 → cloudoll-2.2.8}/cloudoll/mail/smtp.py +0 -0
- {cloudoll-2.2.7 → cloudoll-2.2.8}/cloudoll/orm/__init__.py +0 -0
- {cloudoll-2.2.7 → cloudoll-2.2.8}/cloudoll/orm/base.py +0 -0
- {cloudoll-2.2.7 → cloudoll-2.2.8}/cloudoll/orm/err.py +0 -0
- {cloudoll-2.2.7 → cloudoll-2.2.8}/cloudoll/orm/mysql.py +0 -0
- {cloudoll-2.2.7 → cloudoll-2.2.8}/cloudoll/orm/parse.py +0 -0
- {cloudoll-2.2.7 → cloudoll-2.2.8}/cloudoll/orm/postgres.py +0 -0
- {cloudoll-2.2.7 → cloudoll-2.2.8}/cloudoll/robot/__init__.py +0 -0
- {cloudoll-2.2.7 → cloudoll-2.2.8}/cloudoll/robot/dingtalk.py +0 -0
- {cloudoll-2.2.7 → cloudoll-2.2.8}/cloudoll/robot/feishu.py +0 -0
- {cloudoll-2.2.7 → cloudoll-2.2.8}/cloudoll/robot/slack.py +0 -0
- {cloudoll-2.2.7 → cloudoll-2.2.8}/cloudoll/utils/__init__.py +0 -0
- {cloudoll-2.2.7 → cloudoll-2.2.8}/cloudoll/utils/common.py +0 -0
- {cloudoll-2.2.7 → cloudoll-2.2.8}/cloudoll/utils/m2d.py +0 -0
- {cloudoll-2.2.7 → cloudoll-2.2.8}/cloudoll/utils/patch_loop.py +0 -0
- {cloudoll-2.2.7 → cloudoll-2.2.8}/cloudoll/web/exception.py +0 -0
- {cloudoll-2.2.7 → cloudoll-2.2.8}/cloudoll/web/html.py +0 -0
- {cloudoll-2.2.7 → cloudoll-2.2.8}/cloudoll/web/http.py +0 -0
- {cloudoll-2.2.7 → cloudoll-2.2.8}/cloudoll/web/jwt.py +0 -0
- {cloudoll-2.2.7 → cloudoll-2.2.8}/cloudoll/web/settings.py +0 -0
- {cloudoll-2.2.7 → cloudoll-2.2.8}/cloudoll.egg-info/SOURCES.txt +0 -0
- {cloudoll-2.2.7 → cloudoll-2.2.8}/cloudoll.egg-info/dependency_links.txt +0 -0
- {cloudoll-2.2.7 → cloudoll-2.2.8}/cloudoll.egg-info/entry_points.txt +0 -0
- {cloudoll-2.2.7 → cloudoll-2.2.8}/cloudoll.egg-info/requires.txt +0 -0
- {cloudoll-2.2.7 → cloudoll-2.2.8}/cloudoll.egg-info/top_level.txt +0 -0
- {cloudoll-2.2.7 → cloudoll-2.2.8}/setup.cfg +0 -0
- {cloudoll-2.2.7 → cloudoll-2.2.8}/setup.py +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "2.2.8"
|
|
@@ -21,10 +21,12 @@ class ModelMetaclass(type):
|
|
|
21
21
|
table_name = attrs.get("__table__", None) or name
|
|
22
22
|
primary_key = None
|
|
23
23
|
fields = []
|
|
24
|
+
# mappings = dict()
|
|
24
25
|
for k, v in attrs.items():
|
|
25
26
|
if isinstance(v, Field):
|
|
26
27
|
v.name = k
|
|
27
28
|
v.full_name = f"`{table_name}`.{k}"
|
|
29
|
+
# mappings[k] = v
|
|
28
30
|
if v.primary_key:
|
|
29
31
|
if primary_key:
|
|
30
32
|
warning(f"Duplicate primary key for {table_name}")
|
|
@@ -55,7 +57,6 @@ class ModelMetaclass(type):
|
|
|
55
57
|
attrs["__offset__"] = None
|
|
56
58
|
|
|
57
59
|
model = type.__new__(mcs, name, bases, attrs)
|
|
58
|
-
# sa.__MODELS__.append(model)
|
|
59
60
|
return model
|
|
60
61
|
|
|
61
62
|
def __repr__(self):
|
|
@@ -114,7 +115,9 @@ class Model(metaclass=ModelMetaclass):
|
|
|
114
115
|
if hasattr(self, name):
|
|
115
116
|
f = getattr(self, name)
|
|
116
117
|
if isinstance(f, Field):
|
|
117
|
-
|
|
118
|
+
s = copy.copy(f)
|
|
119
|
+
s.value = value
|
|
120
|
+
super().__setattr__(name, s)
|
|
118
121
|
else:
|
|
119
122
|
super().__setattr__(name, value)
|
|
120
123
|
else:
|
|
@@ -314,15 +317,23 @@ class Model(metaclass=ModelMetaclass):
|
|
|
314
317
|
|
|
315
318
|
sql = f"update `{table}` set {keys}"
|
|
316
319
|
|
|
317
|
-
pk, pkv = self._get_primary()
|
|
318
320
|
if where is not None:
|
|
319
321
|
sql += f' where {" and ".join(f for f in where)}'
|
|
320
322
|
params += self.__params__
|
|
321
|
-
elif pkv is not None:
|
|
322
|
-
sql += f" where `{pk}`=?"
|
|
323
|
-
params.append(pkv)
|
|
324
323
|
else:
|
|
325
|
-
|
|
324
|
+
pk, pkv = self._get_primary()
|
|
325
|
+
if pkv is None:
|
|
326
|
+
for arg in args:
|
|
327
|
+
if isinstance(arg, dict) and pk in arg:
|
|
328
|
+
pkv = arg[pk]
|
|
329
|
+
elif isinstance(arg, Model):
|
|
330
|
+
pkv = arg.get(pk)
|
|
331
|
+
|
|
332
|
+
if pkv is not None:
|
|
333
|
+
sql += f" where `{pk}`=?"
|
|
334
|
+
params.append(pkv)
|
|
335
|
+
else:
|
|
336
|
+
raise "Need where or primary key"
|
|
326
337
|
|
|
327
338
|
return await self.__pool__.update(sql, params)
|
|
328
339
|
|
|
@@ -51,6 +51,7 @@ __ALL__ = (
|
|
|
51
51
|
"put",
|
|
52
52
|
"delete",
|
|
53
53
|
"render_json",
|
|
54
|
+
"render_error",
|
|
54
55
|
"middleware",
|
|
55
56
|
"render_view",
|
|
56
57
|
"redirect",
|
|
@@ -64,29 +65,29 @@ class _Handler(object):
|
|
|
64
65
|
self.fn = fn
|
|
65
66
|
|
|
66
67
|
async def __call__(self, request):
|
|
67
|
-
|
|
68
|
+
content_type = request.content_type
|
|
68
69
|
# 获取函数参数的名称和默认值
|
|
69
70
|
props = inspect.getfullargspec(self.fn)
|
|
70
|
-
if len(props.args) == 2 and
|
|
71
|
+
if len(props.args) == 2 and content_type == "multipart/form-data":
|
|
71
72
|
await _set_session_route(request)
|
|
72
73
|
multipart = await request.multipart()
|
|
73
74
|
field = await multipart.next()
|
|
74
75
|
result = await self.fn(request, field)
|
|
75
76
|
elif len(props.args) == 1:
|
|
76
77
|
await _set_session_route(request)
|
|
77
|
-
if
|
|
78
|
+
if content_type == "multipart/form-data":
|
|
78
79
|
data = await request.post()
|
|
79
|
-
elif
|
|
80
|
+
elif content_type == "application/json":
|
|
80
81
|
data = await request.json()
|
|
81
82
|
else:
|
|
82
83
|
data = await request.post()
|
|
83
|
-
|
|
84
|
+
query_string = request.query_string
|
|
84
85
|
body = {}
|
|
85
86
|
for k in data:
|
|
86
87
|
body[k] = data[k]
|
|
87
88
|
qs = {}
|
|
88
|
-
if
|
|
89
|
-
for k, v in parse.parse_qs(
|
|
89
|
+
if query_string:
|
|
90
|
+
for k, v in parse.parse_qs(query_string, True).items():
|
|
90
91
|
qs[k] = v[0]
|
|
91
92
|
request.qs = Object(qs)
|
|
92
93
|
request.body = Object(body)
|
|
@@ -536,6 +537,10 @@ def all(path: str):
|
|
|
536
537
|
return app.route_table.view(path)
|
|
537
538
|
|
|
538
539
|
|
|
540
|
+
def render_error(msg, status=500) -> Response:
|
|
541
|
+
return render_json({"message": msg, "code": status}, status=status)
|
|
542
|
+
|
|
543
|
+
|
|
539
544
|
def render_json(data, **kw) -> Response:
|
|
540
545
|
res = {}
|
|
541
546
|
if isinstance(data, list):
|
|
@@ -547,6 +552,11 @@ def render_json(data, **kw) -> Response:
|
|
|
547
552
|
res.update(data)
|
|
548
553
|
else:
|
|
549
554
|
res["data"] = data
|
|
555
|
+
status = kw.get("status", 200)
|
|
556
|
+
if status == 200:
|
|
557
|
+
res["message"] = "OK"
|
|
558
|
+
res["code"] = 200
|
|
559
|
+
|
|
550
560
|
res["timestamp"] = int(datetime.now().timestamp() * 1000)
|
|
551
561
|
text = json.dumps(res, ensure_ascii=False, cls=JsonEncoder)
|
|
552
562
|
return web.json_response(text=text, **kw)
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "2.2.7"
|
|
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
|
|
File without changes
|
|
File without changes
|