Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
ZODB
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
Nicolas Wavrant
ZODB
Commits
330d1ca7
Commit
330d1ca7
authored
Jan 09, 2003
by
Fred Drake
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revise the configuration loading to work with the new schema support
from ZConfig.
parent
c1af6815
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
45 additions
and
58 deletions
+45
-58
src/ZEO/runsvr.py
src/ZEO/runsvr.py
+45
-58
No files found.
src/ZEO/runsvr.py
View file @
330d1ca7
...
@@ -119,11 +119,13 @@ class Options:
...
@@ -119,11 +119,13 @@ class Options:
self
.
load_configuration
()
self
.
load_configuration
()
def
load_configuration
(
self
):
def
load_configuration
(
self
):
if
self
.
rootconf
or
not
self
.
configuration
:
if
not
self
.
configuration
:
return
return
c
=
ZConfig
.
Context
.
Context
()
here
=
os
.
path
.
dirname
(
sys
.
argv
[
0
])
schemafile
=
os
.
path
.
join
(
here
,
"schema.xml"
)
schema
=
ZConfig
.
loadSchema
(
schemafile
)
try
:
try
:
self
.
rootconf
=
c
.
loadURL
(
self
.
configuration
)
self
.
rootconf
=
ZConfig
.
loadConfig
(
schema
,
self
.
configuration
)[
0
]
except
ZConfig
.
ConfigurationError
,
errobj
:
except
ZConfig
.
ConfigurationError
,
errobj
:
self
.
usage
(
str
(
errobj
))
self
.
usage
(
str
(
errobj
))
...
@@ -148,9 +150,9 @@ class Options:
...
@@ -148,9 +150,9 @@ class Options:
class
ZEOOptions
(
Options
):
class
ZEOOptions
(
Options
):
hostname
=
None
# A subclass may set this
hostname
=
None
# A subclass may set this
hostconf
=
None
# <Host> section
read_only
=
None
zeoconf
=
None
# <ZEO> section
transaction_timeout
=
None
logconf
=
None
# <Log> section
invalidation_queue_size
=
None
family
=
None
# set by -a; AF_UNIX or AF_INET
family
=
None
# set by -a; AF_UNIX or AF_INET
address
=
None
# set by -a; string or (host, port)
address
=
None
# set by -a; string or (host, port)
...
@@ -183,11 +185,22 @@ class ZEOOptions(Options):
...
@@ -183,11 +185,22 @@ class ZEOOptions(Options):
self
.
usage
(
"invalid port number: %r"
%
port
)
self
.
usage
(
"invalid port number: %r"
%
port
)
self
.
address
=
(
host
,
port
)
self
.
address
=
(
host
,
port
)
elif
opt
in
(
"-f"
,
"--filename"
):
elif
opt
in
(
"-f"
,
"--filename"
):
from
ZODB.FileStorage
import
FileStorage
from
ZODB.config
import
FileStorage
class
FSConfig
:
def
__init__
(
self
,
name
,
path
):
self
.
_name
=
name
self
.
path
=
path
self
.
create
=
0
self
.
read_only
=
0
self
.
stop
=
None
self
.
quota
=
None
def
getSectionName
(
self
):
return
self
.
_name
if
not
self
.
storages
:
if
not
self
.
storages
:
self
.
storages
=
{}
self
.
storages
=
{}
key
=
str
(
1
+
len
(
self
.
storages
))
key
=
str
(
1
+
len
(
self
.
storages
))
self
.
storages
[
key
]
=
(
FileStorage
,
{
"file_name"
:
arg
})
conf
=
FSConfig
(
key
,
arg
)
self
.
storages
[
key
]
=
FileStorage
(
conf
)
else
:
else
:
# Pass it to the base class, for --help/-h
# Pass it to the base class, for --help/-h
Options
.
handle_option
(
self
,
opt
,
arg
)
Options
.
handle_option
(
self
,
opt
,
arg
)
...
@@ -205,20 +218,6 @@ class ZEOOptions(Options):
...
@@ -205,20 +218,6 @@ class ZEOOptions(Options):
Options
.
load_configuration
(
self
)
# Sets self.rootconf
Options
.
load_configuration
(
self
)
# Sets self.rootconf
if
not
self
.
rootconf
:
if
not
self
.
rootconf
:
return
return
try
:
self
.
hostconf
=
self
.
rootconf
.
getSection
(
"Host"
)
except
ZConfig
.
ConfigurationConflictingSectionError
:
if
not
self
.
hostname
:
self
.
hostname
=
socket
.
getfqdn
()
self
.
hostconf
=
self
.
rootconf
.
getSection
(
"Host"
,
self
.
hostname
)
if
self
.
hostconf
is
None
:
# If no <Host> section exists, fall back to the root
self
.
hostconf
=
self
.
rootconf
self
.
zeoconf
=
self
.
hostconf
.
getSection
(
"ZEO"
)
if
self
.
zeoconf
is
None
:
# If no <ZEO> section exists, fall back to the host (or root)
self
.
zeoconf
=
self
.
hostconf
self
.
logconf
=
self
.
hostconf
.
getSection
(
"Log"
)
# Now extract options from various configuration sections
# Now extract options from various configuration sections
self
.
load_zeoconf
()
self
.
load_zeoconf
()
...
@@ -226,39 +225,29 @@ class ZEOOptions(Options):
...
@@ -226,39 +225,29 @@ class ZEOOptions(Options):
self
.
load_storages
()
self
.
load_storages
()
def
load_zeoconf
(
self
):
def
load_zeoconf
(
self
):
# Get some option defaults from the configuration
# Get some option values from the configuration
if
self
.
family
:
if
self
.
family
is
None
:
# -a option overrides
self
.
family
=
self
.
rootconf
.
address
.
family
return
self
.
address
=
self
.
rootconf
.
address
.
address
port
=
self
.
zeoconf
.
getint
(
"server-port"
)
path
=
self
.
zeoconf
.
get
(
"path"
)
self
.
read_only
=
self
.
rootconf
.
read_only
if
port
and
path
:
self
.
transaction_timeout
=
self
.
rootconf
.
transaction_timeout
self
.
usage
(
self
.
invalidation_queue_size
=
self
.
rootconf
.
invalidation_queue_size
"Configuration contains conflicting ZEO information:
\
n
"
"Exactly one of 'path' and 'server-port' may be given."
)
if
port
:
host
=
self
.
hostconf
.
get
(
"hostname"
,
""
)
self
.
family
=
socket
.
AF_INET
self
.
address
=
(
host
,
port
)
elif
path
:
self
.
family
=
socket
.
AF_UNIX
self
.
address
=
path
def
load_logconf
(
self
):
def
load_logconf
(
self
):
# Get logging options from conf, unless overridden by environment
# Get logging options from conf, unless overridden by environment
if
not
self
.
logconf
:
# XXX This still needs to be supported in the config schema.
return
reinit
=
0
reinit
=
0
if
os
.
getenv
(
"EVENT_LOG_FILE"
)
is
None
:
if
os
.
getenv
(
"EVENT_LOG_FILE"
)
is
None
:
if
os
.
getenv
(
"STUPID_LOG_FILE"
)
is
None
:
if
os
.
getenv
(
"STUPID_LOG_FILE"
)
is
None
:
path
=
self
.
logconf
.
get
(
"path"
)
path
=
None
#
self.logconf.get("path")
if
path
is
not
None
:
if
path
is
not
None
:
os
.
environ
[
"EVENT_LOG_FILE"
]
=
path
os
.
environ
[
"EVENT_LOG_FILE"
]
=
path
os
.
environ
[
"STUPID_LOG_FILE"
]
=
path
os
.
environ
[
"STUPID_LOG_FILE"
]
=
path
reinit
=
1
reinit
=
1
if
os
.
getenv
(
"EVENT_LOG_SEVERITY"
)
is
None
:
if
os
.
getenv
(
"EVENT_LOG_SEVERITY"
)
is
None
:
if
os
.
getenv
(
"STUPID_LOG_SEVERITY"
)
is
None
:
if
os
.
getenv
(
"STUPID_LOG_SEVERITY"
)
is
None
:
level
=
self
.
logconf
.
get
(
"level"
)
level
=
None
#
self.logconf.get("level")
if
level
is
not
None
:
if
level
is
not
None
:
os
.
environ
[
"EVENT_LOG_SEVERITY"
]
=
level
os
.
environ
[
"EVENT_LOG_SEVERITY"
]
=
level
os
.
environ
[
"STUPID_LOG_SEVERITY"
]
=
level
os
.
environ
[
"STUPID_LOG_SEVERITY"
]
=
level
...
@@ -271,17 +260,10 @@ class ZEOOptions(Options):
...
@@ -271,17 +260,10 @@ class ZEOOptions(Options):
if
self
.
storages
:
if
self
.
storages
:
# -f option overrides
# -f option overrides
return
return
storagesections
=
self
.
zeoconf
.
getChildSections
(
"Storage"
)
self
.
storages
=
{}
self
.
storages
=
{}
import
ZODB.StorageConfig
for
opener
in
self
.
rootconf
.
storages
:
for
section
in
storagesections
:
self
.
storages
[
opener
.
name
]
=
opener
name
=
section
.
name
if
not
name
:
name
=
str
(
1
+
len
(
self
.
storages
))
if
self
.
storages
.
has_key
(
name
):
# (Actually, the parser doesn't allow this)
self
.
usage
(
"duplicate storage name %r"
%
name
)
self
.
storages
[
name
]
=
ZODB
.
StorageConfig
.
getStorageInfo
(
section
)
class
ZEOServer
:
class
ZEOServer
:
...
@@ -329,10 +311,10 @@ class ZEOServer:
...
@@ -329,10 +311,10 @@ class ZEOServer:
def
open_storages
(
self
):
def
open_storages
(
self
):
self
.
storages
=
{}
self
.
storages
=
{}
for
name
,
(
cls
,
args
)
in
self
.
options
.
storages
.
items
():
for
name
,
opener
in
self
.
options
.
storages
.
items
():
info
(
"open
storage %r: %s.%s(**%r)"
%
info
(
"open
ing storage %r using %s"
(
name
,
cls
.
__module__
,
cls
.
__name__
,
args
))
%
(
name
,
opener
.
__class__
.
__name__
))
self
.
storages
[
name
]
=
cls
(
**
args
)
self
.
storages
[
name
]
=
opener
.
open
(
)
def
setup_signals
(
self
):
def
setup_signals
(
self
):
"""Set up signal handlers.
"""Set up signal handlers.
...
@@ -356,7 +338,12 @@ class ZEOServer:
...
@@ -356,7 +338,12 @@ class ZEOServer:
def
create_server
(
self
):
def
create_server
(
self
):
from
ZEO.StorageServer
import
StorageServer
from
ZEO.StorageServer
import
StorageServer
self
.
server
=
StorageServer
(
self
.
options
.
address
,
self
.
storages
)
self
.
server
=
StorageServer
(
self
.
options
.
address
,
self
.
storages
,
read_only
=
self
.
options
.
read_only
,
invalidation_queue_size
=
self
.
options
.
invalidation_queue_size
,
transaction_timeout
=
self
.
options
.
transaction_timeout
)
def
loop_forever
(
self
):
def
loop_forever
(
self
):
import
ThreadedAsync.LoopCallback
import
ThreadedAsync.LoopCallback
...
...
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