1.1 --- a/imiptools/client.py Tue May 23 22:15:05 2017 +0200
1.2 +++ b/imiptools/client.py Wed May 24 15:41:14 2017 +0200
1.3 @@ -246,10 +246,9 @@
1.4 """
1.5
1.6 if section == "counters":
1.7 - fragment = self.store.get_counter(self.user, username, uid, recurrenceid)
1.8 + return self.store.get_counter(self.user, username, uid, recurrenceid)
1.9 else:
1.10 - fragment = self.store.get_event(self.user, uid, recurrenceid, section)
1.11 - return fragment and Object(fragment)
1.12 + return self.store.get_event(self.user, uid, recurrenceid, section)
1.13
1.14 # Free/busy operations.
1.15
2.1 --- a/imiptools/handlers/scheduling/quota.py Tue May 23 22:15:05 2017 +0200
2.2 +++ b/imiptools/handlers/scheduling/quota.py Wed May 24 15:41:14 2017 +0200
2.3 @@ -3,7 +3,7 @@
2.4 """
2.5 Quota-related scheduling functionality.
2.6
2.7 -Copyright (C) 2016 Paul Boddie <paul@boddie.org.uk>
2.8 +Copyright (C) 2016, 2017 Paul Boddie <paul@boddie.org.uk>
2.9
2.10 This program is free software; you can redistribute it and/or modify it under
2.11 the terms of the GNU General Public License as published by the Free Software
2.12 @@ -20,7 +20,7 @@
2.13 """
2.14
2.15 from imiptools.dates import get_duration, to_utc_datetime
2.16 -from imiptools.data import get_uri, uri_dict, Object
2.17 +from imiptools.data import get_uri, uri_dict
2.18 from imiptools.handlers.scheduling.common import get_scheduling_conflicts, \
2.19 standard_responses
2.20 from imiptools.period import Endless
2.21 @@ -103,8 +103,7 @@
2.22 # Where an existing version of the object exists, merge the recipient's
2.23 # attendance information.
2.24
2.25 - fragment = journal.get_event(quota, handler.uid, handler.recurrenceid)
2.26 - obj = fragment and Object(fragment)
2.27 + obj = journal.get_event(quota, handler.uid, handler.recurrenceid)
2.28 if not obj:
2.29 obj = handler.obj
2.30
2.31 @@ -128,8 +127,7 @@
2.32 # Where an existing version of the object exists, remove the recipient's
2.33 # attendance information.
2.34
2.35 - fragment = journal.get_event(quota, handler.uid, handler.recurrenceid)
2.36 - obj = fragment and Object(fragment)
2.37 + obj = journal.get_event(quota, handler.uid, handler.recurrenceid)
2.38 if not obj:
2.39 return
2.40
3.1 --- a/imiptools/stores/database/common.py Tue May 23 22:15:05 2017 +0200
3.2 +++ b/imiptools/stores/database/common.py Wed May 24 15:41:14 2017 +0200
3.3 @@ -22,7 +22,7 @@
3.4 from imiptools.stores.common import StoreBase, JournalBase
3.5
3.6 from datetime import datetime
3.7 -from imiptools.data import parse_string, to_string
3.8 +from imiptools.data import Object, parse_string, to_string
3.9 from imiptools.dates import format_datetime, get_datetime, to_timezone
3.10 from imiptools.freebusy import FreeBusyDatabaseCollection, \
3.11 FreeBusyGroupDatabaseCollection, \
3.12 @@ -31,6 +31,8 @@
3.13
3.14 def first(l): return l[0]
3.15
3.16 +# Store classes.
3.17 +
3.18 class DatabaseStoreBase(DatabaseOperations):
3.19
3.20 "A database store supporting user-specific locking."
3.21 @@ -164,7 +166,7 @@
3.22
3.23 self.cursor.execute(query, values)
3.24 result = self.cursor.fetchone()
3.25 - return result and parse_string(result[0], "utf-8")
3.26 + return result and Object(parse_string(result[0], "utf-8"))
3.27
3.28 def get_complete_event(self, user, uid):
3.29
3.30 @@ -179,7 +181,7 @@
3.31
3.32 self.cursor.execute(query, values)
3.33 result = self.cursor.fetchone()
3.34 - return result and parse_string(result[0], "utf-8")
3.35 + return result and Object(parse_string(result[0], "utf-8"))
3.36
3.37 def set_complete_event(self, user, uid, node):
3.38
3.39 @@ -273,7 +275,7 @@
3.40
3.41 self.cursor.execute(query, values)
3.42 result = self.cursor.fetchone()
3.43 - return result and parse_string(result[0], "utf-8")
3.44 + return result and Object(parse_string(result[0], "utf-8"))
3.45
3.46 def set_recurrence(self, user, uid, recurrenceid, node):
3.47
3.48 @@ -678,7 +680,7 @@
3.49
3.50 self.cursor.execute(query, values)
3.51 result = self.cursor.fetchone()
3.52 - return result and parse_string(result[0], "utf-8")
3.53 + return result and Object(parse_string(result[0], "utf-8"))
3.54
3.55 def set_counter(self, user, other, node, uid, recurrenceid=None):
3.56
4.1 --- a/imiptools/stores/file.py Tue May 23 22:15:05 2017 +0200
4.2 +++ b/imiptools/stores/file.py Wed May 24 15:41:14 2017 +0200
4.3 @@ -23,7 +23,7 @@
4.4
4.5 from datetime import datetime
4.6 from imiptools.config import settings
4.7 -from imiptools.data import make_calendar, parse_object, to_stream
4.8 +from imiptools.data import Object, make_calendar, parse_object, to_stream
4.9 from imiptools.dates import format_datetime, get_datetime, to_timezone
4.10 from imiptools.filesys import fix_permissions, FileBase
4.11 from imiptools.freebusy import FreeBusyPeriod, FreeBusyGroupPeriod, \
4.12 @@ -40,6 +40,8 @@
4.13 PUBLISH_DIR = settings["PUBLISH_DIR"]
4.14 JOURNAL_DIR = settings["JOURNAL_DIR"]
4.15
4.16 +# Store classes.
4.17 +
4.18 class FileStoreBase(FileBase):
4.19
4.20 "A file store supporting user-specific locking and tabular data."
4.21 @@ -168,7 +170,7 @@
4.22 try:
4.23 f = open(filename, "rb")
4.24 try:
4.25 - return parse_object(f, "utf-8")
4.26 + return Object(parse_object(f, "utf-8"))
4.27 finally:
4.28 f.close()
4.29 finally:
5.1 --- a/tests/list_table.py Tue May 23 22:15:05 2017 +0200
5.2 +++ b/tests/list_table.py Wed May 24 15:41:14 2017 +0200
5.3 @@ -3,7 +3,7 @@
5.4 """
5.5 Show the contents of a table.
5.6
5.7 -Copyright (C) 2016 Paul Boddie <paul@boddie.org.uk>
5.8 +Copyright (C) 2016, 2017 Paul Boddie <paul@boddie.org.uk>
5.9
5.10 This program is free software; you can redistribute it and/or modify it under
5.11 the terms of the GNU General Public License as published by the Free Software
5.12 @@ -28,9 +28,9 @@
5.13 for row in data:
5.14 print row or ""
5.15
5.16 -def show_object(data):
5.17 - if data:
5.18 - print Object(data).to_string(line_length=1000)
5.19 +def show_object(obj):
5.20 + if obj:
5.21 + print obj.to_string(line_length=1000)
5.22
5.23 def show_periods(data):
5.24 if data:
5.25 @@ -95,24 +95,24 @@
5.26 elif table == "countered_object":
5.27 uid = args[0]
5.28 other = args[1]
5.29 - data = store.get_counter(user, other, uid)
5.30 - show_object(data)
5.31 + obj = store.get_counter(user, other, uid)
5.32 + show_object(obj)
5.33
5.34 elif table == "object":
5.35 uid = args[0]
5.36 - data = store.get_event(user, uid)
5.37 - show_object(data)
5.38 + obj = store.get_event(user, uid)
5.39 + show_object(obj)
5.40
5.41 elif table == "journal_object":
5.42 uid = args[0]
5.43 - data = journal.get_event(user, uid)
5.44 - show_object(data)
5.45 + obj = journal.get_event(user, uid)
5.46 + show_object(obj)
5.47
5.48 elif table == "recurrence":
5.49 uid = args[0]
5.50 recurrenceid = args[1]
5.51 - data = store.get_event(user, uid, recurrenceid)
5.52 - show_object(data)
5.53 + obj = store.get_event(user, uid, recurrenceid)
5.54 + show_object(obj)
5.55
5.56 elif table == "cancelled_recurrences":
5.57 uid = args[0]
6.1 --- a/tests/test_handle.py Tue May 23 22:15:05 2017 +0200
6.2 +++ b/tests/test_handle.py Wed May 24 15:41:14 2017 +0200
6.3 @@ -3,7 +3,7 @@
6.4 """
6.5 A handler to help with testing.
6.6
6.7 -Copyright (C) 2014, 2015, 2016 Paul Boddie <paul@boddie.org.uk>
6.8 +Copyright (C) 2014, 2015, 2016, 2017 Paul Boddie <paul@boddie.org.uk>
6.9
6.10 This program is free software; you can redistribute it and/or modify it under
6.11 the terms of the GNU General Public License as published by the Free Software
6.12 @@ -151,20 +151,19 @@
6.13 journal = get_journal(store_type, journal_dir)
6.14
6.15 if uid is not None:
6.16 - fragment = store.get_event(user, uid, recurrenceid)
6.17 + obj = store.get_event(user, uid, recurrenceid)
6.18
6.19 # Permit new recurrences by getting the parent object.
6.20
6.21 - if not fragment:
6.22 - fragment = store.get_event(user, uid)
6.23 + if not obj:
6.24 + obj = store.get_event(user, uid)
6.25
6.26 - if not fragment:
6.27 + if not obj:
6.28 print >>sys.stderr, "No such event:", uid, recurrenceid
6.29 sys.exit(1)
6.30 else:
6.31 - fragment = parse_object(sys.stdin, "utf-8")
6.32 + obj = Object(parse_object(sys.stdin, "utf-8"))
6.33
6.34 - obj = Object(fragment)
6.35 handler = TestClient(obj, user, Messenger(), store, None, journal, preferences_dir)
6.36 response = handler.handle_request(action, start, end, recurrenceid)
6.37
7.1 --- a/tools/copy_store.py Tue May 23 22:15:05 2017 +0200
7.2 +++ b/tools/copy_store.py Wed May 24 15:41:14 2017 +0200
7.3 @@ -59,9 +59,9 @@
7.4 # Get event, recurrence information.
7.5
7.6 for uid, recurrenceid in from_store.get_all_events(user, dirname=dirname):
7.7 - d = from_store.get_event(user, uid, recurrenceid, dirname=dirname)
7.8 - if d:
7.9 - to_store.set_event(user, uid, recurrenceid, Object(d).to_node())
7.10 + obj = from_store.get_event(user, uid, recurrenceid, dirname=dirname)
7.11 + if obj:
7.12 + to_store.set_event(user, uid, recurrenceid, obj.to_node())
7.13 if dirname == "cancellations":
7.14 to_store.cancel_event(user, uid, recurrenceid)
7.15 else:
7.16 @@ -72,9 +72,9 @@
7.17
7.18 if dirname is None:
7.19 for other in from_store.get_counters(user, uid, recurrenceid):
7.20 - d = from_store.get_counter(user, other, uid, recurrenceid)
7.21 - if d:
7.22 - to_store.set_counter(user, other, Object(d).to_node(), uid, recurrenceid)
7.23 + obj = from_store.get_counter(user, other, uid, recurrenceid)
7.24 + if obj:
7.25 + to_store.set_counter(user, other, obj.to_node(), uid, recurrenceid)
7.26 else:
7.27 print >>sys.stderr, "Counter-proposal for %s with UID %s and RECURRENCE-ID %s not found in %s" % (
7.28 (user, uid, recurrenceid or "null", dirname or "active events"))
8.1 --- a/tools/make_freebusy.py Tue May 23 22:15:05 2017 +0200
8.2 +++ b/tools/make_freebusy.py Wed May 24 15:41:14 2017 +0200
8.3 @@ -117,7 +117,7 @@
8.4 print >>sys.stderr, uid, recurrenceid
8.5 event = storage.get_event(user, uid, recurrenceid)
8.6 if event:
8.7 - objs.append(Object(event))
8.8 + objs.append(event)
8.9
8.10 # Build a free/busy collection for the given user.
8.11