Exemple #1
0
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
Exemple #2
0
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
Exemple #3
0
def markdown_filter(environ, text, img=False):
    return markdown(text, img)
Exemple #4
0
def markdown_filter(environ, text, img=False):
    return markdown(text, img)