API can now properly show ranges

This commit is contained in:
Krateng 2019-05-08 17:42:56 +02:00
parent 5c076dfe25
commit 341af94fa9
3 changed files with 18 additions and 0 deletions

View File

@ -78,6 +78,15 @@ class MRangeDescriptor:
"description":self.desc()
}
def __json__(self):
return {
"fromstring":self.fromstr(),
"tostr":self.tostr(),
"fromstamp":self.first_stamp(),
"tostamp":self.last_stamp(),
"description":self.desc()
}
def uri(self):
return "&".join(k + "=" + self.urikeys[k] for k in self.urikeys)

7
monkey.py Normal file
View File

@ -0,0 +1,7 @@
from simplejson import JSONEncoder
def newdefault(self,object):
return getattr(object.__class__,"__json__", olddefault)(object)
olddefault = JSONEncoder.default
JSONEncoder.default = newdefault

View File

@ -3,6 +3,8 @@
# server stuff
from bottle import Bottle, route, get, post, error, run, template, static_file, request, response, FormsDict, redirect, template
import waitress
# monkey patching
import monkey
# rest of the project
import database
from utilities import *