cloudoll 2.3.0__tar.gz → 2.3.1__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.
Files changed (46) hide show
  1. {cloudoll-2.3.0 → cloudoll-2.3.1}/PKG-INFO +1 -1
  2. cloudoll-2.3.1/cloudoll/__init__.py +1 -0
  3. {cloudoll-2.3.0 → cloudoll-2.3.1}/cloudoll/orm/__init__.py +6 -78
  4. {cloudoll-2.3.0 → cloudoll-2.3.1}/cloudoll/orm/model.py +114 -113
  5. {cloudoll-2.3.0 → cloudoll-2.3.1}/cloudoll/web/__init__.py +2 -0
  6. {cloudoll-2.3.0 → cloudoll-2.3.1}/cloudoll.egg-info/PKG-INFO +1 -1
  7. cloudoll-2.3.0/cloudoll/__init__.py +0 -1
  8. {cloudoll-2.3.0 → cloudoll-2.3.1}/LICENSE +0 -0
  9. {cloudoll-2.3.0 → cloudoll-2.3.1}/README.md +0 -0
  10. {cloudoll-2.3.0 → cloudoll-2.3.1}/cloudoll/__main__.py +0 -0
  11. {cloudoll-2.3.0 → cloudoll-2.3.1}/cloudoll/cli.py +0 -0
  12. {cloudoll-2.3.0 → cloudoll-2.3.1}/cloudoll/error/__init__.py +0 -0
  13. {cloudoll-2.3.0 → cloudoll-2.3.1}/cloudoll/error/errors.py +0 -0
  14. {cloudoll-2.3.0 → cloudoll-2.3.1}/cloudoll/logging/__init__.py +0 -0
  15. {cloudoll-2.3.0 → cloudoll-2.3.1}/cloudoll/mail/__init__.py +0 -0
  16. {cloudoll-2.3.0 → cloudoll-2.3.1}/cloudoll/mail/smtp.py +0 -0
  17. {cloudoll-2.3.0 → cloudoll-2.3.1}/cloudoll/orm/base.py +0 -0
  18. {cloudoll-2.3.0 → cloudoll-2.3.1}/cloudoll/orm/err.py +0 -0
  19. {cloudoll-2.3.0 → cloudoll-2.3.1}/cloudoll/orm/field.py +0 -0
  20. {cloudoll-2.3.0 → cloudoll-2.3.1}/cloudoll/orm/mysql.py +0 -0
  21. {cloudoll-2.3.0 → cloudoll-2.3.1}/cloudoll/orm/parse.py +0 -0
  22. {cloudoll-2.3.0 → cloudoll-2.3.1}/cloudoll/orm/postgres.py +0 -0
  23. {cloudoll-2.3.0 → cloudoll-2.3.1}/cloudoll/robot/__init__.py +0 -0
  24. {cloudoll-2.3.0 → cloudoll-2.3.1}/cloudoll/robot/dingtalk.py +0 -0
  25. {cloudoll-2.3.0 → cloudoll-2.3.1}/cloudoll/robot/feishu.py +0 -0
  26. {cloudoll-2.3.0 → cloudoll-2.3.1}/cloudoll/robot/slack.py +0 -0
  27. {cloudoll-2.3.0 → cloudoll-2.3.1}/cloudoll/utils/__init__.py +0 -0
  28. {cloudoll-2.3.0 → cloudoll-2.3.1}/cloudoll/utils/cli_main.py +0 -0
  29. {cloudoll-2.3.0 → cloudoll-2.3.1}/cloudoll/utils/common.py +0 -0
  30. {cloudoll-2.3.0 → cloudoll-2.3.1}/cloudoll/utils/m2d.py +0 -0
  31. {cloudoll-2.3.0 → cloudoll-2.3.1}/cloudoll/utils/patch_loop.py +0 -0
  32. {cloudoll-2.3.0 → cloudoll-2.3.1}/cloudoll/utils/snowflake.py +0 -0
  33. {cloudoll-2.3.0 → cloudoll-2.3.1}/cloudoll/utils/watch.py +0 -0
  34. {cloudoll-2.3.0 → cloudoll-2.3.1}/cloudoll/web/core.py +0 -0
  35. {cloudoll-2.3.0 → cloudoll-2.3.1}/cloudoll/web/exception.py +0 -0
  36. {cloudoll-2.3.0 → cloudoll-2.3.1}/cloudoll/web/html.py +0 -0
  37. {cloudoll-2.3.0 → cloudoll-2.3.1}/cloudoll/web/http.py +0 -0
  38. {cloudoll-2.3.0 → cloudoll-2.3.1}/cloudoll/web/jwt.py +0 -0
  39. {cloudoll-2.3.0 → cloudoll-2.3.1}/cloudoll/web/settings.py +0 -0
  40. {cloudoll-2.3.0 → cloudoll-2.3.1}/cloudoll.egg-info/SOURCES.txt +0 -0
  41. {cloudoll-2.3.0 → cloudoll-2.3.1}/cloudoll.egg-info/dependency_links.txt +0 -0
  42. {cloudoll-2.3.0 → cloudoll-2.3.1}/cloudoll.egg-info/entry_points.txt +0 -0
  43. {cloudoll-2.3.0 → cloudoll-2.3.1}/cloudoll.egg-info/requires.txt +0 -0
  44. {cloudoll-2.3.0 → cloudoll-2.3.1}/cloudoll.egg-info/top_level.txt +0 -0
  45. {cloudoll-2.3.0 → cloudoll-2.3.1}/setup.cfg +0 -0
  46. {cloudoll-2.3.0 → cloudoll-2.3.1}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cloudoll
3
- Version: 2.3.0
3
+ Version: 2.3.1
4
4
  Summary: 辅助快速创建可分布的微服务。
5
5
  Home-page: https://gitee.com/chuchur/cloudoll-py
6
6
  Author: chuchur
@@ -0,0 +1 @@
1
+ __version__ = "2.3.1"
@@ -10,9 +10,6 @@ from aiomysql import Pool as MYPool
10
10
  import aiopg as pg
11
11
  from aiopg.pool import Pool as PGPool
12
12
 
13
- # import asyncpg as pg
14
- # from asyncpg.pool import Pool as PGPool
15
-
16
13
  __ALL__ = "create_engine"
17
14
 
18
15
 
@@ -55,65 +52,6 @@ class Postgres(MeteBase):
55
52
  def __call__(self, *args: Any, **kwds: Any) -> Any:
56
53
  self.__init__(*args, **kwds)
57
54
 
58
- # async def query(self, sql, params=None, query_type: QueryTypes = 2, size: int = 10):
59
- # sql = sql.replace("?", "%s").replace("`", "")
60
- # print_info("sql", sql, params)
61
- # if not self.pool:
62
- # raise ValueError("must be create_engine first.")
63
- # if self.pool._closing or self.pool._closed:
64
- # return None
65
-
66
- # # async with self.pool.acquire() as conn:
67
- # async with self.pool.acquire() as conn:
68
- # # current_cursor = getattr(cursor, 'lastrowid', None)
69
- # if (
70
- # query_type == QueryTypes.CREATEBATCH
71
- # or query_type == QueryTypes.UPDATEBATCH
72
- # ):
73
- # result = await conn.executemany(sql, params) # aiopg don't support executemany
74
- # else:
75
- # result = await conn.execute(sql, params)
76
-
77
- # # result = None
78
-
79
- # return result
80
-
81
- # if query_type == QueryTypes.ALL:
82
- # columns = [desc[0] for desc in cursor.description]
83
- # rows = await cursor.fetchall()
84
- # result = [dict(zip(columns, row)) for row in rows]
85
- # return result
86
- # elif query_type == QueryTypes.ONE:
87
- # columns = [desc[0] for desc in cursor.description]
88
- # row = await cursor.fetchone()
89
- # # print("rows_reuslt", rows)
90
- # result = dict(zip(columns, row)) if row else {}
91
- # return result
92
- # elif query_type == QueryTypes.MANY:
93
- # columns = [desc[0] for desc in cursor.description]
94
- # rows = await cursor.fetchmany(size)
95
- # result = [dict(zip(columns, row)) for row in rows]
96
- # return result
97
- # elif query_type == QueryTypes.COUNT:
98
- # rs = await cursor.fetchone()
99
- # return rs[0] if row else 0
100
- # elif query_type == QueryTypes.CREATE:
101
- # result = cursor.rowcount > 0
102
- # id = cursor.lastrowid
103
- # return result, id
104
- # elif query_type == QueryTypes.CREATEBATCH:
105
- # count = cursor.rowcount
106
- # id = cursor.lastrowid
107
- # return count, id
108
- # elif query_type == QueryTypes.UPDATE:
109
- # return cursor.rowcount > 0
110
- # elif query_type == QueryTypes.UPDATEBATCH:
111
- # return cursor.rowcount
112
- # elif query_type == QueryTypes.DELETE:
113
- # return cursor.rowcount > 0
114
-
115
- # self.pool.release(cursor)
116
-
117
55
  async def query(self, sql, params=None, query_type: QueryTypes = 2, size: int = 10):
118
56
  sql = sql.replace("?", "%s").replace("`", '"')
119
57
  if not self.pool:
@@ -132,7 +70,7 @@ class Postgres(MeteBase):
132
70
  or query_type == QueryTypes.UPDATEBATCH
133
71
  ):
134
72
  # aiopg don't support executemany
135
- await cursor.executemany(sql, params)
73
+ raise RuntimeError("postgres don't support executemany")
136
74
  else:
137
75
  await cursor.execute(sql, params)
138
76
 
@@ -155,8 +93,7 @@ class Postgres(MeteBase):
155
93
  result = [dict(zip(columns, row)) for row in rows]
156
94
  return result
157
95
  elif query_type == QueryTypes.COUNT:
158
- rs = await cursor.fetchone()
159
- return rs[0] if row else 0
96
+ return cursor.rowcount
160
97
  elif query_type == QueryTypes.CREATE:
161
98
  result = cursor.rowcount > 0
162
99
  id = cursor.lastrowid
@@ -182,13 +119,13 @@ class Postgres(MeteBase):
182
119
  password = (str(kw.get("password", "")),)
183
120
  db = (kw.get("db"),)
184
121
  dsn = f"dbname={db[0]} user={user[0]} password={password[0]} host={host[0]} port={port[0]}" # aiopg
185
- # dsn = f"postgres://{user[0]}:{password[0]}@{host[0]}:{port[0]}/{db[0]}" #asyncpg
122
+ # dsn = f"postgres://{user[0]}:{password[0]}@{host[0]}:{port[0]}/{db[0]}" # asyncpg
186
123
  self.pool = await pg.create_pool(
187
124
  dsn=dsn,
188
125
  timeout=kw.get("timeout"),
189
126
  echo=kw.get("echo", False), # aiopg
190
- # max_size=kw.get("maxsize", 10), #asyncpg
191
- # min_size=kw.get("minsize", 5), #asyncpg
127
+ # max_size=kw.get("maxsize", 10), # asyncpg
128
+ # min_size=kw.get("minsize", 5), # asyncpg
192
129
  maxsize=kw.get("maxsize", 10), # aiopg
193
130
  minsize=kw.get("minsize", 5), # aiopg
194
131
  )
@@ -246,11 +183,7 @@ class Mysql(MeteBase):
246
183
  else:
247
184
  await cursor.execute(sql, params)
248
185
 
249
- # if query_type.value > 4:
250
- # if self.driver == "mysql":
251
186
  await conn.commit()
252
- # elif self.driver == "postgres":
253
- # columns = [desc[0] for desc in cursor.description]
254
187
 
255
188
  if query_type == QueryTypes.ALL:
256
189
  return await cursor.fetchall()
@@ -259,11 +192,7 @@ class Mysql(MeteBase):
259
192
  elif query_type == QueryTypes.MANY:
260
193
  return await cursor.fetchmany(size)
261
194
  elif query_type == QueryTypes.COUNT:
262
- rs = await cursor.fetchone()
263
- value = 0
264
- for r in rs:
265
- value = rs[r]
266
- return value
195
+ return cursor.rowcount
267
196
  elif query_type == QueryTypes.CREATE:
268
197
  result = cursor.rowcount > 0
269
198
  id = cursor.lastrowid
@@ -299,7 +228,6 @@ class Mysql(MeteBase):
299
228
  )
300
229
  print_info(f"Database connection successfuly for mysql/{kw.get('db')}.")
301
230
  except Exception as e:
302
- # print(e)
303
231
  # print(traceback.format_exc())
304
232
  print_error(
305
233
  f"Database connection failed,the instance : mysql/{kw.get('db')}"
@@ -458,7 +458,8 @@ class Model(metaclass=ModelMetaclass):
458
458
  cls = copy.deepcopy(self)
459
459
  JOIN = cls._literal("LEFT JOIN", __join__)
460
460
  WHERE = cls._literal("WHERE", __where__)
461
- aft = " ".join([JOIN, WHERE])
461
+ GROUPBY = self._literal("GROUP BY", self.__group_by__)
462
+ aft = " ".join([JOIN, WHERE, GROUPBY])
462
463
  sql = f"SELECT COUNT(*) FROM {cls.__table__} {aft}"
463
464
  args = cls.__params__
464
465
  sql = self._exchange_sql(sql)
@@ -468,14 +469,14 @@ class Model(metaclass=ModelMetaclass):
468
469
  class Models(object):
469
470
  class CharField(Field):
470
471
  def __init__(
471
- self,
472
- name=None,
473
- primary_key=False,
474
- default=None,
475
- charset=None,
476
- max_length=None,
477
- not_null=False,
478
- comment=None,
472
+ self,
473
+ name=None,
474
+ primary_key=False,
475
+ default=None,
476
+ charset=None,
477
+ max_length=None,
478
+ not_null=False,
479
+ comment=None,
479
480
  ):
480
481
  super().__init__(
481
482
  name,
@@ -490,14 +491,14 @@ class Models(object):
490
491
 
491
492
  class VarCharField(Field):
492
493
  def __init__(
493
- self,
494
- name=None,
495
- primary_key=False,
496
- default=None,
497
- charset=None,
498
- max_length=None,
499
- not_null=False,
500
- comment=None,
494
+ self,
495
+ name=None,
496
+ primary_key=False,
497
+ default=None,
498
+ charset=None,
499
+ max_length=None,
500
+ not_null=False,
501
+ comment=None,
501
502
  ):
502
503
  super().__init__(
503
504
  name,
@@ -512,7 +513,7 @@ class Models(object):
512
513
 
513
514
  class BooleanField(Field):
514
515
  def __init__(
515
- self, name=None, default=False, not_null=False, comment=None, unsigned=False
516
+ self, name=None, default=False, not_null=False, comment=None, unsigned=False
516
517
  ):
517
518
  super().__init__(
518
519
  name,
@@ -525,15 +526,15 @@ class Models(object):
525
526
 
526
527
  class IntegerField(Field):
527
528
  def __init__(
528
- self,
529
- name=None,
530
- primary_key=False,
531
- default=None,
532
- auto_increment=False,
533
- not_null=False,
534
- unsigned=False,
535
- comment=None,
536
- max_length=None,
529
+ self,
530
+ name=None,
531
+ primary_key=False,
532
+ default=None,
533
+ auto_increment=False,
534
+ not_null=False,
535
+ unsigned=False,
536
+ comment=None,
537
+ max_length=None,
537
538
  ):
538
539
  super().__init__(
539
540
  name,
@@ -549,15 +550,15 @@ class Models(object):
549
550
 
550
551
  class BigIntegerField(Field):
551
552
  def __init__(
552
- self,
553
- name=None,
554
- primary_key=False,
555
- default=None,
556
- auto_increment=False,
557
- not_null=False,
558
- unsigned=False,
559
- comment=None,
560
- max_length=None,
553
+ self,
554
+ name=None,
555
+ primary_key=False,
556
+ default=None,
557
+ auto_increment=False,
558
+ not_null=False,
559
+ unsigned=False,
560
+ comment=None,
561
+ max_length=None,
561
562
  ):
562
563
  super().__init__(
563
564
  name,
@@ -573,13 +574,13 @@ class Models(object):
573
574
 
574
575
  class DoubleField(Field):
575
576
  def __init__(
576
- self,
577
- name=None,
578
- default=None,
579
- not_null=False,
580
- max_length=None,
581
- unsigned=False,
582
- comment=None,
577
+ self,
578
+ name=None,
579
+ default=None,
580
+ not_null=False,
581
+ max_length=None,
582
+ unsigned=False,
583
+ comment=None,
583
584
  ):
584
585
  super().__init__(
585
586
  name,
@@ -593,14 +594,14 @@ class Models(object):
593
594
 
594
595
  class FloatField(Field):
595
596
  def __init__(
596
- self,
597
- name=None,
598
- default=None,
599
- not_null=False,
600
- max_length=None,
601
- scale_length=None,
602
- unsigned=False,
603
- comment=None,
597
+ self,
598
+ name=None,
599
+ default=None,
600
+ not_null=False,
601
+ max_length=None,
602
+ scale_length=None,
603
+ unsigned=False,
604
+ comment=None,
604
605
  ):
605
606
  super().__init__(
606
607
  name,
@@ -615,14 +616,14 @@ class Models(object):
615
616
 
616
617
  class NumericField(Field):
617
618
  def __init__(
618
- self,
619
- name=None,
620
- default=0.0,
621
- not_null=False,
622
- max_length=None,
623
- scale_length=None,
624
- unsigned=False,
625
- comment=None,
619
+ self,
620
+ name=None,
621
+ default=0.0,
622
+ not_null=False,
623
+ max_length=None,
624
+ scale_length=None,
625
+ unsigned=False,
626
+ comment=None,
626
627
  ):
627
628
  super().__init__(
628
629
  name,
@@ -637,14 +638,14 @@ class Models(object):
637
638
 
638
639
  class DecimalField(Field):
639
640
  def __init__(
640
- self,
641
- name=None,
642
- default=0.0,
643
- not_null=False,
644
- max_length=None,
645
- scale_length=None,
646
- unsigned=False,
647
- comment=None,
641
+ self,
642
+ name=None,
643
+ default=0.0,
644
+ not_null=False,
645
+ max_length=None,
646
+ scale_length=None,
647
+ unsigned=False,
648
+ comment=None,
648
649
  ):
649
650
  super().__init__(
650
651
  name,
@@ -659,13 +660,13 @@ class Models(object):
659
660
 
660
661
  class TextField(Field):
661
662
  def __init__(
662
- self,
663
- name=None,
664
- default=None,
665
- charset=None,
666
- max_length=None,
667
- not_null=False,
668
- comment=None,
663
+ self,
664
+ name=None,
665
+ default=None,
666
+ charset=None,
667
+ max_length=None,
668
+ not_null=False,
669
+ comment=None,
669
670
  ):
670
671
  super().__init__(
671
672
  name,
@@ -679,13 +680,13 @@ class Models(object):
679
680
 
680
681
  class LongTextField(Field):
681
682
  def __init__(
682
- self,
683
- name=None,
684
- default=None,
685
- charset=None,
686
- max_length=None,
687
- not_null=False,
688
- comment=None,
683
+ self,
684
+ name=None,
685
+ default=None,
686
+ charset=None,
687
+ max_length=None,
688
+ not_null=False,
689
+ comment=None,
689
690
  ):
690
691
  super().__init__(
691
692
  name,
@@ -699,13 +700,13 @@ class Models(object):
699
700
 
700
701
  class MediumTextField(Field):
701
702
  def __init__(
702
- self,
703
- name=None,
704
- default=None,
705
- charset=None,
706
- max_length=None,
707
- not_null=False,
708
- comment=None,
703
+ self,
704
+ name=None,
705
+ default=None,
706
+ charset=None,
707
+ max_length=None,
708
+ not_null=False,
709
+ comment=None,
709
710
  ):
710
711
  super().__init__(
711
712
  name,
@@ -719,14 +720,14 @@ class Models(object):
719
720
 
720
721
  class DatetimeField(Field):
721
722
  def __init__(
722
- self,
723
- name=None,
724
- default=None,
725
- max_length=None,
726
- not_null=False,
727
- created_generated=False,
728
- update_generated=False,
729
- comment=None,
723
+ self,
724
+ name=None,
725
+ default=None,
726
+ max_length=None,
727
+ not_null=False,
728
+ created_generated=False,
729
+ update_generated=False,
730
+ comment=None,
730
731
  ):
731
732
  super().__init__(
732
733
  name,
@@ -741,14 +742,14 @@ class Models(object):
741
742
 
742
743
  class DateField(Field):
743
744
  def __init__(
744
- self,
745
- name=None,
746
- default=None,
747
- max_length=None,
748
- not_null=False,
749
- created_generated=False,
750
- update_generated=False,
751
- comment=None,
745
+ self,
746
+ name=None,
747
+ default=None,
748
+ max_length=None,
749
+ not_null=False,
750
+ created_generated=False,
751
+ update_generated=False,
752
+ comment=None,
752
753
  ):
753
754
  super().__init__(
754
755
  name,
@@ -763,14 +764,14 @@ class Models(object):
763
764
 
764
765
  class TimestampField(Field):
765
766
  def __init__(
766
- self,
767
- name=None,
768
- default=None,
769
- max_length=None,
770
- not_null=False,
771
- created_generated=False,
772
- update_generated=False,
773
- comment=None,
767
+ self,
768
+ name=None,
769
+ default=None,
770
+ max_length=None,
771
+ not_null=False,
772
+ created_generated=False,
773
+ update_generated=False,
774
+ comment=None,
774
775
  ):
775
776
  super().__init__(
776
777
  name,
@@ -786,7 +787,7 @@ class Models(object):
786
787
 
787
788
  class JsonField(Field):
788
789
  def __init__(
789
- self, name=None, default=None, charset=None, not_null=False, comment=None
790
+ self, name=None, default=None, charset=None, not_null=False, comment=None
790
791
  ):
791
792
  super().__init__(
792
793
  name,
@@ -23,6 +23,7 @@ from .core import (
23
23
  render_json,
24
24
  render_error,
25
25
  render_view,
26
+ render,
26
27
  middleware,
27
28
  redirect,
28
29
  )
@@ -44,6 +45,7 @@ __all__: Tuple[str, ...] = (
44
45
  "render_json",
45
46
  "render_error",
46
47
  "render_view",
48
+ "render",
47
49
  "middleware",
48
50
  "redirect",
49
51
  "jwt",
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cloudoll
3
- Version: 2.3.0
3
+ Version: 2.3.1
4
4
  Summary: 辅助快速创建可分布的微服务。
5
5
  Home-page: https://gitee.com/chuchur/cloudoll-py
6
6
  Author: chuchur
@@ -1 +0,0 @@
1
- __version__ = "2.3.0"
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