Changeset 746:003c2d428dd8 in hatta-dev


Ignore:
Timestamp:
01/24/10 15:31:54 (2 years ago)
Author:
sheep@…
Branch:
default
Message:

remove empty subdirectories after page delete

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • hatta.py

    r745 r746  
    708708                                                       author, comment, parent) 
    709709 
     710    def delete_page(self, title, author=u'', comment=u''): 
     711        super(WikiSubdirectoryStorage, self).delete_page(title, author, comment) 
     712        file_path = self._file_path(title) 
     713        self._check_path(file_path) 
     714        dir_path = os.path.dirname(file_path) 
     715        os.removedirs(dir_path) 
    710716 
    711717class WikiParser(object): 
  • tests/test_repo.py

    r744 r746  
    9595            exists = os.path.exists(filepath) 
    9696            assert exists 
     97 
     98    def test_subdirectory_delete(self, subdir_repo): 
     99        title = u'foo/bar' 
     100        filepath = os.path.join(subdir_repo.path, 'foo/bar') 
     101        dirpath = os.path.join(subdir_repo.path, 'foo') 
     102        subdir_repo.save_text(title, self.text, self.author, self.comment, 
     103                              parent=-1) 
     104        subdir_repo.delete_page(title, self.author, self.comment) 
     105        exists = os.path.exists(filepath) 
     106        assert not exists 
     107        exists = os.path.exists(dirpath) 
     108        assert not exists 
    97109 
    98110 
Note: See TracChangeset for help on using the changeset viewer.