def json_serializer(obj): if isinstance(obj, datetime): if obj.utcoffset() is not None: obj = obj - obj.utcoffset() millis = int( calendar.timegm(obj.timetuple()) * 1000 + obj.microsecond / 1000) return millis if isinstance(obj, GewebError): return dict((name, getattr(obj, name)) for name in dir(obj) \ if not name.startswith('__') and name != 'args') try: obj = obj.todict() if 'text' in obj: obj['text'] = markdown(obj['text']) return obj except AttributeError: return obj
def json_serializer(obj): if isinstance(obj, datetime): if obj.utcoffset() is not None: obj = obj - obj.utcoffset() millis = int( calendar.timegm(obj.timetuple()) * 1000 + obj.microsecond / 1000 ) return millis if isinstance(obj, GewebError): return dict((name, getattr(obj, name)) for name in dir(obj) \ if not name.startswith('__') and name != 'args') try: obj = obj.todict() if 'text' in obj: obj['text'] = markdown(obj['text']) return obj except AttributeError: return obj
def markdown_filter(environ, text, img=False): return markdown(text, img)