basestorage.py 717 B

1234567891011121314151617181920212223242526272829303132333435
  1. #!/usr/bin/python
  2. # -*- coding: utf-8 -*-
  3. from __future__ import print_function, unicode_literals
  4. class BaseStorage(object):
  5. """
  6. Provides operations on the storage data.
  7. This class gets subclassed to actually write the data
  8. to a file, database, whatever.
  9. """
  10. data = None
  11. def open(self):
  12. """
  13. When overridden in a subclass,
  14. closes the persistent storage.
  15. """
  16. pass
  17. def save(self):
  18. """
  19. When overriden in a subclass,
  20. stores the data to a persistent storage.
  21. """
  22. pass
  23. def close(self):
  24. """
  25. When overridden in a subclass,
  26. closes the persistent storage.
  27. """
  28. pass