Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
Zope
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
Zope
Commits
2c936305
Commit
2c936305
authored
Apr 08, 2003
by
Chris McDonough
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Wire up ZODB database configuration via configuration file.
parent
ad9aed9f
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
85 additions
and
8 deletions
+85
-8
lib/python/Zope/App/startup.py
lib/python/Zope/App/startup.py
+5
-3
lib/python/Zope/Startup/datatypes.py
lib/python/Zope/Startup/datatypes.py
+52
-0
lib/python/Zope/Startup/zopeschema.xml
lib/python/Zope/Startup/zopeschema.xml
+23
-1
skel/etc/zope.conf.in
skel/etc/zope.conf.in
+5
-4
No files found.
lib/python/Zope/App/startup.py
View file @
2c936305
...
@@ -48,9 +48,11 @@ def startup():
...
@@ -48,9 +48,11 @@ def startup():
# Try to use custom storage
# Try to use custom storage
m
=
imp
.
find_module
(
'custom_zodb'
,[
getConfiguration
().
instancehome
])
m
=
imp
.
find_module
(
'custom_zodb'
,[
getConfiguration
().
instancehome
])
except
:
except
:
import
ZODB.FileStorage
# if there is no custom_zodb, use the config file specified databases
storage
=
ZODB
.
FileStorage
.
FileStorage
(
Globals
.
BobobaseName
)
config
=
getConfiguration
()
DB
=
ZODB
.
DB
(
storage
)
name
=
config
.
db_mount_tab
[
'/'
]
DB
=
config
.
db_name_tab
[
name
].
open
()
Globals
.
BobobaseName
=
name
else
:
else
:
m
=
imp
.
load_module
(
'Zope.custom_zodb'
,
m
[
0
],
m
[
1
],
m
[
2
])
m
=
imp
.
load_module
(
'Zope.custom_zodb'
,
m
[
0
],
m
[
1
],
m
[
2
])
if
hasattr
(
m
,
'DB'
):
if
hasattr
(
m
,
'DB'
):
...
...
lib/python/Zope/Startup/datatypes.py
View file @
2c936305
...
@@ -68,12 +68,22 @@ def dns_resolver(hostname):
...
@@ -68,12 +68,22 @@ def dns_resolver(hostname):
from
ZServer.medusa
import
resolver
from
ZServer.medusa
import
resolver
return
resolver
.
caching_resolver
(
hostname
)
return
resolver
.
caching_resolver
(
hostname
)
# mount-point definition
def
mount_point
(
value
):
if
not
value
:
raise
ValueError
,
'mount-point must not be empty'
if
not
value
.
startswith
(
'/'
):
raise
ValueError
,
(
"mount-point '%s' is invalid: mount points must "
"begin with a slash"
%
value
)
return
value
# Datatype for the root configuration object
# Datatype for the root configuration object
# (adds the softwarehome and zopehome fields; default values for some
# (adds the softwarehome and zopehome fields; default values for some
# computed paths)
# computed paths)
def
root_config
(
section
):
def
root_config
(
section
):
from
ZConfig
import
ConfigurationError
here
=
os
.
path
.
dirname
(
os
.
path
.
abspath
(
__file__
))
here
=
os
.
path
.
dirname
(
os
.
path
.
abspath
(
__file__
))
swhome
=
os
.
path
.
dirname
(
os
.
path
.
dirname
(
here
))
swhome
=
os
.
path
.
dirname
(
os
.
path
.
dirname
(
here
))
section
.
softwarehome
=
swhome
section
.
softwarehome
=
swhome
...
@@ -88,4 +98,46 @@ def root_config(section):
...
@@ -88,4 +98,46 @@ def root_config(section):
section
.
pid_filename
=
os
.
path
.
join
(
section
.
clienthome
,
'Z2.pid'
)
section
.
pid_filename
=
os
.
path
.
join
(
section
.
clienthome
,
'Z2.pid'
)
if
section
.
lock_filename
is
None
:
if
section
.
lock_filename
is
None
:
section
.
lock_filename
=
os
.
path
.
join
(
section
.
clienthome
,
'Z2.lock'
)
section
.
lock_filename
=
os
.
path
.
join
(
section
.
clienthome
,
'Z2.lock'
)
if
not
section
.
databases
:
# default to a filestorage named 'Data.fs' in clienthome
from
ZODB.config
import
FileStorage
from
ZODB.config
import
ZODBDatabase
class
dummy
:
def
__init__
(
self
,
name
):
self
.
name
=
name
def
getSectionName
(
self
):
return
self
.
name
path
=
os
.
path
.
join
(
section
.
clienthome
,
'Data.fs'
)
ns
=
dummy
(
'default filestorage at %s'
%
path
)
ns
.
path
=
path
ns
.
create
=
None
ns
.
read_only
=
None
ns
.
quota
=
None
storage
=
FileStorage
(
ns
)
ns2
=
dummy
(
'default zodb database using filestorage at %s'
%
path
)
ns2
.
storage
=
storage
ns2
.
cache_size
=
5000
ns2
.
pool_size
=
7
ns2
.
version_pool_size
=
3
ns2
.
version_cache_size
=
100
ns2
.
mount_points
=
[
'/'
]
section
.
databases
=
[
ZODBDatabase
(
ns2
)]
section
.
db_mount_tab
=
db_mount_tab
=
{}
section
.
db_name_tab
=
db_name_tab
=
{}
dup_err
=
(
'Invalid configuration: ZODB databases named "%s" and "%s" are '
'both configured to use the same mount point, named "%s"'
)
for
database
in
section
.
databases
:
mount_points
=
database
.
config
.
mount_points
name
=
database
.
config
.
getSectionName
()
db_name_tab
[
name
]
=
database
for
point
in
mount_points
:
if
db_mount_tab
.
has_key
(
point
):
raise
ConfigurationError
(
dup_err
%
(
db_mount_tab
[
point
],
name
,
point
))
db_mount_tab
[
point
]
=
name
return
section
return
section
lib/python/Zope/Startup/zopeschema.xml
View file @
2c936305
...
@@ -121,6 +121,18 @@
...
@@ -121,6 +121,18 @@
</sectiontype>
</sectiontype>
<sectiontype
name=
"zodb_db"
datatype=
"ZODB.config.ZODBDatabase"
implements=
"ZODB.database"
extends=
"zodb"
>
<description>
We need to specialize the database configuration section for Zope
only by including a (required) mount-point argument, which
is a string. A Zope ZODB database can have multiple mount points,
so this is a multikey.
</description>
<multikey
name=
"mount-point"
required=
"yes"
attribute=
"mount_points"
datatype=
".mount_point"
/>
</sectiontype>
<!-- end of type definitions -->
<!-- end of type definitions -->
<!-- schema begins -->
<!-- schema begins -->
...
@@ -261,7 +273,17 @@
...
@@ -261,7 +273,17 @@
</description>
</description>
</key>
</key>
<multisection
type=
"ZODB.database"
name=
"*"
attribute=
"databases"
/>
<multisection
type=
"ZODB.database"
name=
"+"
attribute=
"databases"
>
<description>
Zope ZODB databases must have a name, and they are required to be
referenced via the "zodb_db" database type because it is
the only kind of database definition that implements
the required mount-point argument. There is another
database sectiontype named "zodb", but it cannot be used
in the context of a proper Zope configuration (due to
lack of a mount-point).
</description>
</multisection>
<section
type=
"zoperunner"
name=
"*"
attribute=
"runner"
/>
<section
type=
"zoperunner"
name=
"*"
attribute=
"runner"
/>
...
...
skel/etc/zope.conf.in
View file @
2c936305
...
@@ -705,11 +705,11 @@ products $INSTANCE/Products
...
@@ -705,11 +705,11 @@ products $INSTANCE/Products
# port-base 1000
# port-base 1000
# Database section
# Database
(zodb_db)
section
#
#
# Description:
# Description:
# A database section allows the definition of custom database and
# A database section allows the definition of custom database and
# storage types.
The standard
# storage types.
#
#
# Influences: Zope configuration
# Influences: Zope configuration
#
#
...
@@ -719,12 +719,13 @@ products $INSTANCE/Products
...
@@ -719,12 +719,13 @@ products $INSTANCE/Products
#
#
# Example:
# Example:
#
#
# <zodb>
# <zodb
_db
>
# <filestorage>
# <filestorage>
# path $INSTANCE/var/Data.fs
# path $INSTANCE/var/Data.fs
# </filestorage>
# </filestorage>
# mount-point /
# cache-size 5000
# cache-size 5000
# pool-size 7
# pool-size 7
# version-pool-size 3
# version-pool-size 3
# version-cache-size 100
# version-cache-size 100
# </zodb>
# </zodb
_db
>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment