1.1 --- a/MoinSupport.py Wed Nov 06 12:33:12 2013 +0100
1.2 +++ b/MoinSupport.py Wed Nov 06 12:41:01 2013 +0100
1.3 @@ -1093,7 +1093,7 @@
1.4
1.5 # Content storage support.
1.6
1.7 -# Specific storage mechanisms.
1.8 +# Underlying storage mechanisms.
1.9
1.10 class SubpageItemStore(GeneralItemStore):
1.11
1.12 @@ -1187,11 +1187,32 @@
1.13 finally:
1.14 self.writelock.release()
1.15
1.16 -# General item store classes.
1.17 +def getDirectoryItemStoreForPage(page, item_dir, lock_dir):
1.18 +
1.19 + """
1.20 + A convenience function returning a directory-based store for the given
1.21 + 'page', using the given 'item_dir' and 'lock_dir'.
1.22 + """
1.23 +
1.24 + item_dir_path = tuple(item_dir.split("/"))
1.25 + lock_dir_path = tuple(lock_dir.split("/"))
1.26 + return DirectoryItemStore(page.getPagePath(*item_dir_path), page.getPagePath(*lock_dir_path))
1.27 +
1.28 +def getSubpageItemStoreForPage(page, lock_dir):
1.29 +
1.30 + """
1.31 + A convenience function returning a subpage-based store for the given
1.32 + 'page', using the given 'lock_dir'.
1.33 + """
1.34 +
1.35 + lock_dir_path = tuple(lock_dir.split("/"))
1.36 + return SubpageItemStore(page, page.getPagePath(*lock_dir_path))
1.37 +
1.38 +# Page-oriented item store classes.
1.39
1.40 class ItemStoreBase:
1.41
1.42 - "Support for page-specific item stores."
1.43 + "Access item stores via pages, observing page access restrictions."
1.44
1.45 def __init__(self, page, store):
1.46 self.page = page
1.47 @@ -1285,27 +1306,20 @@
1.48 def next(self):
1.49 return self.store.next()
1.50
1.51 -def getDirectoryItemStoreForPage(page, item_dir, lock_dir):
1.52 - item_dir_path = tuple(item_dir.split("/"))
1.53 - lock_dir_path = tuple(lock_dir.split("/"))
1.54 - return DirectoryItemStore(page.getPagePath(*item_dir_path), page.getPagePath(*lock_dir_path))
1.55 +# Convenience store classes.
1.56
1.57 -def getSubpageItemStoreForPage(page, lock_dir):
1.58 - lock_dir_path = tuple(lock_dir.split("/"))
1.59 - return SubpageItemStore(page, page.getPagePath(*lock_dir_path))
1.60 -
1.61 -# Convenience store constructors.
1.62 -
1.63 -def ItemStore(page, item_dir="items", lock_dir="item_locks"):
1.64 +class ItemStore(ItemStoreBase):
1.65
1.66 "Store items in a directory via a page."
1.67
1.68 - return ItemStoreBase(page, getDirectoryItemStoreForPage(page, item_dir, lock_dir))
1.69 + def __init__(self, page, item_dir="items", lock_dir="item_locks"):
1.70 + ItemStoreBase.__init__(self, page, getDirectoryItemStoreForPage(page, item_dir, lock_dir))
1.71
1.72 -def ItemSubpageStore(page, lock_dir="item_locks"):
1.73 +class ItemSubpageStore(ItemStoreBase):
1.74
1.75 "Store items in subpages of a page."
1.76
1.77 - return ItemStoreBase(page, getSubpageItemStoreForPage(page, lock_dir))
1.78 + def __init__(self, page, lock_dir="item_locks"):
1.79 + ItemStoreBase.__init__(self, page, getSubpageItemStoreForPage(page, lock_dir))
1.80
1.81 # vim: tabstop=4 expandtab shiftwidth=4