mirror of
https://github.com/PiBrewing/craftbeerpi4.git
synced 2024-11-10 01:17:42 +01:00
22 lines
600 B
Python
22 lines
600 B
Python
from json import JSONEncoder
|
|
|
|
class ComplexEncoder(JSONEncoder):
|
|
|
|
def default(self, obj):
|
|
|
|
from cbpi.database.orm_framework import DBModel
|
|
|
|
try:
|
|
if isinstance(obj, DBModel):
|
|
return obj.__dict__
|
|
#elif callable(getattr(obj, "reprJSON")):
|
|
# return obj.reprJSON()
|
|
#elif isinstance(obj, ActorModel):
|
|
# return None
|
|
#elif hasattr(obj, "callback"):
|
|
# return obj()
|
|
else:
|
|
raise TypeError()
|
|
except TypeError:
|
|
pass
|
|
return None
|