pypicloud.storage.object_store module

Store packages in S3

class pypicloud.storage.object_store.ObjectStoreStorage(request=None, expire_after=None, bucket_prefix=None, prepend_hash=None, redirect_urls=None, sse=None, object_acl=None, storage_class=None, region_name=None, public_url=False, **kwargs)[source]

Bases: IStorage

Storage backend base class containing code that is common between supported object stores (S3 / GCS)

calculate_path(package)[source]

Calculates the path of a package

classmethod configure(settings)[source]

Configure the storage method with app settings

download_response(package)[source]

Return a HTTP Response that will download this package

This is called from the download endpoint

get_path(package)[source]

Get the fully-qualified bucket path for a package

get_url(package)[source]

Create or return an HTTP url for a package file

By default this will return a link to the download endpoint

/api/package/<package>/<filename>

Returns
linkstr

Link to the location of this package file

open(package)[source]

Get a buffer object that can read the package data

This should be a context manager. It is used in migration scripts, not directly by the web application.

Parameters
packagePackage

Examples

with storage.open(package) as pkg_data:
    with open('outfile.tar.gz', 'w') as ofile:
        ofile.write(pkg_data.read())
classmethod package_from_object(obj, factory)[source]

Subclasses must implement a method for constructing a Package instance from the backend’s storage object format

test = False[source]