Package amplee :: Package storage :: Module storefs :: Class FilesystemStorage
[hide private]
[frames] | no frames]

Class FilesystemStorage

source code

object --+    
         |    
   Storage --+
             |
            FilesystemStorage

Instance Methods [hide private]
 
__init__(self, storage_path, enable_lock=False, encoding='utf-8')
Simple filesystem storage for amplee.
source code
 
shutdown(self)
Shutdown the storage.
source code
object
create_container(self, collection_name)
Creates a subdirectory within the storage directory If it already exists does nothing.
source code
StorageResourceInfo or subclass
info(self, collection_name, resource_name=None)
Returns a StorageResourceInfo which ``key`` attribute is set to the absolute path to the given resource or, if not provided, to the collection directory.
source code
object
get_content(self, info)
Returns the content as a string of the resource found at 'info.key'.
source code
string
get_meta_data(self, info)
Returns the content as a string of the resource found at 'info.key'.
source code
 
put_content(self, info, content, **kwargs)
Set the content at 'info' of the resource.
source code
 
put_meta_data(self, info, content, **kwargs)
Set the content at 'info' of the resource.
source code
 
remove_content(self, info)
Remove the resource at 'info'
source code
 
remove_meta_data(self, info)
Remove the resource at 'path'
source code
 
persist(self, *args, **kwargs)
Does nothing in the filesystem storage
source code
bool
exists(self, info)
Returns True if the resource at 'info.key' exists.
source code
dict
ls(self, collection_name, ext=None)
List all the existing resources of a collection Returns a dictionary like this:
source code
tuple
ils(self, collection_name, ext=None)
Yield members matching the parameters.
source code

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

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, storage_path, enable_lock=False, encoding='utf-8')
(Constructor)

source code 

Simple filesystem storage for amplee.

If storage path does not exist, it is created.

When the locking is enabled it creates a threading.Lock instance which is used for writing operations (put and remove).

Keyword arguments storage_path -- absolute path to the top level directory which will contain collections and resources enable_lock -- if True, thread locking will be enabled during write operations encoding -- used to encode the path elements
Overrides: object.__init__

shutdown(self)

source code 
Shutdown the storage. Does nothing effectively.
Overrides: Storage.shutdown

create_container(self, collection_name)

source code 

Creates a subdirectory within the storage directory If it already exists does nothing.

Keyword argument collection_name -- name of the directory to create
Returns: object
the subclass may or may not return an object upon the creation of the container
Overrides: Storage.create_container

info(self, collection_name, resource_name=None)

source code 
Returns a StorageResourceInfo which ``key`` attribute is set to the absolute path to the given resource or, if not provided, to the collection directory.
Returns: StorageResourceInfo or subclass
an object representing the resource within the storage
Overrides: Storage.info

get_content(self, info)

source code 

Returns the content as a string of the resource found at 'info.key'. If no resource could be found, an amplee.error.UnknownResource is raised.

Keyword arguments info -- Path to the resource as returned by info()
Returns: object
content of the resource
Overrides: Storage.get_content

get_meta_data(self, info)

source code 

Returns the content as a string of the resource found at 'info.key'. If no resource could be found, an amplee.error.UnknownResource is raised.

Keyword arguments info -- Path to the resource as returned by info()
Returns: string
content of the atom entry
Overrides: Storage.get_meta_data

put_content(self, info, content, **kwargs)

source code 

Set the content at 'info' of the resource.

Keyword arguments info -- Path to the resource as returned by info()

content -- data as a string object or a file object. In the latter case read() MUST return the full content as a byte string.
Overrides: Storage.put_content

put_meta_data(self, info, content, **kwargs)

source code 

Set the content at 'info' of the resource.

Keyword arguments info -- Path to the resource as returned by info()

content -- data as a string or a file object. In the latter case read() MUST return the full content as a byte string.
Overrides: Storage.put_meta_data

remove_content(self, info)

source code 

Remove the resource at 'info'

Keyword arguments info -- Path to the resource as returned by info()
Overrides: Storage.remove_content

remove_meta_data(self, info)

source code 

Remove the resource at 'path'

Keyword arguments info -- Path to the resource as returned by info()
Overrides: Storage.remove_meta_data

persist(self, *args, **kwargs)

source code 
Does nothing in the filesystem storage
Overrides: Storage.persist

exists(self, info)

source code 

Returns True if the resource at 'info.key' exists. False otherwise.

Keyword arguments info -- Path to the resource as returned by info()
Returns: bool
True if the test succeeds, False otherwise.
Overrides: Storage.exists

ls(self, collection_name, ext=None)

source code 

List all the existing resources of a collection Returns a dictionary like this:

members[basename(abs_path)] = StorageResourceInfo

Keyword arguments collection_name -- name of the collection
Returns: dict
a dictionnary of existing members, their identifier and a StorageResourceInfo instance representing the resource.
Overrides: Storage.ls

ils(self, collection_name, ext=None)

source code 

Yield members matching the parameters.

Keyword arguments collection_name -- name of the collection
Returns: tuple
existing members, their identifier and a StorageResourceInfo instance representing the resource.
Overrides: Storage.ils