zoom.instances module

zoom.instances

Mananage zoom instances

Note: Experimental!

class zoom.instances.Instance(path=None)

Bases: object

Zoom Instance

A Zoom instance is a directory containing sites, apps and themes. Zoom can host multiples sites using the same configuration under a single Instance.

>>> import tempfile
>>> instance_path = os.path.join(tempfile.gettempdir(), 'fakeinstance')
>>> instance = Instance(instance_path)
>>> instance.create()
>>> os.path.exists(instance.path)
True
>>> os.path.exists(os.path.join(instance.path, 'sites'))
True
>>> instance.sites == {}
True
>>> instance.destroy()
>>> os.path.exists(instance.path)
False
create()

Create a new instance

destroy()

Destroy an empty instance

run_background_jobs()

Run background jobs

Iterates through the sites in the instance and calls run_background_jobs on each one.

>>> instance = Instance()
>>> instance.run_background_jobs()
localhost
sites

a dict of sites for the instance

>>> instance = Instance()
>>> print(instance.sites)
{'localhost': Site('localhost')}
>>> import tempfile
>>> instance_path = os.path.join(tempfile.gettempdir(), 'fakeinstance')
>>> instance = Instance(instance_path)
>>> got_it = False
>>> try:
...     instance.sites
... except InstanceMissingException:
...     got_it = True
>>> got_it
True
sites_path

the path to the sites of the instance

>>> instance_directory = zoom.tools.zoompath('web')
>>> instance = Instance(instance_directory)
>>> instance.sites_path == instance_directory + '/sites'
True
exception zoom.instances.InstanceExistsException

Bases: Exception

Instance directory exists

exception zoom.instances.InstanceMissingException

Bases: Exception

Instance directory is missing