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
04ab51de
Commit
04ab51de
authored
Aug 07, 2016
by
Hanno Schlichting
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Simplify ZopeWSGIOptions and drop dependency on zdaemon.
parent
95d7a661
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
31 additions
and
38 deletions
+31
-38
setup.py
setup.py
+0
-1
src/Zope2/Startup/options.py
src/Zope2/Startup/options.py
+20
-5
src/Zope2/Startup/run.py
src/Zope2/Startup/run.py
+2
-10
src/Zope2/Startup/tests/test_schema.py
src/Zope2/Startup/tests/test_schema.py
+6
-12
src/Zope2/Startup/tests/test_starter.py
src/Zope2/Startup/tests/test_starter.py
+2
-7
src/Zope2/utilities/finder.py
src/Zope2/utilities/finder.py
+1
-3
No files found.
setup.py
View file @
04ab51de
...
...
@@ -67,7 +67,6 @@ setup(
'setuptools'
,
'transaction'
,
'waitress'
,
'zdaemon'
,
'zExceptions >= 3.2'
,
'zope.browser'
,
'zope.browsermenu'
,
...
...
src/Zope2/Startup/options.py
View file @
04ab51de
...
...
@@ -15,9 +15,8 @@
import
os
import
xml.sax
from
ZConfig.loader
import
SchemaLoader
from
ZConfig.loader
import
ConfigLoader
,
SchemaLoader
from
ZConfig.schema
import
SchemaParser
from
zdaemon.zdoptions
import
ZDOptions
from
zope.deferredimport
import
deprecated
# BBB Zope 5.0
...
...
@@ -48,13 +47,19 @@ class ConditionalSchemaParser(SchemaParser):
SchemaParser
.
start_import
(
self
,
attrs
)
class
ZopeWSGIOptions
(
ZDOptions
):
"""
zdaemon based ZopeWSGIOptions to parse a ZConfig schema
.
class
ZopeWSGIOptions
(
object
):
"""
ZopeWSGIOptions parses a ZConfig schema and config file
.
"""
configfile
=
None
confighandlers
=
None
configroot
=
None
schema
=
None
schemadir
=
os
.
path
.
dirname
(
os
.
path
.
abspath
(
__file__
))
schemafile
=
'wsgischema.xml'
def
__init__
(
self
,
configfile
=
None
):
self
.
configfile
=
configfile
def
load_schema
(
self
):
if
self
.
schema
is
None
:
# Load schema
...
...
@@ -75,3 +80,13 @@ class ZopeWSGIOptions(ZDOptions):
self
.
schema
=
parser
.
_schema
finally
:
resource
.
close
()
def
load_configfile
(
self
):
loader
=
ConfigLoader
(
self
.
schema
)
self
.
configroot
,
self
.
confighandlers
=
loader
.
loadURL
(
self
.
configfile
)
def
__call__
(
self
):
self
.
load_schema
()
self
.
load_configfile
()
return
self
src/Zope2/Startup/run.py
View file @
04ab51de
...
...
@@ -43,13 +43,7 @@ def _set_wsgi_config(configfile=None):
Optionally accept a configfile argument (string path) in order
to specify where the configuration file exists. """
from
Zope2.Startup
import
options
,
handlers
opts
=
options
.
ZopeWSGIOptions
()
if
configfile
:
opts
.
configfile
=
configfile
opts
.
realize
(
raise_getopt_errs
=
0
)
else
:
opts
.
realize
()
opts
=
options
.
ZopeWSGIOptions
(
configfile
=
configfile
)()
handlers
.
handleWSGIConfig
(
opts
.
configroot
,
opts
.
confighandlers
)
import
App.config
App
.
config
.
setConfiguration
(
opts
.
configroot
)
...
...
@@ -63,9 +57,7 @@ def make_wsgi_app(global_config, zope_conf):
from
Zope2.Startup.options
import
ZopeWSGIOptions
from
ZPublisher.WSGIPublisher
import
publish_module
starter
=
get_wsgi_starter
()
opts
=
ZopeWSGIOptions
()
opts
.
configfile
=
zope_conf
opts
.
realize
(
args
=
(),
progname
=
'Zope2WSGI'
,
raise_getopt_errs
=
False
)
opts
=
ZopeWSGIOptions
(
configfile
=
zope_conf
)()
handleWSGIConfig
(
opts
.
configroot
,
opts
.
confighandlers
)
setConfiguration
(
opts
.
configroot
)
starter
.
setConfiguration
(
opts
.
configroot
)
...
...
src/Zope2/Startup/tests/test_schema.py
View file @
04ab51de
...
...
@@ -21,38 +21,32 @@ import ZConfig
from
Zope2.Startup.options
import
ZopeWSGIOptions
_SCHEMA
=
{}
_SCHEMA
=
None
TEMPNAME
=
tempfile
.
mktemp
()
TEMPVAR
=
os
.
path
.
join
(
TEMPNAME
,
"var"
)
def
getSchema
(
schemafile
):
def
getSchema
():
global
_SCHEMA
if
schemafile
not
in
_SCHEMA
:
if
_SCHEMA
is
None
:
opts
=
ZopeWSGIOptions
()
opts
.
schemafile
=
schemafile
opts
.
load_schema
()
_SCHEMA
[
schemafile
]
=
opts
.
schema
return
_SCHEMA
[
schemafile
]
_SCHEMA
=
opts
.
schema
return
_SCHEMA
class
WSGIStartupTestCase
(
unittest
.
TestCase
):
@
property
def
schema
(
self
):
return
getSchema
(
'wsgischema.xml'
)
def
load_config_text
(
self
,
text
):
# We have to create a directory of our own since the existence
# of the directory is checked. This handles this in a
# platform-independent way.
schema
=
self
.
schema
sio
=
cStringIO
.
StringIO
(
text
.
replace
(
"<<INSTANCE_HOME>>"
,
TEMPNAME
))
os
.
mkdir
(
TEMPNAME
)
os
.
mkdir
(
TEMPVAR
)
try
:
conf
,
handler
=
ZConfig
.
loadConfigFile
(
schema
,
sio
)
conf
,
handler
=
ZConfig
.
loadConfigFile
(
getSchema
()
,
sio
)
finally
:
os
.
rmdir
(
TEMPVAR
)
os
.
rmdir
(
TEMPNAME
)
...
...
src/Zope2/Startup/tests/test_starter.py
View file @
04ab51de
...
...
@@ -27,11 +27,10 @@ from Zope2.Startup.options import ZopeWSGIOptions
_SCHEMA
=
None
def
getSchema
(
schemafile
):
def
getSchema
():
global
_SCHEMA
if
_SCHEMA
is
None
:
opts
=
ZopeWSGIOptions
()
opts
.
schemafile
=
schemafile
opts
.
load_schema
()
_SCHEMA
=
opts
.
schema
return
_SCHEMA
...
...
@@ -39,10 +38,6 @@ def getSchema(schemafile):
class
WSGIStarterTestCase
(
unittest
.
TestCase
):
@
property
def
schema
(
self
):
return
getSchema
(
'wsgischema.xml'
)
def
setUp
(
self
):
self
.
TEMPNAME
=
tempfile
.
mktemp
()
...
...
@@ -66,7 +61,7 @@ class WSGIStarterTestCase(unittest.TestCase):
if
why
==
17
:
# already exists
pass
conf
,
self
.
handler
=
ZConfig
.
loadConfigFile
(
self
.
schema
,
sio
)
conf
,
self
.
handler
=
ZConfig
.
loadConfigFile
(
getSchema
()
,
sio
)
self
.
assertEqual
(
conf
.
instancehome
,
self
.
TEMPNAME
)
return
conf
...
...
src/Zope2/utilities/finder.py
View file @
04ab51de
...
...
@@ -30,9 +30,7 @@ class ZopeFinder(object):
from
Zope2.Startup
import
options
,
handlers
import
App.config
import
Zope2
opts
=
options
.
ZopeWSGIOptions
()
opts
.
configfile
=
config_file
opts
.
realize
(
args
=
[],
doc
=
""
,
raise_getopt_errs
=
0
)
opts
=
options
.
ZopeWSGIOptions
(
configfile
=
config_file
)()
handlers
.
handleWSGIConfig
(
opts
.
configroot
,
opts
.
confighandlers
)
App
.
config
.
setConfiguration
(
opts
.
configroot
)
app
=
Zope2
.
app
()
...
...
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