1
# Copyright 2010 Canonical Ltd. This software is licensed under the
2
# GNU Affero General Public License version 3 (see the file LICENSE).
10
from lpx.disk.directory import Directory
11
from lpx.disk.exceptions import ClientError
12
from lpx.disk.validators import valid_name
18
This is the highest-level interface to a backend in order to manage
21
Note that Store objects are not threadsafe. You should create one
22
Store per thread in your application, passing them the same backend
26
directory_factory = Directory
28
def __init__(self, backend):
29
self._backend = backend
30
self._connection = backend.connect()
32
def __getitem__(self, name):
33
"""Get a Directory from this Store."""
34
if not valid_name(name):
35
raise ClientError("Invalid directory name: '%s'" % name)
37
return self.directory_factory(self, name)
39
def __delitem__(self, name):
40
"""Delete a Directory from this Store."""
41
if not valid_name(name):
42
raise ClientError("Invalid directory name: '%s'" % name)
44
return self._connection.deleteDirectory(name)
47
"""Return this Store's Backend object."""