1.1 --- a/MoinSupport.py Fri May 31 02:07:53 2013 +0200
1.2 +++ b/MoinSupport.py Mon Jun 03 23:37:05 2013 +0200
1.3 @@ -1026,6 +1026,16 @@
1.4 user = self.page.request.user
1.5 return user and user.may.read(self.page.page_name)
1.6
1.7 + def can_delete(self):
1.8 +
1.9 + """
1.10 + Return whether the user associated with the request can delete the
1.11 + page owning this store.
1.12 + """
1.13 +
1.14 + user = self.page.request.user
1.15 + return user and user.may.delete(self.page.page_name)
1.16 +
1.17 # High-level methods.
1.18
1.19 def append(self, item):
1.20 @@ -1039,10 +1049,7 @@
1.21
1.22 def __len__(self):
1.23
1.24 - """
1.25 - Return the number of the next item (which should also be the number of
1.26 - items).
1.27 - """
1.28 + "Return the number of items in the store."
1.29
1.30 if not self.can_read():
1.31 return 0
1.32 @@ -1058,4 +1065,13 @@
1.33
1.34 return ItemDirectoryStore.__getitem__(self, number)
1.35
1.36 + def __delitem__(self, number):
1.37 +
1.38 + "Remove the item with the given 'number'."
1.39 +
1.40 + if not self.can_delete():
1.41 + return
1.42 +
1.43 + return ItemDirectoryStore.__delitem__(self, number)
1.44 +
1.45 # vim: tabstop=4 expandtab shiftwidth=4