Models are no longer 'types'
In jsonmodels, the metaclass for models was changed. Therefore, a model is no longer a type. Checks of the form type(x) == type fail, and are replaced with inspect.isclass(x). Change-Id: Ib8de32e47db8b44735c95b552835ce85b24e2b88 Closes-Bug: #1753244
This commit is contained in:
parent
a2f50a8e82
commit
491ff53f40
|
@ -10,6 +10,7 @@
|
|||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
import collections
|
||||
import inspect
|
||||
import itertools
|
||||
import threading
|
||||
|
||||
|
@ -215,7 +216,7 @@ class DbStore(object):
|
|||
index=Lport.get_index('topic'))
|
||||
(Lport(...), Lport(...), ...)
|
||||
"""
|
||||
if type(obj) == type:
|
||||
if inspect.isclass(obj):
|
||||
model = obj
|
||||
obj = model()
|
||||
else:
|
||||
|
@ -231,7 +232,7 @@ class DbStore(object):
|
|||
index=Lport.get_index('topic'))
|
||||
('id1', 'id2', 'id3', ...)
|
||||
'''
|
||||
if type(obj) == type:
|
||||
if inspect.isclass(obj):
|
||||
model = obj
|
||||
obj = model()
|
||||
else:
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
import collections
|
||||
import copy
|
||||
import functools
|
||||
import inspect
|
||||
|
||||
from jsonmodels import fields
|
||||
from jsonmodels import models
|
||||
|
@ -420,7 +421,7 @@ def get_model(arg):
|
|||
* By table name (old+new models)
|
||||
'''
|
||||
|
||||
if type(arg) == type:
|
||||
if inspect.isclass(arg):
|
||||
return arg
|
||||
|
||||
for lookup in (
|
||||
|
|
Loading…
Reference in New Issue