Commit 02955468 authored by Christian Theune's avatar Christian Theune

- removed some unnecessary XXX comments

 - made ClientStorage and BlobStorage create the blob root directories automatically
parent 3f77de54
......@@ -315,9 +315,15 @@ class ClientStorage(object):
self._lock = threading.Lock()
# XXX need to check for POSIX-ness here
if blob_dir is not None and (os.stat(blob_dir).st_mode & 077) != 0:
log2('Blob dir %s has insecure mode setting' % blob_dir,
level=logging.WARNING)
if blob_dir is not None:
if not os.path.exists(blob_dir):
os.makedirs(blob_dir, 0700)
log2("Blob cache directory '%s' does not exist. "
"Created new directory." % self.base_directory,
level=logging.INFO)
if (os.stat(blob_dir).st_mode & 077) != 0:
log2('Blob dir %s has insecure mode setting' % blob_dir,
level=logging.WARNING)
self.blob_dir = blob_dir
......
......@@ -15,6 +15,7 @@
import os
import shutil
import base64
import logging
from zope.interface import implements
from zope.proxy import ProxyBase, getProxiedObject
......@@ -25,6 +26,8 @@ from ZODB.POSException import POSKeyError
BLOB_SUFFIX = ".blob"
logger = logging.getLogger('ZODB.BlobStorage')
class BlobStorage(ProxyBase):
"""A storage to support blobs."""
......@@ -32,7 +35,7 @@ class BlobStorage(ProxyBase):
__slots__ = ('base_directory', 'dirty_oids')
# Proxies can't have a __dict__ so specifying __slots__ here allows
# us to have instance attributes? XXX confirm
# us to have instance attributes explicitly on the proxy.
def __new__(self, base_directory, storage):
return ProxyBase.__new__(self, storage)
......@@ -41,6 +44,10 @@ class BlobStorage(ProxyBase):
# TODO Complain if storage is ClientStorage
ProxyBase.__init__(self, storage)
self.base_directory = base_directory
if not os.path.exists(self.base_directory):
os.makedirs(self.base_directory, 0700)
logger.info("Blob directory '%s' does not exist. "
"Created new directory." % self.base_directory)
self.dirty_oids = []
def __repr__(self):
......@@ -93,7 +100,6 @@ class BlobStorage(ProxyBase):
""" We need to override the base storage's abort instead of
providing an _abort method because methods found on the proxied object
aren't rebound to the proxy """
# XXX this is never called during our tests.
getProxiedObject(self).tpc_abort(*arg, **kw)
while self.dirty_oids:
oid, serial = self.dirty_oids.pop()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment