view backend/arangodb/FeedEntry.py @ 257:75b81da8d7a5

convert the feed entry timestamps to arango compatible date strings in migration
author Dirk Olmes <dirk@xanthippe.ping.de>
date Tue, 12 Mar 2019 02:38:41 +0100
parents f79be01821c4
children 304917762618
line wrap: on
line source

# -*- coding: utf-8 -*-
from datetime import datetime

class FeedEntry(object):
    def __init__(self, document):
        super(FeedEntry, self).__init__()
        self.document = document

    def __getattr__(self, attribute):
        if attribute == 'updated':
            return self._parse_updated()
        return self.document[attribute]

    def _parse_updated(self):
        value = self.document['updated']
        return datetime(*value)

    def markRead(self):
        self.document['read'] = True
        self.document.patch()