Package Camelot :: Package camelot :: Package core :: Package files :: Module storage :: Class Storage
[frames] | no frames]

Class Storage

source code


Helper class that opens and saves StoredFile objects The default implementation stores files in the settings.CAMELOT_MEDIA_ROOT directory. The storage object should only be used within the model thread, as all of it's methods might block.

The methods of this class don't verify if they are called on the model thread, because these classes can be used on the server as well.

Instance Methods
 
__init__(self, upload_to='', stored_file_implementation=<class 'Camelot.camelot.core.files.storage.StoredFile'>)
checking out files from the storage
source code
 
available(self)
Verify if the storage is available
source code
 
exists(self, name)
True if a file exists given some name
source code
 
list(self, prefix='*', suffix='*')
Lists all files with a given prefix and or suffix available in this storage :return: a iterator of StoredFile objects
source code
 
path(self, name)
The local filesystem path where the file can be opened using Python’s standard open
source code
 
checkin(self, local_path)
Check the file pointed to by local_path into the storage, and return a StoredFile
source code
 
checkin_stream(self, prefix, suffix, stream)
Check the datastream in as a file into the storage :param prefix: the prefix to use for generating a file name :param suffix: the suffix to use for generating a filen name, eg '.png' :return: a StoredFile
source code
 
checkout(self, stored_file)
Check the file pointed to by the local_path out of the storage and return a local filesystem path where the file can be opened
source code
 
checkout_stream(self, stored_file)
Check the file stored_file out of the storage as a datastream :return: a file object
source code
 
delete(self, name) source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties

Inherited from object: __class__

Method Details

__init__(self, upload_to='', stored_file_implementation=<class 'Camelot.camelot.core.files.storage.StoredFile'>)
(Constructor)

source code 
checking out files from the storage
Parameters:
  • upload_to - the sub directory in which to put files
  • stored_file_implementation - the subclass of StoredFile to be used when
Overrides: object.__init__