Actually, we can implement get_unique_filename, which should be the

same across all storage API implementations
This commit is contained in:
Christopher Allan Webber 2011-04-09 14:05:44 -05:00
parent 797be93ca6
commit 0b9cf289c3

View File

@ -84,6 +84,14 @@ class StorageInterface(object):
# Subclasses should override this method.
self.__raise_not_implemented()
def get_file(self, filepath):
# Subclasses should override this method.
self.__raise_not_implemented()
def delete_file(self, filepath):
# Subclasses should override this method.
self.__raise_not_implemented()
def get_unique_filename(self, filepath):
"""
If a filename at filepath already exists, generate a new name.
@ -96,13 +104,7 @@ class StorageInterface(object):
>>> storage_handler.get_unique_filename(['dir1', 'dir2', 'fname.jpg'])
['dir1', 'dir2', 'd02c3571-dd62-4479-9d62-9e3012dada29-fname.jpg']
"""
# Subclasses should override this method.
self.__raise_not_implemented()
def get_file(self, filepath):
# Subclasses should override this method.
self.__raise_not_implemented()
def delete_file(self, filepath):
# Subclasses should override this method.
self.__raise_not_implemented()
if self.file_exists(filepath):
return filepath[:-1] + ["%s-%s" % (uuid.uuid4(), filepath[-1])]
else:
return filepath