File tree 1 file changed +13
-7
lines changed
1 file changed +13
-7
lines changed Original file line number Diff line number Diff line change 3
3
4
4
class AppMetaclass (ABCMeta ):
5
5
6
+ def __new__ (cls , name , bases , attrs ):
7
+ if name != "BaseManager" :
8
+ model = attrs .get ("model" )
9
+ if not model :
10
+ raise NotImplementedError (f"Class attribute `model` was not defined by { name } !" )
11
+
12
+ table = getattr (model .Meta , "table" , None )
13
+ if not table :
14
+ raise NotImplementedError (f"Meta attribute `table` was not defined by model { model .__name__ } !" )
15
+
16
+ attrs ["table" ] = model .Meta .table
17
+ return super ().__new__ (cls , name , bases , attrs )
18
+
6
19
@property
7
20
def ro_conn (self ):
8
21
"""
@@ -20,10 +33,3 @@ def rw_conn(self):
20
33
if not getattr (self , "get_rw_conn" , None ):
21
34
raise NotImplementedError (f"Method `get_rw_conn()` was not implemented by { self .__class__ .__name__ } !" )
22
35
return self .get_rw_conn ()
23
-
24
- @property
25
- def table (self ):
26
- db_table = self .model ._meta .db_table
27
- if not db_table :
28
- raise NotImplementedError (f"Class attribute `model` was not defined by { self .__name__ } !" )
29
- return db_table
You can’t perform that action at this time.
0 commit comments