Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

dotcloud environment loader

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 fixtures
Octocat-spinner-32 MANIFEST.in
Octocat-spinner-32 README.rst
Octocat-spinner-32 setup.py
Octocat-spinner-32 spot.py
Octocat-spinner-32 test_spot.py
README.rst

SPOT - DotCloud environment loader

Why?

When working with DotCloud you will more than likely have a developement environment locally that offers the services your application requires which are specified in the build file.

Locally one very rarely bother changing the parameters of the services from their defaults settings but on DotCloud your application must read the environment file.

Hence you end up with a fair amount of boilerplate code in your application which figures out wether it is running locally or on DotCloud and instantiates the services for you to use accordingly.

Not anymore ... if you don't want to ;)

How?

Enters SPOT (named after the French earth observation satellite). SPOT knows wether your code is running locally or on DotCloud, exposes each service parameters under the name you gave it in your build file.

For example if your build file contains a python service named www and a redis_ service named cache:

www:
    type: python
cache:
    type: redis

Then when you instantiate a spot.Dotcloud() object it will expose the cache services:

>>> import spot
>>> dotcloud = spot.Dotcloud()
>>> isinstance(dotcloud.cache, spot.Redis)
True

When running locally:

>>> dotcloud.cache.host
u'localhost'

But on DotCloud:

>>> dotcloud.cache.host
u'SOMETHING.dotcloud.com'

If you have installed the packages allowing Python to handle the services e.g. redis_ (and hiredis), the spot.Dotcloud instance also expose a connection to the server you can use out of the box:

>>> type(dotcloud.cache.server)
<class 'redis.client.StrictRedis'>

Next?

At this stage only the Redis_ and MongoDB services are managed. I will add more as I require them ... or you can contribute and submit new services definition via pull request ;)

Docutils System Messages

System Message: ERROR/3 (<string>, line 29); backlink

Duplicate target name, cannot be used as a unique reference: "redis".

System Message: ERROR/3 (<string>, line 55); backlink

Duplicate target name, cannot be used as a unique reference: "redis".

System Message: ERROR/3 (<string>, line 65); backlink

Duplicate target name, cannot be used as a unique reference: "redis".
Something went wrong with that request. Please try again.