cloudoll 2.2.6__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.6 → cloudoll-2.2.8}/PKG-INFO +1 -1
- cloudoll-2.2.8/cloudoll/__init__.py +1 -0
- {cloudoll-2.2.6 → cloudoll-2.2.8}/cloudoll/orm/__init__.py +3 -2
- {cloudoll-2.2.6 → cloudoll-2.2.8}/cloudoll/orm/field.py +1 -1
- {cloudoll-2.2.6 → cloudoll-2.2.8}/cloudoll/orm/model.py +27 -11
- {cloudoll-2.2.6 → cloudoll-2.2.8}/cloudoll/utils/watch.py +0 -1
- {cloudoll-2.2.6 → cloudoll-2.2.8}/cloudoll/web/__init__.py +17 -7
- {cloudoll-2.2.6 → cloudoll-2.2.8}/cloudoll.egg-info/PKG-INFO +1 -1
- cloudoll-2.2.6/cloudoll/__init__.py +0 -1
- {cloudoll-2.2.6 → cloudoll-2.2.8}/LICENSE +0 -0
- {cloudoll-2.2.6 → cloudoll-2.2.8}/README.md +0 -0
- {cloudoll-2.2.6 → cloudoll-2.2.8}/cloudoll/__main__.py +0 -0
- {cloudoll-2.2.6 → cloudoll-2.2.8}/cloudoll/cli.py +0 -0
- {cloudoll-2.2.6 → cloudoll-2.2.8}/cloudoll/error/__init__.py +0 -0
- {cloudoll-2.2.6 → cloudoll-2.2.8}/cloudoll/error/errors.py +0 -0
- {cloudoll-2.2.6 → cloudoll-2.2.8}/cloudoll/logging/__init__.py +0 -0
- {cloudoll-2.2.6 → cloudoll-2.2.8}/cloudoll/mail/__init__.py +0 -0
- {cloudoll-2.2.6 → cloudoll-2.2.8}/cloudoll/mail/smtp.py +0 -0
- {cloudoll-2.2.6 → cloudoll-2.2.8}/cloudoll/orm/base.py +0 -0
- {cloudoll-2.2.6 → cloudoll-2.2.8}/cloudoll/orm/err.py +0 -0
- {cloudoll-2.2.6 → cloudoll-2.2.8}/cloudoll/orm/mysql.py +0 -0
- {cloudoll-2.2.6 → cloudoll-2.2.8}/cloudoll/orm/parse.py +0 -0
- {cloudoll-2.2.6 → cloudoll-2.2.8}/cloudoll/orm/postgres.py +0 -0
- {cloudoll-2.2.6 → cloudoll-2.2.8}/cloudoll/robot/__init__.py +0 -0
- {cloudoll-2.2.6 → cloudoll-2.2.8}/cloudoll/robot/dingtalk.py +0 -0
- {cloudoll-2.2.6 → cloudoll-2.2.8}/cloudoll/robot/feishu.py +0 -0
- {cloudoll-2.2.6 → cloudoll-2.2.8}/cloudoll/robot/slack.py +0 -0
- {cloudoll-2.2.6 → cloudoll-2.2.8}/cloudoll/utils/__init__.py +0 -0
- {cloudoll-2.2.6 → cloudoll-2.2.8}/cloudoll/utils/common.py +0 -0
- {cloudoll-2.2.6 → cloudoll-2.2.8}/cloudoll/utils/m2d.py +0 -0
- {cloudoll-2.2.6 → cloudoll-2.2.8}/cloudoll/utils/patch_loop.py +0 -0
- {cloudoll-2.2.6 → cloudoll-2.2.8}/cloudoll/web/exception.py +0 -0
- {cloudoll-2.2.6 → cloudoll-2.2.8}/cloudoll/web/html.py +0 -0
- {cloudoll-2.2.6 → cloudoll-2.2.8}/cloudoll/web/http.py +0 -0
- {cloudoll-2.2.6 → cloudoll-2.2.8}/cloudoll/web/jwt.py +0 -0
- {cloudoll-2.2.6 → cloudoll-2.2.8}/cloudoll/web/settings.py +0 -0
- {cloudoll-2.2.6 → cloudoll-2.2.8}/cloudoll.egg-info/SOURCES.txt +0 -0
- {cloudoll-2.2.6 → cloudoll-2.2.8}/cloudoll.egg-info/dependency_links.txt +0 -0
- {cloudoll-2.2.6 → cloudoll-2.2.8}/cloudoll.egg-info/entry_points.txt +0 -0
- {cloudoll-2.2.6 → cloudoll-2.2.8}/cloudoll.egg-info/requires.txt +0 -0
- {cloudoll-2.2.6 → cloudoll-2.2.8}/cloudoll.egg-info/top_level.txt +0 -0
- {cloudoll-2.2.6 → cloudoll-2.2.8}/setup.cfg +0 -0
- {cloudoll-2.2.6 → cloudoll-2.2.8}/setup.py +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "2.2.8"
|
|
@@ -88,7 +88,7 @@ class Postgres(MeteBase):
|
|
|
88
88
|
return cursor.rowcount > 0
|
|
89
89
|
|
|
90
90
|
self.pool.release(conn)
|
|
91
|
-
|
|
91
|
+
|
|
92
92
|
async def create_engine(self, **kw):
|
|
93
93
|
try:
|
|
94
94
|
host = (kw.get("host", "localhost"),)
|
|
@@ -172,8 +172,9 @@ class Mysql(MeteBase):
|
|
|
172
172
|
return cursor.rowcount > 0
|
|
173
173
|
elif query_type == QueryTypes.DELETE:
|
|
174
174
|
return cursor.rowcount > 0
|
|
175
|
-
|
|
175
|
+
|
|
176
176
|
self.pool.release(conn)
|
|
177
|
+
|
|
177
178
|
async def create_engine(self, loop=None, **kw):
|
|
178
179
|
try:
|
|
179
180
|
self.pool = await aiomysql.create_pool(
|
|
@@ -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):
|
|
@@ -67,6 +68,9 @@ class ModelMetaclass(type):
|
|
|
67
68
|
|
|
68
69
|
class Model(metaclass=ModelMetaclass):
|
|
69
70
|
def __init__(self, **kw):
|
|
71
|
+
for k in self.__fields__:
|
|
72
|
+
f = getattr(self, k, None)
|
|
73
|
+
f.value = None
|
|
70
74
|
for k, v in kw.items():
|
|
71
75
|
# print(f"{k}----{v}")
|
|
72
76
|
f = getattr(self, k, None)
|
|
@@ -77,7 +81,7 @@ class Model(metaclass=ModelMetaclass):
|
|
|
77
81
|
else:
|
|
78
82
|
setattr(self, k, v)
|
|
79
83
|
|
|
80
|
-
# super(
|
|
84
|
+
# super().__init__(self, **kw)
|
|
81
85
|
|
|
82
86
|
def __str__(self):
|
|
83
87
|
return "<Model: %s>" % self.__class__.__name__
|
|
@@ -111,7 +115,9 @@ class Model(metaclass=ModelMetaclass):
|
|
|
111
115
|
if hasattr(self, name):
|
|
112
116
|
f = getattr(self, name)
|
|
113
117
|
if isinstance(f, Field):
|
|
114
|
-
|
|
118
|
+
s = copy.copy(f)
|
|
119
|
+
s.value = value
|
|
120
|
+
super().__setattr__(name, s)
|
|
115
121
|
else:
|
|
116
122
|
super().__setattr__(name, value)
|
|
117
123
|
else:
|
|
@@ -143,7 +149,7 @@ class Model(metaclass=ModelMetaclass):
|
|
|
143
149
|
@classmethod
|
|
144
150
|
def use(cls, pool=None):
|
|
145
151
|
cls.__pool__ = pool
|
|
146
|
-
return cls()
|
|
152
|
+
return cls()
|
|
147
153
|
|
|
148
154
|
def select(cls, *args):
|
|
149
155
|
cols = []
|
|
@@ -215,14 +221,16 @@ class Model(metaclass=ModelMetaclass):
|
|
|
215
221
|
md = None
|
|
216
222
|
if args is None or not args:
|
|
217
223
|
for f in self.__fields__:
|
|
218
|
-
|
|
224
|
+
f = getattr(self, f)
|
|
225
|
+
x = f.value
|
|
226
|
+
data[f] = x
|
|
219
227
|
else:
|
|
220
228
|
for item in args:
|
|
221
229
|
md = item
|
|
222
230
|
if isinstance(item, Model):
|
|
223
231
|
for k in item.__dict__:
|
|
224
232
|
data[k] = item[k]
|
|
225
|
-
else:
|
|
233
|
+
else: # for object
|
|
226
234
|
for k, v in item.items():
|
|
227
235
|
data[k] = v
|
|
228
236
|
keys = []
|
|
@@ -309,15 +317,23 @@ class Model(metaclass=ModelMetaclass):
|
|
|
309
317
|
|
|
310
318
|
sql = f"update `{table}` set {keys}"
|
|
311
319
|
|
|
312
|
-
pk, pkv = self._get_primary()
|
|
313
320
|
if where is not None:
|
|
314
321
|
sql += f' where {" and ".join(f for f in where)}'
|
|
315
322
|
params += self.__params__
|
|
316
|
-
elif pkv is not None:
|
|
317
|
-
sql += f" where `{pk}`=?"
|
|
318
|
-
params.append(pkv)
|
|
319
323
|
else:
|
|
320
|
-
|
|
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"
|
|
321
337
|
|
|
322
338
|
return await self.__pool__.update(sql, params)
|
|
323
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.6"
|
|
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
|