File tree Expand file tree Collapse file tree 1 file changed +13
-7
lines changed Expand file tree Collapse file tree 1 file changed +13
-7
lines changed Original file line number Diff line number Diff line change 33
44class AppMetaclass (ABCMeta ):
55
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+
619 @property
720 def ro_conn (self ):
821 """
@@ -20,10 +33,3 @@ def rw_conn(self):
2033 if not getattr (self , "get_rw_conn" , None ):
2134 raise NotImplementedError (f"Method `get_rw_conn()` was not implemented by { self .__class__ .__name__ } !" )
2235 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