Commit 6f70d777 authored by Jim Fulton's avatar Jim Fulton

Added blob-dir configuration option.

parent c49527eb
...@@ -2,8 +2,8 @@ Defining FileStorages using ZConfig ...@@ -2,8 +2,8 @@ Defining FileStorages using ZConfig
=================================== ===================================
ZODB provides support for defining many storages, including ZODB provides support for defining many storages, including
FileStorages, using ZConfig. To do this, you use a filestorage FileStorages, using ZConfig. To define a FileStorage, you use a
section, and define a path: filestorage section, and define a path:
>>> import ZODB.config >>> import ZODB.config
>>> fs = ZODB.config.storageFromString(""" >>> fs = ZODB.config.storageFromString("""
...@@ -15,16 +15,39 @@ section, and define a path: ...@@ -15,16 +15,39 @@ section, and define a path:
>>> fs._file.name >>> fs._file.name
'my.fs' 'my.fs'
>>> fs.close()
There are a number of options we can provide: There are a number of options we can provide:
blob-dir
If supplied, the file storage will provide blob support and this
is the name of a directory to hold blob data. The directory will
be created if it doeesn't exist. If no value (or an empty value)
is provided, then no blob support will be provided. (You can still
use a BlobStorage to provide blob support.)
>>> fs = ZODB.config.storageFromString("""
... <filestorage>
... path my.fs
... blob-dir blobs
... </filestorage>
... """)
>>> fs._file.name
'my.fs'
>>> import os
>>> os.path.basename(fs.blob_dir)
'blobs'
>>> fs.close()
create create
Flag that indicates whether the storage should be truncated if Flag that indicates whether the storage should be truncated if
it already exists. it already exists.
To demonstrate this, we'll first write some dataL To demonstrate this, we'll first write some dataL
>>> db = ZODB.DB(fs) # writes object 0 >>> db = ZODB.DB('my.fs') # writes object 0
>>> db.close() >>> db.close()
Then reopen with the create option: Then reopen with the create option:
......
...@@ -7,13 +7,22 @@ ...@@ -7,13 +7,22 @@
<sectiontype name="filestorage" datatype=".FileStorage" <sectiontype name="filestorage" datatype=".FileStorage"
implements="ZODB.storage"> implements="ZODB.storage">
<key name="path" required="yes"> <key name="path" required="yes" datatype="existing-dirpath">
<description> <description>
Path name to the main storage file. The names for Path name to the main storage file. The names for
supplemental files, including index and lock files, will be supplemental files, including index and lock files, will be
computed from this. computed from this.
</description> </description>
</key> </key>
<key name="blob-dir" required="no" datatype="existing-dirpath">
<description>
If supplied, the file storage will provide blob support and this
is the name of a directory to hold blob data. The directory will
be created if it doeesn't exist. If no value (or an empty value)
is provided, then no blob support will be provided. (You can still
use a BlobStorage to provide blob support.)
</description>
</key>
<key name="create" datatype="boolean" default="false"> <key name="create" datatype="boolean" default="false">
<description> <description>
Flag that indicates whether the storage should be truncated if Flag that indicates whether the storage should be truncated if
......
...@@ -147,6 +147,7 @@ class FileStorage(BaseConfig): ...@@ -147,6 +147,7 @@ class FileStorage(BaseConfig):
read_only=self.config.read_only, read_only=self.config.read_only,
quota=self.config.quota, quota=self.config.quota,
pack_gc=self.config.pack_gc, pack_gc=self.config.pack_gc,
blob_dir=self.config.blob_dir,
**options) **options)
class BlobStorage(BaseConfig): class BlobStorage(BaseConfig):
......
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