cloudoll 2.2.15__tar.gz → 2.2.16__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.15 → cloudoll-2.2.16}/PKG-INFO +1 -1
- cloudoll-2.2.16/cloudoll/__init__.py +1 -0
- {cloudoll-2.2.15 → cloudoll-2.2.16}/cloudoll/cli.py +11 -9
- {cloudoll-2.2.15 → cloudoll-2.2.16}/cloudoll/orm/model.py +25 -23
- {cloudoll-2.2.15 → cloudoll-2.2.16}/cloudoll/utils/watch.py +1 -1
- {cloudoll-2.2.15 → cloudoll-2.2.16}/cloudoll/web/settings.py +1 -1
- {cloudoll-2.2.15 → cloudoll-2.2.16}/cloudoll.egg-info/PKG-INFO +1 -1
- {cloudoll-2.2.15 → cloudoll-2.2.16}/setup.py +1 -1
- cloudoll-2.2.15/cloudoll/__init__.py +0 -1
- {cloudoll-2.2.15 → cloudoll-2.2.16}/LICENSE +0 -0
- {cloudoll-2.2.15 → cloudoll-2.2.16}/README.md +0 -0
- {cloudoll-2.2.15 → cloudoll-2.2.16}/cloudoll/__main__.py +0 -0
- {cloudoll-2.2.15 → cloudoll-2.2.16}/cloudoll/error/__init__.py +0 -0
- {cloudoll-2.2.15 → cloudoll-2.2.16}/cloudoll/error/errors.py +0 -0
- {cloudoll-2.2.15 → cloudoll-2.2.16}/cloudoll/logging/__init__.py +0 -0
- {cloudoll-2.2.15 → cloudoll-2.2.16}/cloudoll/mail/__init__.py +0 -0
- {cloudoll-2.2.15 → cloudoll-2.2.16}/cloudoll/mail/smtp.py +0 -0
- {cloudoll-2.2.15 → cloudoll-2.2.16}/cloudoll/orm/__init__.py +0 -0
- {cloudoll-2.2.15 → cloudoll-2.2.16}/cloudoll/orm/base.py +0 -0
- {cloudoll-2.2.15 → cloudoll-2.2.16}/cloudoll/orm/err.py +0 -0
- {cloudoll-2.2.15 → cloudoll-2.2.16}/cloudoll/orm/field.py +0 -0
- {cloudoll-2.2.15 → cloudoll-2.2.16}/cloudoll/orm/mysql.py +0 -0
- {cloudoll-2.2.15 → cloudoll-2.2.16}/cloudoll/orm/parse.py +0 -0
- {cloudoll-2.2.15 → cloudoll-2.2.16}/cloudoll/orm/postgres.py +0 -0
- {cloudoll-2.2.15 → cloudoll-2.2.16}/cloudoll/robot/__init__.py +0 -0
- {cloudoll-2.2.15 → cloudoll-2.2.16}/cloudoll/robot/dingtalk.py +0 -0
- {cloudoll-2.2.15 → cloudoll-2.2.16}/cloudoll/robot/feishu.py +0 -0
- {cloudoll-2.2.15 → cloudoll-2.2.16}/cloudoll/robot/slack.py +0 -0
- {cloudoll-2.2.15 → cloudoll-2.2.16}/cloudoll/utils/__init__.py +0 -0
- {cloudoll-2.2.15 → cloudoll-2.2.16}/cloudoll/utils/common.py +0 -0
- {cloudoll-2.2.15 → cloudoll-2.2.16}/cloudoll/utils/m2d.py +0 -0
- {cloudoll-2.2.15 → cloudoll-2.2.16}/cloudoll/utils/patch_loop.py +0 -0
- {cloudoll-2.2.15 → cloudoll-2.2.16}/cloudoll/web/__init__.py +0 -0
- {cloudoll-2.2.15 → cloudoll-2.2.16}/cloudoll/web/exception.py +0 -0
- {cloudoll-2.2.15 → cloudoll-2.2.16}/cloudoll/web/html.py +0 -0
- {cloudoll-2.2.15 → cloudoll-2.2.16}/cloudoll/web/http.py +0 -0
- {cloudoll-2.2.15 → cloudoll-2.2.16}/cloudoll/web/jwt.py +0 -0
- {cloudoll-2.2.15 → cloudoll-2.2.16}/cloudoll.egg-info/SOURCES.txt +0 -0
- {cloudoll-2.2.15 → cloudoll-2.2.16}/cloudoll.egg-info/dependency_links.txt +0 -0
- {cloudoll-2.2.15 → cloudoll-2.2.16}/cloudoll.egg-info/entry_points.txt +0 -0
- {cloudoll-2.2.15 → cloudoll-2.2.16}/cloudoll.egg-info/requires.txt +0 -0
- {cloudoll-2.2.15 → cloudoll-2.2.16}/cloudoll.egg-info/top_level.txt +0 -0
- {cloudoll-2.2.15 → cloudoll-2.2.16}/setup.cfg +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "2.2.16"
|
|
@@ -27,11 +27,11 @@ life_cycle = ["on_startup", "on_shutdown", "on_cleanup", "cleanup_ctx"]
|
|
|
27
27
|
|
|
28
28
|
|
|
29
29
|
@cli.command()
|
|
30
|
-
@click.option("-p", "--path",help="Model's relative path,save models or create tables",default="models.py",)
|
|
30
|
+
@click.option("-p", "--path", help="Model's relative path,save models or create tables", default="models.py",)
|
|
31
31
|
@click.option("-c", "--create", help="For create model or table, model / table", default="model")
|
|
32
|
-
@click.option("-t", "--table",help="Table's name or Model's name, split by `,` or 'ALL'",required=True,)
|
|
32
|
+
@click.option("-t", "--table", help="Table's name or Model's name, split by `,` or 'ALL'", required=True,)
|
|
33
33
|
@click.option("-env", "--environment", help="Environment, local / test / prod", default="local")
|
|
34
|
-
@click.option("-db", "--database",help="Database name, pick the database in conf.{env}.yaml",default="mysql",)
|
|
34
|
+
@click.option("-db", "--database", help="Database name, pick the database in conf.{env}.yaml", default="mysql",)
|
|
35
35
|
def gen(path, create, table, environment, database) -> None:
|
|
36
36
|
"""Help to create models or tables."""
|
|
37
37
|
|
|
@@ -76,15 +76,15 @@ def gen(path, create, table, environment, database) -> None:
|
|
|
76
76
|
|
|
77
77
|
@cli.command()
|
|
78
78
|
@click.option("-env", "--environment", help="Environment, local / test / prod", default="local")
|
|
79
|
-
@click.option("-p", "--port", help="Server's port", default=
|
|
80
|
-
@click.option("-h", "--host", help="Server's host", default=
|
|
79
|
+
@click.option("-p", "--port", help="Server's port", default=None)
|
|
80
|
+
@click.option("-h", "--host", help="Server's host", default=None)
|
|
81
81
|
@click.option("-m", "--mode", help="development or production mode", default='development')
|
|
82
|
-
@click.option("-path", "--path",help="Unix file system path to serve on. Specifying a path will cause hostname and port arguments to be ignored.",)
|
|
82
|
+
@click.option("-path", "--path", help="Unix file system path to serve on. Specifying a path will cause hostname and port arguments to be ignored.",)
|
|
83
83
|
@click.option("-e", "--entry", help="Entry point model name. delfault name app", default="app")
|
|
84
84
|
def start(environment, host, port, mode, path, entry) -> None:
|
|
85
85
|
"""Start a services."""
|
|
86
86
|
try:
|
|
87
|
-
print_info("Current mode: "
|
|
87
|
+
print_info("Current mode: ", mode)
|
|
88
88
|
config = get_config(environment)
|
|
89
89
|
# print(environment, host, port, mode, path, entry)
|
|
90
90
|
# return
|
|
@@ -95,8 +95,10 @@ def start(environment, host, port, mode, path, entry) -> None:
|
|
|
95
95
|
aux_app = web.Application(
|
|
96
96
|
logger=None,
|
|
97
97
|
)
|
|
98
|
-
|
|
99
|
-
|
|
98
|
+
defaults = {"host": "0.0.0.0", "port": 9001, "path": None}
|
|
99
|
+
conf_server = config.get("server", {})
|
|
100
|
+
env_server = {"host": host, "port": port, "path": path}
|
|
101
|
+
server = chainMap(defaults, conf_server, env_server)
|
|
100
102
|
config["server"] = server
|
|
101
103
|
|
|
102
104
|
aux_port = int(server.port) + 1
|
|
@@ -2,7 +2,8 @@ from .field import Field, Function, Expression
|
|
|
2
2
|
from ..logging import print_warn
|
|
3
3
|
from functools import reduce
|
|
4
4
|
import operator
|
|
5
|
-
import copy
|
|
5
|
+
import copy
|
|
6
|
+
import datetime
|
|
6
7
|
|
|
7
8
|
|
|
8
9
|
class ModelMetaclass(type):
|
|
@@ -31,8 +32,8 @@ class ModelMetaclass(type):
|
|
|
31
32
|
if primary_key:
|
|
32
33
|
print_warn(f"Duplicate primary key for {table_name}")
|
|
33
34
|
primary_key = k
|
|
34
|
-
else:
|
|
35
|
-
|
|
35
|
+
# else:
|
|
36
|
+
fields.append(k)
|
|
36
37
|
|
|
37
38
|
if not primary_key:
|
|
38
39
|
print_warn(f"{table_name} Missing primary key")
|
|
@@ -217,6 +218,8 @@ class Model(metaclass=ModelMetaclass):
|
|
|
217
218
|
f = getattr(self, k)
|
|
218
219
|
x = f.value
|
|
219
220
|
data[k] = x
|
|
221
|
+
elif args and isinstance(args, dict):
|
|
222
|
+
data = args
|
|
220
223
|
else:
|
|
221
224
|
for item in args:
|
|
222
225
|
md = item
|
|
@@ -299,19 +302,19 @@ class Model(metaclass=ModelMetaclass):
|
|
|
299
302
|
self._reset()
|
|
300
303
|
return await self.__pool__.all(sql, args)
|
|
301
304
|
|
|
302
|
-
async def update(self, *args) -> bool:
|
|
305
|
+
async def update(self, *args, **kw) -> bool:
|
|
303
306
|
"""
|
|
304
307
|
Update data
|
|
305
308
|
"""
|
|
306
309
|
table = self.__table__
|
|
307
|
-
where = self.__where__
|
|
310
|
+
# where = self.__where__
|
|
311
|
+
where = self._literal("WHERE", self.__where__)
|
|
308
312
|
|
|
309
|
-
keys, params, md = self._get_key_args(args)
|
|
313
|
+
keys, params, md = self._get_key_args(args or kw)
|
|
310
314
|
|
|
311
|
-
sql = f"update `{table}` set {keys}"
|
|
315
|
+
sql = f"update `{table}` set {keys} {where}"
|
|
312
316
|
|
|
313
|
-
if where is not None:
|
|
314
|
-
sql += f' where {" and ".join(f for f in where)}'
|
|
317
|
+
if where is not None and where != '':
|
|
315
318
|
params += self.__params__
|
|
316
319
|
else:
|
|
317
320
|
pk, pkv = self._get_primary()
|
|
@@ -327,7 +330,7 @@ class Model(metaclass=ModelMetaclass):
|
|
|
327
330
|
params.append(pkv)
|
|
328
331
|
else:
|
|
329
332
|
raise "Need where or primary key"
|
|
330
|
-
|
|
333
|
+
self._reset()
|
|
331
334
|
return await self.__pool__.update(sql, params)
|
|
332
335
|
|
|
333
336
|
async def delete(self) -> bool:
|
|
@@ -335,24 +338,23 @@ class Model(metaclass=ModelMetaclass):
|
|
|
335
338
|
Delete data
|
|
336
339
|
"""
|
|
337
340
|
table = self.__table__
|
|
338
|
-
where = self.__where__
|
|
341
|
+
where = self._literal("WHERE", self.__where__)
|
|
339
342
|
args = self.__params__
|
|
340
|
-
sql = f"delete from `{table}`"
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
raise "need where or primary"
|
|
343
|
+
sql = f"delete from `{table}` {where}"
|
|
344
|
+
|
|
345
|
+
if where is None or where == '':
|
|
346
|
+
pk, pkv = self._get_primary()
|
|
347
|
+
if pkv is not None:
|
|
348
|
+
sql += f" where `{pk}`=?"
|
|
349
|
+
args = [pkv]
|
|
350
|
+
else:
|
|
351
|
+
raise "need where or primary key"
|
|
350
352
|
self._reset()
|
|
351
353
|
return await self.__pool__.delete(sql, args)
|
|
352
354
|
|
|
353
|
-
async def insert(self, *args):
|
|
355
|
+
async def insert(self, *args, **kw):
|
|
354
356
|
table = self.__table__
|
|
355
|
-
keys, params, md = self._get_key_args(args)
|
|
357
|
+
keys, params, md = self._get_key_args(args or kw)
|
|
356
358
|
sql = f"insert into `{table}` set {keys}"
|
|
357
359
|
self._reset()
|
|
358
360
|
return await self.__pool__.create(sql, params)
|
|
@@ -34,7 +34,7 @@ class WatchTask:
|
|
|
34
34
|
async def start(self, app: Application) -> None:
|
|
35
35
|
self._app = app
|
|
36
36
|
self.stopper = asyncio.Event()
|
|
37
|
-
ignore_dirs = self._config["server"]
|
|
37
|
+
ignore_dirs = self._config["server"].get("ignore_dirs", [])
|
|
38
38
|
self._awatch = awatch(
|
|
39
39
|
self._path,
|
|
40
40
|
stop_event=self.stopper,
|
|
@@ -11,6 +11,6 @@ def get_config(env):
|
|
|
11
11
|
if not os.path.exists(conf_path):
|
|
12
12
|
print_error(f"Configuration file does not exist: {conf_path}")
|
|
13
13
|
return {}
|
|
14
|
-
with open(conf_path) as f:
|
|
14
|
+
with open(conf_path,'r',encoding='utf-8') as f:
|
|
15
15
|
config = yaml.safe_load(f)
|
|
16
16
|
return config or {}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "2.2.15"
|
|
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
|