paul@2 | 1 | #!/usr/bin/env python |
paul@2 | 2 | |
paul@146 | 3 | """ |
paul@146 | 4 | A simple filesystem-based store of calendar data. |
paul@146 | 5 | |
paul@1039 | 6 | Copyright (C) 2014, 2015, 2016 Paul Boddie <paul@boddie.org.uk> |
paul@146 | 7 | |
paul@146 | 8 | This program is free software; you can redistribute it and/or modify it under |
paul@146 | 9 | the terms of the GNU General Public License as published by the Free Software |
paul@146 | 10 | Foundation; either version 3 of the License, or (at your option) any later |
paul@146 | 11 | version. |
paul@146 | 12 | |
paul@146 | 13 | This program is distributed in the hope that it will be useful, but WITHOUT |
paul@146 | 14 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
paul@146 | 15 | FOR A PARTICULAR PURPOSE. See the GNU General Public License for more |
paul@146 | 16 | details. |
paul@146 | 17 | |
paul@146 | 18 | You should have received a copy of the GNU General Public License along with |
paul@146 | 19 | this program. If not, see <http://www.gnu.org/licenses/>. |
paul@146 | 20 | """ |
paul@146 | 21 | |
paul@1088 | 22 | from imiptools.stores.common import StoreBase, PublisherBase, JournalBase |
paul@1069 | 23 | |
paul@30 | 24 | from datetime import datetime |
paul@1039 | 25 | from imiptools.config import STORE_DIR, PUBLISH_DIR, JOURNAL_DIR |
paul@301 | 26 | from imiptools.data import make_calendar, parse_object, to_stream |
paul@740 | 27 | from imiptools.dates import format_datetime, get_datetime, to_timezone |
paul@147 | 28 | from imiptools.filesys import fix_permissions, FileBase |
paul@1171 | 29 | from imiptools.period import FreeBusyPeriod, FreeBusyGroupPeriod, \ |
paul@1171 | 30 | FreeBusyOfferPeriod, FreeBusyCollection, \ |
paul@1171 | 31 | FreeBusyGroupCollection, FreeBusyOffersCollection |
paul@1046 | 32 | from imiptools.text import parse_line |
paul@808 | 33 | from os.path import isdir, isfile, join |
paul@343 | 34 | from os import listdir, remove, rmdir |
paul@395 | 35 | import codecs |
paul@15 | 36 | |
paul@1039 | 37 | class FileStoreBase(FileBase): |
paul@50 | 38 | |
paul@1039 | 39 | "A file store supporting user-specific locking and tabular data." |
paul@147 | 40 | |
paul@303 | 41 | def acquire_lock(self, user, timeout=None): |
paul@303 | 42 | FileBase.acquire_lock(self, timeout, user) |
paul@303 | 43 | |
paul@303 | 44 | def release_lock(self, user): |
paul@303 | 45 | FileBase.release_lock(self, user) |
paul@303 | 46 | |
paul@648 | 47 | # Utility methods. |
paul@648 | 48 | |
paul@343 | 49 | def _set_defaults(self, t, empty_defaults): |
paul@343 | 50 | for i, default in empty_defaults: |
paul@343 | 51 | if i >= len(t): |
paul@343 | 52 | t += [None] * (i - len(t) + 1) |
paul@343 | 53 | if not t[i]: |
paul@343 | 54 | t[i] = default |
paul@343 | 55 | return t |
paul@343 | 56 | |
paul@1046 | 57 | def _get_table(self, user, filename, empty_defaults=None, tab_separated=True): |
paul@343 | 58 | |
paul@343 | 59 | """ |
paul@343 | 60 | From the file for the given 'user' having the given 'filename', return |
paul@343 | 61 | a list of tuples representing the file's contents. |
paul@343 | 62 | |
paul@343 | 63 | The 'empty_defaults' is a list of (index, value) tuples indicating the |
paul@343 | 64 | default value where a column either does not exist or provides an empty |
paul@343 | 65 | value. |
paul@1046 | 66 | |
paul@1046 | 67 | If 'tab_separated' is specified and is a false value, line parsing using |
paul@1046 | 68 | the imiptools.text.parse_line function will be performed instead of |
paul@1046 | 69 | splitting each line of the file using tab characters as separators. |
paul@343 | 70 | """ |
paul@343 | 71 | |
paul@702 | 72 | f = codecs.open(filename, "rb", encoding="utf-8") |
paul@702 | 73 | try: |
paul@702 | 74 | l = [] |
paul@702 | 75 | for line in f.readlines(): |
paul@1046 | 76 | line = line.strip(" \r\n") |
paul@1046 | 77 | if tab_separated: |
paul@1046 | 78 | t = line.split("\t") |
paul@1046 | 79 | else: |
paul@1046 | 80 | t = parse_line(line) |
paul@702 | 81 | if empty_defaults: |
paul@702 | 82 | t = self._set_defaults(t, empty_defaults) |
paul@702 | 83 | l.append(tuple(t)) |
paul@702 | 84 | return l |
paul@702 | 85 | finally: |
paul@702 | 86 | f.close() |
paul@702 | 87 | |
paul@1046 | 88 | def _get_table_atomic(self, user, filename, empty_defaults=None, tab_separated=True): |
paul@702 | 89 | |
paul@702 | 90 | """ |
paul@702 | 91 | From the file for the given 'user' having the given 'filename', return |
paul@702 | 92 | a list of tuples representing the file's contents. |
paul@702 | 93 | |
paul@702 | 94 | The 'empty_defaults' is a list of (index, value) tuples indicating the |
paul@702 | 95 | default value where a column either does not exist or provides an empty |
paul@702 | 96 | value. |
paul@1046 | 97 | |
paul@1046 | 98 | If 'tab_separated' is specified and is a false value, line parsing using |
paul@1046 | 99 | the imiptools.text.parse_line function will be performed instead of |
paul@1046 | 100 | splitting each line of the file using tab characters as separators. |
paul@702 | 101 | """ |
paul@702 | 102 | |
paul@343 | 103 | self.acquire_lock(user) |
paul@343 | 104 | try: |
paul@1046 | 105 | return self._get_table(user, filename, empty_defaults, tab_separated) |
paul@343 | 106 | finally: |
paul@343 | 107 | self.release_lock(user) |
paul@343 | 108 | |
paul@343 | 109 | def _set_table(self, user, filename, items, empty_defaults=None): |
paul@343 | 110 | |
paul@343 | 111 | """ |
paul@343 | 112 | For the given 'user', write to the file having the given 'filename' the |
paul@343 | 113 | 'items'. |
paul@343 | 114 | |
paul@343 | 115 | The 'empty_defaults' is a list of (index, value) tuples indicating the |
paul@343 | 116 | default value where a column either does not exist or provides an empty |
paul@343 | 117 | value. |
paul@343 | 118 | """ |
paul@343 | 119 | |
paul@702 | 120 | f = codecs.open(filename, "wb", encoding="utf-8") |
paul@702 | 121 | try: |
paul@702 | 122 | for item in items: |
paul@747 | 123 | self._set_table_item(f, item, empty_defaults) |
paul@702 | 124 | finally: |
paul@702 | 125 | f.close() |
paul@702 | 126 | fix_permissions(filename) |
paul@702 | 127 | |
paul@747 | 128 | def _set_table_item(self, f, item, empty_defaults=None): |
paul@747 | 129 | |
paul@747 | 130 | "Set in table 'f' the given 'item', using any 'empty_defaults'." |
paul@747 | 131 | |
paul@747 | 132 | if empty_defaults: |
paul@747 | 133 | item = self._set_defaults(list(item), empty_defaults) |
paul@747 | 134 | f.write("\t".join(item) + "\n") |
paul@747 | 135 | |
paul@702 | 136 | def _set_table_atomic(self, user, filename, items, empty_defaults=None): |
paul@702 | 137 | |
paul@702 | 138 | """ |
paul@702 | 139 | For the given 'user', write to the file having the given 'filename' the |
paul@702 | 140 | 'items'. |
paul@702 | 141 | |
paul@702 | 142 | The 'empty_defaults' is a list of (index, value) tuples indicating the |
paul@702 | 143 | default value where a column either does not exist or provides an empty |
paul@702 | 144 | value. |
paul@702 | 145 | """ |
paul@702 | 146 | |
paul@343 | 147 | self.acquire_lock(user) |
paul@343 | 148 | try: |
paul@702 | 149 | self._set_table(user, filename, items, empty_defaults) |
paul@343 | 150 | finally: |
paul@343 | 151 | self.release_lock(user) |
paul@343 | 152 | |
paul@1171 | 153 | def _set_freebusy(self, user, freebusy, filename): |
paul@1171 | 154 | |
paul@1171 | 155 | """ |
paul@1171 | 156 | For the given 'user', convert the 'freebusy' details to a form suitable |
paul@1171 | 157 | for writing to 'filename'. |
paul@1171 | 158 | """ |
paul@1171 | 159 | |
paul@1171 | 160 | # Obtain tuples from the free/busy objects. |
paul@1171 | 161 | |
paul@1171 | 162 | self._set_table_atomic(user, filename, |
paul@1171 | 163 | map(lambda fb: freebusy.make_tuple(fb.as_tuple(strings_only=True)), list(freebusy))) |
paul@1171 | 164 | |
paul@1088 | 165 | class Store(FileStoreBase, StoreBase): |
paul@1039 | 166 | |
paul@1039 | 167 | "A file store of tabular free/busy data and objects." |
paul@1039 | 168 | |
paul@1039 | 169 | def __init__(self, store_dir=None): |
paul@1039 | 170 | FileBase.__init__(self, store_dir or STORE_DIR) |
paul@1039 | 171 | |
paul@648 | 172 | # Store object access. |
paul@648 | 173 | |
paul@329 | 174 | def _get_object(self, user, filename): |
paul@329 | 175 | |
paul@329 | 176 | """ |
paul@329 | 177 | Return the parsed object for the given 'user' having the given |
paul@329 | 178 | 'filename'. |
paul@329 | 179 | """ |
paul@329 | 180 | |
paul@329 | 181 | self.acquire_lock(user) |
paul@329 | 182 | try: |
paul@329 | 183 | f = open(filename, "rb") |
paul@329 | 184 | try: |
paul@329 | 185 | return parse_object(f, "utf-8") |
paul@329 | 186 | finally: |
paul@329 | 187 | f.close() |
paul@329 | 188 | finally: |
paul@329 | 189 | self.release_lock(user) |
paul@329 | 190 | |
paul@329 | 191 | def _set_object(self, user, filename, node): |
paul@329 | 192 | |
paul@329 | 193 | """ |
paul@329 | 194 | Set an object for the given 'user' having the given 'filename', using |
paul@329 | 195 | 'node' to define the object. |
paul@329 | 196 | """ |
paul@329 | 197 | |
paul@329 | 198 | self.acquire_lock(user) |
paul@329 | 199 | try: |
paul@329 | 200 | f = open(filename, "wb") |
paul@329 | 201 | try: |
paul@329 | 202 | to_stream(f, node) |
paul@329 | 203 | finally: |
paul@329 | 204 | f.close() |
paul@329 | 205 | fix_permissions(filename) |
paul@329 | 206 | finally: |
paul@329 | 207 | self.release_lock(user) |
paul@329 | 208 | |
paul@329 | 209 | return True |
paul@329 | 210 | |
paul@329 | 211 | def _remove_object(self, filename): |
paul@329 | 212 | |
paul@329 | 213 | "Remove the object with the given 'filename'." |
paul@329 | 214 | |
paul@329 | 215 | try: |
paul@329 | 216 | remove(filename) |
paul@329 | 217 | except OSError: |
paul@329 | 218 | return False |
paul@329 | 219 | |
paul@329 | 220 | return True |
paul@329 | 221 | |
paul@343 | 222 | def _remove_collection(self, filename): |
paul@343 | 223 | |
paul@343 | 224 | "Remove the collection with the given 'filename'." |
paul@343 | 225 | |
paul@343 | 226 | try: |
paul@343 | 227 | rmdir(filename) |
paul@343 | 228 | except OSError: |
paul@343 | 229 | return False |
paul@343 | 230 | |
paul@343 | 231 | return True |
paul@343 | 232 | |
paul@670 | 233 | # User discovery. |
paul@670 | 234 | |
paul@670 | 235 | def get_users(self): |
paul@670 | 236 | |
paul@670 | 237 | "Return a list of users." |
paul@670 | 238 | |
paul@670 | 239 | return listdir(self.store_dir) |
paul@670 | 240 | |
paul@648 | 241 | # Event and event metadata access. |
paul@648 | 242 | |
paul@119 | 243 | def get_events(self, user): |
paul@119 | 244 | |
paul@119 | 245 | "Return a list of event identifiers." |
paul@119 | 246 | |
paul@138 | 247 | filename = self.get_object_in_store(user, "objects") |
paul@808 | 248 | if not filename or not isdir(filename): |
paul@1142 | 249 | return [] |
paul@119 | 250 | |
paul@119 | 251 | return [name for name in listdir(filename) if isfile(join(filename, name))] |
paul@119 | 252 | |
paul@1142 | 253 | def get_cancelled_events(self, user): |
paul@648 | 254 | |
paul@1142 | 255 | "Return a list of event identifiers for cancelled events." |
paul@648 | 256 | |
paul@1142 | 257 | filename = self.get_object_in_store(user, "cancellations", "objects") |
paul@1142 | 258 | if not filename or not isdir(filename): |
paul@1142 | 259 | return [] |
paul@648 | 260 | |
paul@1142 | 261 | return [name for name in listdir(filename) if isfile(join(filename, name))] |
paul@648 | 262 | |
paul@858 | 263 | def get_event(self, user, uid, recurrenceid=None, dirname=None): |
paul@343 | 264 | |
paul@343 | 265 | """ |
paul@343 | 266 | Get the event for the given 'user' with the given 'uid'. If |
paul@343 | 267 | the optional 'recurrenceid' is specified, a specific instance or |
paul@343 | 268 | occurrence of an event is returned. |
paul@343 | 269 | """ |
paul@343 | 270 | |
paul@858 | 271 | filename = self.get_event_filename(user, uid, recurrenceid, dirname) |
paul@808 | 272 | if not filename or not isfile(filename): |
paul@694 | 273 | return None |
paul@694 | 274 | |
paul@694 | 275 | return filename and self._get_object(user, filename) |
paul@694 | 276 | |
paul@343 | 277 | def get_complete_event(self, user, uid): |
paul@50 | 278 | |
paul@50 | 279 | "Get the event for the given 'user' with the given 'uid'." |
paul@50 | 280 | |
paul@694 | 281 | filename = self.get_complete_event_filename(user, uid) |
paul@808 | 282 | if not filename or not isfile(filename): |
paul@50 | 283 | return None |
paul@50 | 284 | |
paul@694 | 285 | return filename and self._get_object(user, filename) |
paul@50 | 286 | |
paul@343 | 287 | def set_complete_event(self, user, uid, node): |
paul@50 | 288 | |
paul@50 | 289 | "Set an event for 'user' having the given 'uid' and 'node'." |
paul@50 | 290 | |
paul@138 | 291 | filename = self.get_object_in_store(user, "objects", uid) |
paul@50 | 292 | if not filename: |
paul@50 | 293 | return False |
paul@50 | 294 | |
paul@329 | 295 | return self._set_object(user, filename, node) |
paul@15 | 296 | |
paul@1068 | 297 | def remove_parent_event(self, user, uid): |
paul@1068 | 298 | |
paul@1068 | 299 | "Remove the parent event for 'user' having the given 'uid'." |
paul@369 | 300 | |
paul@234 | 301 | filename = self.get_object_in_store(user, "objects", uid) |
paul@234 | 302 | if not filename: |
paul@234 | 303 | return False |
paul@234 | 304 | |
paul@329 | 305 | return self._remove_object(filename) |
paul@234 | 306 | |
paul@334 | 307 | def get_recurrences(self, user, uid): |
paul@334 | 308 | |
paul@334 | 309 | """ |
paul@334 | 310 | Get additional event instances for an event of the given 'user' with the |
paul@694 | 311 | indicated 'uid'. Both active and cancelled recurrences are returned. |
paul@694 | 312 | """ |
paul@694 | 313 | |
paul@694 | 314 | return self.get_active_recurrences(user, uid) + self.get_cancelled_recurrences(user, uid) |
paul@694 | 315 | |
paul@694 | 316 | def get_active_recurrences(self, user, uid): |
paul@694 | 317 | |
paul@694 | 318 | """ |
paul@694 | 319 | Get additional event instances for an event of the given 'user' with the |
paul@694 | 320 | indicated 'uid'. Cancelled recurrences are not returned. |
paul@334 | 321 | """ |
paul@334 | 322 | |
paul@334 | 323 | filename = self.get_object_in_store(user, "recurrences", uid) |
paul@808 | 324 | if not filename or not isdir(filename): |
paul@347 | 325 | return [] |
paul@334 | 326 | |
paul@334 | 327 | return [name for name in listdir(filename) if isfile(join(filename, name))] |
paul@334 | 328 | |
paul@694 | 329 | def get_cancelled_recurrences(self, user, uid): |
paul@694 | 330 | |
paul@694 | 331 | """ |
paul@694 | 332 | Get additional event instances for an event of the given 'user' with the |
paul@694 | 333 | indicated 'uid'. Only cancelled recurrences are returned. |
paul@694 | 334 | """ |
paul@694 | 335 | |
paul@782 | 336 | filename = self.get_object_in_store(user, "cancellations", "recurrences", uid) |
paul@808 | 337 | if not filename or not isdir(filename): |
paul@694 | 338 | return [] |
paul@694 | 339 | |
paul@694 | 340 | return [name for name in listdir(filename) if isfile(join(filename, name))] |
paul@694 | 341 | |
paul@334 | 342 | def get_recurrence(self, user, uid, recurrenceid): |
paul@334 | 343 | |
paul@334 | 344 | """ |
paul@334 | 345 | For the event of the given 'user' with the given 'uid', return the |
paul@334 | 346 | specific recurrence indicated by the 'recurrenceid'. |
paul@334 | 347 | """ |
paul@334 | 348 | |
paul@694 | 349 | filename = self.get_recurrence_filename(user, uid, recurrenceid) |
paul@808 | 350 | if not filename or not isfile(filename): |
paul@334 | 351 | return None |
paul@334 | 352 | |
paul@694 | 353 | return filename and self._get_object(user, filename) |
paul@334 | 354 | |
paul@334 | 355 | def set_recurrence(self, user, uid, recurrenceid, node): |
paul@334 | 356 | |
paul@334 | 357 | "Set an event for 'user' having the given 'uid' and 'node'." |
paul@334 | 358 | |
paul@334 | 359 | filename = self.get_object_in_store(user, "recurrences", uid, recurrenceid) |
paul@334 | 360 | if not filename: |
paul@334 | 361 | return False |
paul@334 | 362 | |
paul@334 | 363 | return self._set_object(user, filename, node) |
paul@334 | 364 | |
paul@334 | 365 | def remove_recurrence(self, user, uid, recurrenceid): |
paul@334 | 366 | |
paul@378 | 367 | """ |
paul@378 | 368 | Remove a special recurrence from an event stored by 'user' having the |
paul@378 | 369 | given 'uid' and 'recurrenceid'. |
paul@378 | 370 | """ |
paul@334 | 371 | |
paul@378 | 372 | filename = self.get_object_in_store(user, "recurrences", uid, recurrenceid) |
paul@334 | 373 | if not filename: |
paul@334 | 374 | return False |
paul@334 | 375 | |
paul@334 | 376 | return self._remove_object(filename) |
paul@334 | 377 | |
paul@1068 | 378 | def remove_recurrence_collection(self, user, uid): |
paul@1068 | 379 | |
paul@1068 | 380 | """ |
paul@1068 | 381 | Remove the collection of recurrences stored by 'user' having the given |
paul@1068 | 382 | 'uid'. |
paul@1068 | 383 | """ |
paul@1068 | 384 | |
paul@378 | 385 | recurrences = self.get_object_in_store(user, "recurrences", uid) |
paul@378 | 386 | if recurrences: |
paul@378 | 387 | return self._remove_collection(recurrences) |
paul@378 | 388 | |
paul@378 | 389 | return True |
paul@378 | 390 | |
paul@1142 | 391 | # Event filename computation. |
paul@1142 | 392 | |
paul@1142 | 393 | def get_event_filename(self, user, uid, recurrenceid=None, dirname=None, username=None): |
paul@1142 | 394 | |
paul@1142 | 395 | """ |
paul@1142 | 396 | Get the filename providing the event for the given 'user' with the given |
paul@1142 | 397 | 'uid'. If the optional 'recurrenceid' is specified, a specific instance |
paul@1142 | 398 | or occurrence of an event is returned. |
paul@1142 | 399 | |
paul@1142 | 400 | Where 'dirname' is specified, the given directory name is used as the |
paul@1142 | 401 | base of the location within which any filename will reside. |
paul@1142 | 402 | """ |
paul@1142 | 403 | |
paul@1142 | 404 | if recurrenceid: |
paul@1142 | 405 | return self.get_recurrence_filename(user, uid, recurrenceid, dirname, username) |
paul@1142 | 406 | else: |
paul@1142 | 407 | return self.get_complete_event_filename(user, uid, dirname, username) |
paul@1142 | 408 | |
paul@1142 | 409 | def get_recurrence_filename(self, user, uid, recurrenceid, dirname=None, username=None): |
paul@1142 | 410 | |
paul@1142 | 411 | """ |
paul@1142 | 412 | For the event of the given 'user' with the given 'uid', return the |
paul@1142 | 413 | filename providing the recurrence with the given 'recurrenceid'. |
paul@1142 | 414 | |
paul@1142 | 415 | Where 'dirname' is specified, the given directory name is used as the |
paul@1142 | 416 | base of the location within which any filename will reside. |
paul@1142 | 417 | |
paul@1142 | 418 | Where 'username' is specified, the event details will reside in a file |
paul@1142 | 419 | bearing that name within a directory having 'uid' as its name. |
paul@1142 | 420 | """ |
paul@1142 | 421 | |
paul@1142 | 422 | return self.get_object_in_store(user, dirname, "recurrences", uid, recurrenceid, username) |
paul@1142 | 423 | |
paul@1142 | 424 | def get_complete_event_filename(self, user, uid, dirname=None, username=None): |
paul@1142 | 425 | |
paul@1142 | 426 | """ |
paul@1142 | 427 | Get the filename providing the event for the given 'user' with the given |
paul@1142 | 428 | 'uid'. |
paul@1142 | 429 | |
paul@1142 | 430 | Where 'dirname' is specified, the given directory name is used as the |
paul@1142 | 431 | base of the location within which any filename will reside. |
paul@1142 | 432 | |
paul@1142 | 433 | Where 'username' is specified, the event details will reside in a file |
paul@1142 | 434 | bearing that name within a directory having 'uid' as its name. |
paul@1142 | 435 | """ |
paul@1142 | 436 | |
paul@1142 | 437 | return self.get_object_in_store(user, dirname, "objects", uid, username) |
paul@1142 | 438 | |
paul@652 | 439 | # Free/busy period providers, upon extension of the free/busy records. |
paul@652 | 440 | |
paul@672 | 441 | def _get_freebusy_providers(self, user): |
paul@672 | 442 | |
paul@672 | 443 | """ |
paul@672 | 444 | Return the free/busy providers for the given 'user'. |
paul@672 | 445 | |
paul@672 | 446 | This function returns any stored datetime and a list of providers as a |
paul@672 | 447 | 2-tuple. Each provider is itself a (uid, recurrenceid) tuple. |
paul@672 | 448 | """ |
paul@672 | 449 | |
paul@672 | 450 | filename = self.get_object_in_store(user, "freebusy-providers") |
paul@808 | 451 | if not filename or not isfile(filename): |
paul@672 | 452 | return None |
paul@672 | 453 | |
paul@672 | 454 | # Attempt to read providers, with a declaration of the datetime |
paul@672 | 455 | # from which such providers are considered as still being active. |
paul@672 | 456 | |
paul@702 | 457 | t = self._get_table_atomic(user, filename, [(1, None)]) |
paul@672 | 458 | try: |
paul@672 | 459 | dt_string = t[0][0] |
paul@672 | 460 | except IndexError: |
paul@672 | 461 | return None |
paul@672 | 462 | |
paul@672 | 463 | return dt_string, t[1:] |
paul@672 | 464 | |
paul@672 | 465 | def _set_freebusy_providers(self, user, dt_string, t): |
paul@672 | 466 | |
paul@672 | 467 | "Set the given provider timestamp 'dt_string' and table 't'." |
paul@672 | 468 | |
paul@652 | 469 | filename = self.get_object_in_store(user, "freebusy-providers") |
paul@672 | 470 | if not filename: |
paul@672 | 471 | return False |
paul@652 | 472 | |
paul@672 | 473 | t.insert(0, (dt_string,)) |
paul@702 | 474 | self._set_table_atomic(user, filename, t, [(1, "")]) |
paul@672 | 475 | return True |
paul@652 | 476 | |
paul@648 | 477 | # Free/busy period access. |
paul@648 | 478 | |
paul@1171 | 479 | def get_freebusy(self, user, name=None, mutable=False, cls=None): |
paul@15 | 480 | |
paul@15 | 481 | "Get free/busy details for the given 'user'." |
paul@15 | 482 | |
paul@702 | 483 | filename = self.get_object_in_store(user, name or "freebusy") |
paul@1062 | 484 | |
paul@808 | 485 | if not filename or not isfile(filename): |
paul@1062 | 486 | periods = [] |
paul@112 | 487 | else: |
paul@1171 | 488 | cls = cls or FreeBusyPeriod |
paul@1171 | 489 | periods = map(lambda t: cls(*t), |
paul@1066 | 490 | self._get_table_atomic(user, filename)) |
paul@702 | 491 | |
paul@1071 | 492 | return FreeBusyCollection(periods, mutable) |
paul@1071 | 493 | |
paul@1071 | 494 | def get_freebusy_for_other(self, user, other, mutable=False): |
paul@112 | 495 | |
paul@112 | 496 | "For the given 'user', get free/busy details for the 'other' user." |
paul@112 | 497 | |
paul@112 | 498 | filename = self.get_object_in_store(user, "freebusy-other", other) |
paul@1062 | 499 | |
paul@808 | 500 | if not filename or not isfile(filename): |
paul@1062 | 501 | periods = [] |
paul@112 | 502 | else: |
paul@1062 | 503 | periods = map(lambda t: FreeBusyPeriod(*t), |
paul@1066 | 504 | self._get_table_atomic(user, filename)) |
paul@702 | 505 | |
paul@1071 | 506 | return FreeBusyCollection(periods, mutable) |
paul@1071 | 507 | |
paul@1064 | 508 | def set_freebusy(self, user, freebusy, name=None): |
paul@15 | 509 | |
paul@15 | 510 | "For the given 'user', set 'freebusy' details." |
paul@15 | 511 | |
paul@702 | 512 | filename = self.get_object_in_store(user, name or "freebusy") |
paul@15 | 513 | if not filename: |
paul@15 | 514 | return False |
paul@15 | 515 | |
paul@1171 | 516 | self._set_freebusy(user, freebusy, filename) |
paul@15 | 517 | return True |
paul@15 | 518 | |
paul@1064 | 519 | def set_freebusy_for_other(self, user, freebusy, other): |
paul@110 | 520 | |
paul@110 | 521 | "For the given 'user', set 'freebusy' details for the 'other' user." |
paul@110 | 522 | |
paul@110 | 523 | filename = self.get_object_in_store(user, "freebusy-other", other) |
paul@110 | 524 | if not filename: |
paul@110 | 525 | return False |
paul@110 | 526 | |
paul@1171 | 527 | self._set_freebusy(user, freebusy, filename) |
paul@112 | 528 | return True |
paul@112 | 529 | |
paul@1142 | 530 | def get_freebusy_others(self, user): |
paul@1142 | 531 | |
paul@1142 | 532 | """ |
paul@1142 | 533 | For the given 'user', return a list of other users for whom free/busy |
paul@1142 | 534 | information is retained. |
paul@1142 | 535 | """ |
paul@1142 | 536 | |
paul@1142 | 537 | filename = self.get_object_in_store(user, "freebusy-other") |
paul@1142 | 538 | |
paul@1142 | 539 | if not filename or not isdir(filename): |
paul@1142 | 540 | return [] |
paul@1142 | 541 | |
paul@1142 | 542 | return listdir(filename) |
paul@1142 | 543 | |
paul@710 | 544 | # Tentative free/busy periods related to countering. |
paul@710 | 545 | |
paul@1071 | 546 | def get_freebusy_offers(self, user, mutable=False): |
paul@710 | 547 | |
paul@710 | 548 | "Get free/busy offers for the given 'user'." |
paul@710 | 549 | |
paul@710 | 550 | offers = [] |
paul@710 | 551 | expired = [] |
paul@741 | 552 | now = to_timezone(datetime.utcnow(), "UTC") |
paul@710 | 553 | |
paul@710 | 554 | # Expire old offers and save the collection if modified. |
paul@710 | 555 | |
paul@730 | 556 | self.acquire_lock(user) |
paul@710 | 557 | try: |
paul@1171 | 558 | l = self.get_freebusy(user, "freebusy-offers", cls=FreeBusyOfferPeriod) |
paul@710 | 559 | for fb in l: |
paul@710 | 560 | if fb.expires and get_datetime(fb.expires) <= now: |
paul@710 | 561 | expired.append(fb) |
paul@710 | 562 | else: |
paul@710 | 563 | offers.append(fb) |
paul@710 | 564 | |
paul@710 | 565 | if expired: |
paul@730 | 566 | self.set_freebusy_offers(user, offers) |
paul@710 | 567 | finally: |
paul@730 | 568 | self.release_lock(user) |
paul@710 | 569 | |
paul@1171 | 570 | return FreeBusyOffersCollection(offers, mutable) |
paul@710 | 571 | |
paul@747 | 572 | # Requests and counter-proposals. |
paul@648 | 573 | |
paul@142 | 574 | def _get_requests(self, user, queue): |
paul@66 | 575 | |
paul@142 | 576 | "Get requests for the given 'user' from the given 'queue'." |
paul@66 | 577 | |
paul@142 | 578 | filename = self.get_object_in_store(user, queue) |
paul@808 | 579 | if not filename or not isfile(filename): |
paul@1142 | 580 | return [] |
paul@66 | 581 | |
paul@747 | 582 | return self._get_table_atomic(user, filename, [(1, None), (2, None)]) |
paul@66 | 583 | |
paul@142 | 584 | def get_requests(self, user): |
paul@142 | 585 | |
paul@142 | 586 | "Get requests for the given 'user'." |
paul@142 | 587 | |
paul@142 | 588 | return self._get_requests(user, "requests") |
paul@142 | 589 | |
paul@142 | 590 | def _set_requests(self, user, requests, queue): |
paul@66 | 591 | |
paul@142 | 592 | """ |
paul@142 | 593 | For the given 'user', set the list of queued 'requests' in the given |
paul@142 | 594 | 'queue'. |
paul@142 | 595 | """ |
paul@142 | 596 | |
paul@142 | 597 | filename = self.get_object_in_store(user, queue) |
paul@66 | 598 | if not filename: |
paul@66 | 599 | return False |
paul@66 | 600 | |
paul@747 | 601 | self._set_table_atomic(user, filename, requests, [(1, ""), (2, "")]) |
paul@66 | 602 | return True |
paul@66 | 603 | |
paul@142 | 604 | def set_requests(self, user, requests): |
paul@142 | 605 | |
paul@142 | 606 | "For the given 'user', set the list of queued 'requests'." |
paul@142 | 607 | |
paul@142 | 608 | return self._set_requests(user, requests, "requests") |
paul@142 | 609 | |
paul@747 | 610 | def _set_request(self, user, request, queue): |
paul@142 | 611 | |
paul@343 | 612 | """ |
paul@747 | 613 | For the given 'user', set the given 'request' in the given 'queue'. |
paul@343 | 614 | """ |
paul@142 | 615 | |
paul@142 | 616 | filename = self.get_object_in_store(user, queue) |
paul@55 | 617 | if not filename: |
paul@55 | 618 | return False |
paul@55 | 619 | |
paul@303 | 620 | self.acquire_lock(user) |
paul@55 | 621 | try: |
paul@747 | 622 | f = codecs.open(filename, "ab", encoding="utf-8") |
paul@303 | 623 | try: |
paul@747 | 624 | self._set_table_item(f, request, [(1, ""), (2, "")]) |
paul@303 | 625 | finally: |
paul@303 | 626 | f.close() |
paul@303 | 627 | fix_permissions(filename) |
paul@55 | 628 | finally: |
paul@303 | 629 | self.release_lock(user) |
paul@55 | 630 | |
paul@55 | 631 | return True |
paul@55 | 632 | |
paul@747 | 633 | def set_request(self, user, uid, recurrenceid=None, type=None): |
paul@142 | 634 | |
paul@747 | 635 | """ |
paul@747 | 636 | For the given 'user', set the queued 'uid' and 'recurrenceid', |
paul@747 | 637 | indicating a request, along with any given 'type'. |
paul@747 | 638 | """ |
paul@142 | 639 | |
paul@747 | 640 | return self._set_request(user, (uid, recurrenceid, type), "requests") |
paul@747 | 641 | |
paul@760 | 642 | def get_counters(self, user, uid, recurrenceid=None): |
paul@754 | 643 | |
paul@754 | 644 | """ |
paul@766 | 645 | For the given 'user', return a list of users from whom counter-proposals |
paul@766 | 646 | have been received for the given 'uid' and optional 'recurrenceid'. |
paul@754 | 647 | """ |
paul@754 | 648 | |
paul@754 | 649 | filename = self.get_event_filename(user, uid, recurrenceid, "counters") |
paul@808 | 650 | if not filename or not isdir(filename): |
paul@1142 | 651 | return [] |
paul@754 | 652 | |
paul@766 | 653 | return [name for name in listdir(filename) if isfile(join(filename, name))] |
paul@760 | 654 | |
paul@760 | 655 | def get_counter(self, user, other, uid, recurrenceid=None): |
paul@105 | 656 | |
paul@343 | 657 | """ |
paul@760 | 658 | For the given 'user', return the counter-proposal from 'other' for the |
paul@760 | 659 | given 'uid' and optional 'recurrenceid'. |
paul@760 | 660 | """ |
paul@760 | 661 | |
paul@760 | 662 | filename = self.get_event_filename(user, uid, recurrenceid, "counters", other) |
paul@1090 | 663 | if not filename or not isfile(filename): |
paul@1142 | 664 | return None |
paul@760 | 665 | |
paul@760 | 666 | return self._get_object(user, filename) |
paul@760 | 667 | |
paul@760 | 668 | def set_counter(self, user, other, node, uid, recurrenceid=None): |
paul@760 | 669 | |
paul@760 | 670 | """ |
paul@760 | 671 | For the given 'user', store a counter-proposal received from 'other' the |
paul@760 | 672 | given 'node' representing that proposal for the given 'uid' and |
paul@760 | 673 | 'recurrenceid'. |
paul@760 | 674 | """ |
paul@760 | 675 | |
paul@760 | 676 | filename = self.get_event_filename(user, uid, recurrenceid, "counters", other) |
paul@760 | 677 | if not filename: |
paul@760 | 678 | return False |
paul@760 | 679 | |
paul@760 | 680 | return self._set_object(user, filename, node) |
paul@760 | 681 | |
paul@760 | 682 | def remove_counters(self, user, uid, recurrenceid=None): |
paul@760 | 683 | |
paul@760 | 684 | """ |
paul@760 | 685 | For the given 'user', remove all counter-proposals associated with the |
paul@760 | 686 | given 'uid' and 'recurrenceid'. |
paul@343 | 687 | """ |
paul@105 | 688 | |
paul@747 | 689 | filename = self.get_event_filename(user, uid, recurrenceid, "counters") |
paul@808 | 690 | if not filename or not isdir(filename): |
paul@747 | 691 | return False |
paul@747 | 692 | |
paul@760 | 693 | removed = False |
paul@747 | 694 | |
paul@760 | 695 | for other in listdir(filename): |
paul@760 | 696 | counter_filename = self.get_event_filename(user, uid, recurrenceid, "counters", other) |
paul@760 | 697 | removed = removed or self._remove_object(counter_filename) |
paul@760 | 698 | |
paul@760 | 699 | return removed |
paul@760 | 700 | |
paul@760 | 701 | def remove_counter(self, user, other, uid, recurrenceid=None): |
paul@105 | 702 | |
paul@747 | 703 | """ |
paul@760 | 704 | For the given 'user', remove any counter-proposal from 'other' |
paul@760 | 705 | associated with the given 'uid' and 'recurrenceid'. |
paul@747 | 706 | """ |
paul@747 | 707 | |
paul@760 | 708 | filename = self.get_event_filename(user, uid, recurrenceid, "counters", other) |
paul@808 | 709 | if not filename or not isfile(filename): |
paul@105 | 710 | return False |
paul@747 | 711 | |
paul@747 | 712 | return self._remove_object(filename) |
paul@747 | 713 | |
paul@747 | 714 | # Event cancellation. |
paul@105 | 715 | |
paul@343 | 716 | def cancel_event(self, user, uid, recurrenceid=None): |
paul@142 | 717 | |
paul@343 | 718 | """ |
paul@694 | 719 | Cancel an event for 'user' having the given 'uid'. If the optional |
paul@694 | 720 | 'recurrenceid' is specified, a specific instance or occurrence of an |
paul@694 | 721 | event is cancelled. |
paul@343 | 722 | """ |
paul@142 | 723 | |
paul@694 | 724 | filename = self.get_event_filename(user, uid, recurrenceid) |
paul@694 | 725 | cancelled_filename = self.get_event_filename(user, uid, recurrenceid, "cancellations") |
paul@142 | 726 | |
paul@808 | 727 | if filename and cancelled_filename and isfile(filename): |
paul@694 | 728 | return self.move_object(filename, cancelled_filename) |
paul@142 | 729 | |
paul@142 | 730 | return False |
paul@142 | 731 | |
paul@863 | 732 | def uncancel_event(self, user, uid, recurrenceid=None): |
paul@863 | 733 | |
paul@863 | 734 | """ |
paul@863 | 735 | Uncancel an event for 'user' having the given 'uid'. If the optional |
paul@863 | 736 | 'recurrenceid' is specified, a specific instance or occurrence of an |
paul@863 | 737 | event is uncancelled. |
paul@863 | 738 | """ |
paul@863 | 739 | |
paul@863 | 740 | filename = self.get_event_filename(user, uid, recurrenceid) |
paul@863 | 741 | cancelled_filename = self.get_event_filename(user, uid, recurrenceid, "cancellations") |
paul@863 | 742 | |
paul@863 | 743 | if filename and cancelled_filename and isfile(cancelled_filename): |
paul@863 | 744 | return self.move_object(cancelled_filename, filename) |
paul@863 | 745 | |
paul@863 | 746 | return False |
paul@863 | 747 | |
paul@796 | 748 | def remove_cancellation(self, user, uid, recurrenceid=None): |
paul@796 | 749 | |
paul@796 | 750 | """ |
paul@796 | 751 | Remove a cancellation for 'user' for the event having the given 'uid'. |
paul@796 | 752 | If the optional 'recurrenceid' is specified, a specific instance or |
paul@796 | 753 | occurrence of an event is affected. |
paul@796 | 754 | """ |
paul@796 | 755 | |
paul@796 | 756 | # Remove any parent event cancellation or a specific recurrence |
paul@796 | 757 | # cancellation if indicated. |
paul@796 | 758 | |
paul@796 | 759 | filename = self.get_event_filename(user, uid, recurrenceid, "cancellations") |
paul@796 | 760 | |
paul@808 | 761 | if filename and isfile(filename): |
paul@796 | 762 | return self._remove_object(filename) |
paul@796 | 763 | |
paul@796 | 764 | return False |
paul@796 | 765 | |
paul@1088 | 766 | class Publisher(FileBase, PublisherBase): |
paul@30 | 767 | |
paul@30 | 768 | "A publisher of objects." |
paul@30 | 769 | |
paul@597 | 770 | def __init__(self, store_dir=None): |
paul@597 | 771 | FileBase.__init__(self, store_dir or PUBLISH_DIR) |
paul@30 | 772 | |
paul@30 | 773 | def set_freebusy(self, user, freebusy): |
paul@30 | 774 | |
paul@30 | 775 | "For the given 'user', set 'freebusy' details." |
paul@30 | 776 | |
paul@52 | 777 | filename = self.get_object_in_store(user, "freebusy") |
paul@30 | 778 | if not filename: |
paul@30 | 779 | return False |
paul@30 | 780 | |
paul@30 | 781 | record = [] |
paul@30 | 782 | rwrite = record.append |
paul@30 | 783 | |
paul@30 | 784 | rwrite(("ORGANIZER", {}, user)) |
paul@30 | 785 | rwrite(("UID", {}, user)) |
paul@30 | 786 | rwrite(("DTSTAMP", {}, datetime.utcnow().strftime("%Y%m%dT%H%M%SZ"))) |
paul@30 | 787 | |
paul@458 | 788 | for fb in freebusy: |
paul@458 | 789 | if not fb.transp or fb.transp == "OPAQUE": |
paul@529 | 790 | rwrite(("FREEBUSY", {"FBTYPE" : "BUSY"}, "/".join( |
paul@563 | 791 | map(format_datetime, [fb.get_start_point(), fb.get_end_point()])))) |
paul@30 | 792 | |
paul@395 | 793 | f = open(filename, "wb") |
paul@30 | 794 | try: |
paul@30 | 795 | to_stream(f, make_calendar([("VFREEBUSY", {}, record)], "PUBLISH")) |
paul@30 | 796 | finally: |
paul@30 | 797 | f.close() |
paul@103 | 798 | fix_permissions(filename) |
paul@30 | 799 | |
paul@30 | 800 | return True |
paul@30 | 801 | |
paul@1088 | 802 | class Journal(FileStoreBase, JournalBase): |
paul@1039 | 803 | |
paul@1039 | 804 | "A journal system to support quotas." |
paul@1039 | 805 | |
paul@1039 | 806 | def __init__(self, store_dir=None): |
paul@1039 | 807 | FileBase.__init__(self, store_dir or JOURNAL_DIR) |
paul@1039 | 808 | |
paul@1049 | 809 | # Quota and user identity/group discovery. |
paul@1049 | 810 | |
paul@1049 | 811 | def get_quotas(self): |
paul@1049 | 812 | |
paul@1049 | 813 | "Return a list of quotas." |
paul@1049 | 814 | |
paul@1049 | 815 | return listdir(self.store_dir) |
paul@1049 | 816 | |
paul@1049 | 817 | def get_quota_users(self, quota): |
paul@1049 | 818 | |
paul@1049 | 819 | "Return a list of quota users." |
paul@1049 | 820 | |
paul@1049 | 821 | filename = self.get_object_in_store(quota, "journal") |
paul@1049 | 822 | if not filename or not isdir(filename): |
paul@1049 | 823 | return [] |
paul@1049 | 824 | |
paul@1049 | 825 | return listdir(filename) |
paul@1049 | 826 | |
paul@1039 | 827 | # Groups of users sharing quotas. |
paul@1039 | 828 | |
paul@1039 | 829 | def get_groups(self, quota): |
paul@1039 | 830 | |
paul@1039 | 831 | "Return the identity mappings for the given 'quota' as a dictionary." |
paul@1039 | 832 | |
paul@1039 | 833 | filename = self.get_object_in_store(quota, "groups") |
paul@1039 | 834 | if not filename or not isfile(filename): |
paul@1039 | 835 | return {} |
paul@1039 | 836 | |
paul@1046 | 837 | return dict(self._get_table_atomic(quota, filename, tab_separated=False)) |
paul@1039 | 838 | |
paul@1142 | 839 | def set_group(self, quota, store_user, user_group): |
paul@1142 | 840 | |
paul@1142 | 841 | """ |
paul@1142 | 842 | For the given 'quota', set a mapping from 'store_user' to 'user_group'. |
paul@1142 | 843 | """ |
paul@1142 | 844 | |
paul@1142 | 845 | filename = self.get_object_in_store(quota, "groups") |
paul@1142 | 846 | if not filename: |
paul@1142 | 847 | return False |
paul@1142 | 848 | |
paul@1142 | 849 | groups = self.get_groups(quota) or {} |
paul@1142 | 850 | groups[store_user] = user_group |
paul@1142 | 851 | |
paul@1142 | 852 | self._set_table_atomic(quota, filename, groups.items()) |
paul@1142 | 853 | return True |
paul@1142 | 854 | |
paul@1039 | 855 | def get_limits(self, quota): |
paul@1039 | 856 | |
paul@1039 | 857 | """ |
paul@1039 | 858 | Return the limits for the 'quota' as a dictionary mapping identities or |
paul@1039 | 859 | groups to durations. |
paul@1039 | 860 | """ |
paul@1039 | 861 | |
paul@1039 | 862 | filename = self.get_object_in_store(quota, "limits") |
paul@1039 | 863 | if not filename or not isfile(filename): |
paul@1142 | 864 | return {} |
paul@1039 | 865 | |
paul@1046 | 866 | return dict(self._get_table_atomic(quota, filename, tab_separated=False)) |
paul@1039 | 867 | |
paul@1089 | 868 | def set_limit(self, quota, group, limit): |
paul@1089 | 869 | |
paul@1089 | 870 | """ |
paul@1089 | 871 | For the given 'quota', set for a user 'group' the given 'limit' on |
paul@1089 | 872 | resource usage. |
paul@1089 | 873 | """ |
paul@1089 | 874 | |
paul@1089 | 875 | filename = self.get_object_in_store(quota, "limits") |
paul@1089 | 876 | if not filename: |
paul@1142 | 877 | return False |
paul@1089 | 878 | |
paul@1089 | 879 | limits = self.get_limits(quota) or {} |
paul@1089 | 880 | limits[group] = limit |
paul@1089 | 881 | |
paul@1089 | 882 | self._set_table_atomic(quota, filename, limits.items()) |
paul@1089 | 883 | return True |
paul@1089 | 884 | |
paul@1048 | 885 | # Free/busy period access for users within quota groups. |
paul@1039 | 886 | |
paul@1142 | 887 | def get_freebusy_users(self, quota): |
paul@1142 | 888 | |
paul@1142 | 889 | """ |
paul@1142 | 890 | Return a list of users whose free/busy details are retained for the |
paul@1142 | 891 | given 'quota'. |
paul@1142 | 892 | """ |
paul@1142 | 893 | |
paul@1142 | 894 | filename = self.get_object_in_store(quota, "freebusy") |
paul@1142 | 895 | if not filename or not isdir(filename): |
paul@1142 | 896 | return [] |
paul@1142 | 897 | |
paul@1142 | 898 | return listdir(filename) |
paul@1142 | 899 | |
paul@1171 | 900 | def get_freebusy(self, quota, user, mutable=False, cls=None): |
paul@1039 | 901 | |
paul@1039 | 902 | "Get free/busy details for the given 'quota' and 'user'." |
paul@1039 | 903 | |
paul@1039 | 904 | filename = self.get_object_in_store(quota, "freebusy", user) |
paul@1059 | 905 | |
paul@1039 | 906 | if not filename or not isfile(filename): |
paul@1062 | 907 | periods = [] |
paul@1062 | 908 | else: |
paul@1171 | 909 | cls = cls or FreeBusyPeriod |
paul@1171 | 910 | periods = map(lambda t: cls(*t), |
paul@1067 | 911 | self._get_table_atomic(quota, filename)) |
paul@1059 | 912 | |
paul@1071 | 913 | return FreeBusyCollection(periods, mutable) |
paul@1039 | 914 | |
paul@1064 | 915 | def set_freebusy(self, quota, user, freebusy): |
paul@1039 | 916 | |
paul@1039 | 917 | "For the given 'quota' and 'user', set 'freebusy' details." |
paul@1039 | 918 | |
paul@1039 | 919 | filename = self.get_object_in_store(quota, "freebusy", user) |
paul@1039 | 920 | if not filename: |
paul@1039 | 921 | return False |
paul@1039 | 922 | |
paul@1171 | 923 | self._set_freebusy(quota, freebusy, filename) |
paul@1039 | 924 | return True |
paul@1039 | 925 | |
paul@1039 | 926 | # Journal entry methods. |
paul@1039 | 927 | |
paul@1071 | 928 | def get_entries(self, quota, group, mutable=False): |
paul@1039 | 929 | |
paul@1039 | 930 | """ |
paul@1039 | 931 | Return a list of journal entries for the given 'quota' for the indicated |
paul@1039 | 932 | 'group'. |
paul@1039 | 933 | """ |
paul@1039 | 934 | |
paul@1039 | 935 | filename = self.get_object_in_store(quota, "journal", group) |
paul@1039 | 936 | |
paul@1039 | 937 | if not filename or not isfile(filename): |
paul@1062 | 938 | periods = [] |
paul@1062 | 939 | else: |
paul@1171 | 940 | periods = map(lambda t: FreeBusyGroupPeriod(*t), |
paul@1067 | 941 | self._get_table_atomic(quota, filename)) |
paul@1062 | 942 | |
paul@1171 | 943 | return FreeBusyGroupCollection(periods, mutable) |
paul@1039 | 944 | |
paul@1039 | 945 | def set_entries(self, quota, group, entries): |
paul@1039 | 946 | |
paul@1039 | 947 | """ |
paul@1039 | 948 | For the given 'quota' and indicated 'group', set the list of journal |
paul@1039 | 949 | 'entries'. |
paul@1039 | 950 | """ |
paul@1039 | 951 | |
paul@1039 | 952 | filename = self.get_object_in_store(quota, "journal", group) |
paul@1039 | 953 | if not filename: |
paul@1039 | 954 | return False |
paul@1039 | 955 | |
paul@1171 | 956 | self._set_freebusy(quota, entries, filename) |
paul@1039 | 957 | return True |
paul@1039 | 958 | |
paul@2 | 959 | # vim: tabstop=4 expandtab shiftwidth=4 |