annotate backend/arangodb/FeedEntry.py @ 258:4ca1fac32dde

Pull the constant of days to keep feed entries into the abstract class
author Dirk Olmes <dirk@xanthippe.ping.de>
date Tue, 12 Mar 2019 02:39:18 +0100
parents f79be01821c4
children 304917762618
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
256
f79be01821c4 Arangodb backend, first version which barely works for reading
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
f79be01821c4 Arangodb backend, first version which barely works for reading
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
2 from datetime import datetime
f79be01821c4 Arangodb backend, first version which barely works for reading
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
3
f79be01821c4 Arangodb backend, first version which barely works for reading
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
4 class FeedEntry(object):
f79be01821c4 Arangodb backend, first version which barely works for reading
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
5 def __init__(self, document):
f79be01821c4 Arangodb backend, first version which barely works for reading
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
6 super(FeedEntry, self).__init__()
f79be01821c4 Arangodb backend, first version which barely works for reading
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
7 self.document = document
f79be01821c4 Arangodb backend, first version which barely works for reading
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
8
f79be01821c4 Arangodb backend, first version which barely works for reading
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
9 def __getattr__(self, attribute):
f79be01821c4 Arangodb backend, first version which barely works for reading
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
10 if attribute == 'updated':
f79be01821c4 Arangodb backend, first version which barely works for reading
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
11 return self._parse_updated()
f79be01821c4 Arangodb backend, first version which barely works for reading
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
12 return self.document[attribute]
f79be01821c4 Arangodb backend, first version which barely works for reading
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
13
f79be01821c4 Arangodb backend, first version which barely works for reading
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
14 def _parse_updated(self):
f79be01821c4 Arangodb backend, first version which barely works for reading
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
15 value = self.document['updated']
f79be01821c4 Arangodb backend, first version which barely works for reading
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
16 return datetime(*value)
f79be01821c4 Arangodb backend, first version which barely works for reading
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
17
f79be01821c4 Arangodb backend, first version which barely works for reading
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
18 def markRead(self):
f79be01821c4 Arangodb backend, first version which barely works for reading
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
19 self.document['read'] = True
f79be01821c4 Arangodb backend, first version which barely works for reading
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
20 self.document.patch()