Package amplee :: Package storage :: Module stores3 :: Class S3Storage
[hide private]
[frames] | no frames]

Class S3Storage

source code

object --+    
         |    
   Storage --+
             |
            S3Storage

Instance Methods [hide private]
 
__init__(self, aws_access_key_id, aws_secret_access_key, unique_prefix, encoding='utf-8', separator='_', aws_key_lookup=None, aws_file_path=None)
Amazon S3 storage for amplee.
source code
 
shutdown(self)
Disable the boto connection
source code
 
__bn(self, value)
Constructs the bucket name
source code
object
create_container(self, collection_name)
Creates and returns a boto bucket instance for that collection name prefixed by self.unique_prefix
source code
StorageResourceInfo or subclass
info(self, collection_name, resource_name=None)
Returns a StorageResourceInfo instance where the ``key`` attribute is a boto.s3.key.Key instance.
source code
object
get_content(self, info)
Returns the content of the resource at 'info' as a string
source code
string
get_meta_data(self, info)
Returns the content of the resource at 'info' as a string
source code
 
put_content(self, info, content, media_type=None, *args, **kwargs)
Updates the content of the resource at 'info'
source code
 
put_meta_data(self, info, content, media_type=None, *args, **kwargs)
Updates the content of the resource at 'info'
source code
 
remove_content(self, info)
Removes the resource at 'info'
source code
 
remove_meta_data(self, info)
Removes the resource at 'info'
source code
 
persist(self, info_list, msg=None)
Does nothing
source code
bool
exists(self, info)
Returns True if the resource 'info.key' exists in the bucket
source code
dict
ls(self, collection_name, ext=None)
List all the members in a collection and returns them as a dictionnary.
source code
tuple
ils(self, collection_name, ext=None)
Yields members in a collection and returns them as a tuple.
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, aws_access_key_id, aws_secret_access_key, unique_prefix, encoding='utf-8', separator='_', aws_key_lookup=None, aws_file_path=None)
(Constructor)

source code 

Amazon S3 storage for amplee. http://www.amazon.com/gp/browse.html?node=16427261

If the buck does not exist this storage will create it transparently.

Keyword arguments aws_access_key_id -- Amazon S3 publick key

aws_secret_access_key -- Amazon S3 private key

unique_prefix -- Unique prefix used for the creation of buckets

encoding -- when your content is unicode it has to be encoded before being sent to the Amazon servers (default: utf-8)

separator -- character used to join the prefix and the bucket

aws_key_lookup -- a callback that takes one argument and that returns a tuple with the public_key and the secret_key (see below)

aws_file_path -- the argument passed to aws_key_lookup is the path to the file containing the AWS keys

Set it to something really unique and not None!
Overrides: object.__init__

shutdown(self)

source code 
Disable the boto connection
Overrides: Storage.shutdown

create_container(self, collection_name)

source code 
Creates and returns a boto bucket instance for that collection name prefixed by self.unique_prefix
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 instance where the ``key`` attribute is a boto.s3.key.Key instance.
Returns: StorageResourceInfo or subclass
an object representing the resource within the storage
Overrides: Storage.info

get_content(self, info)

source code 

Returns the content of the resource at 'info' as a string

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

get_meta_data(self, info)

source code 

Returns the content of the resource at 'info' as a string

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

put_content(self, info, content, media_type=None, *args, **kwargs)

source code 

Updates the content of the resource at 'info'

Keyword argument: info -- as returned by info()

content -- content as a string or a file object to be persisted into the bucket. If a file object is provided it will be closed automatically.

media_type -- mime type of the resource (default:None)
Overrides: Storage.put_content

put_meta_data(self, info, content, media_type=None, *args, **kwargs)

source code 

Updates the content of the resource at 'info'

Keyword argument: info -- as returned by info()

content -- content as a string or a file object to be persisted into the bucket. If a file object is provided it will be closed automatically.

media_type -- mime type of the resource (default:None)
Overrides: Storage.put_meta_data

remove_content(self, info)

source code 

Removes the resource at 'info'

Keyword argument: info -- as returned by info()
Overrides: Storage.remove_content

remove_meta_data(self, info)

source code 

Removes the resource at 'info'

Keyword argument: info -- as returned by info()
Overrides: Storage.remove_meta_data

persist(self, info_list, msg=None)

source code 
Does nothing
Overrides: Storage.persist

exists(self, info)

source code 
Returns True if the resource 'info.key' exists in the bucket
Returns: bool
True if the test succeeds, False otherwise.
Overrides: Storage.exists

ls(self, collection_name, ext=None)

source code 

List all the members in a collection and returns them as a dictionnary.

Keyword argument: collection_name -- the name of the collection to browse
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 

Yields members in a collection and returns them as a tuple.

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