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
953c1ee6
Commit
953c1ee6
authored
Apr 30, 2006
by
Lennart Regebro
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Twisted support.
parent
7abca36a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
76 additions
and
10 deletions
+76
-10
lib/python/Zope2/Startup/__init__.py
lib/python/Zope2/Startup/__init__.py
+14
-7
lib/python/Zope2/Startup/handlers.py
lib/python/Zope2/Startup/handlers.py
+54
-3
lib/python/Zope2/Startup/zopeschema.xml
lib/python/Zope2/Startup/zopeschema.xml
+8
-0
No files found.
lib/python/Zope2/Startup/__init__.py
View file @
953c1ee6
...
...
@@ -20,12 +20,11 @@ import sys
import
socket
from
re
import
compile
from
socket
import
gethostbyaddr
import
twisted.internet.reactor
import
ZConfig
from
ZConfig.components.logger
import
loghandler
logger
=
logging
.
getLogger
(
"Zope"
)
started
=
False
...
...
@@ -96,7 +95,10 @@ class ZopeStarter:
self
.
makePidFile
()
self
.
setupInterpreter
()
self
.
startZope
()
self
.
registerSignals
()
from
App.config
import
getConfiguration
config
=
getConfiguration
()
if
not
config
.
twisted_servers
:
self
.
registerSignals
()
# emit a "ready" message in order to prevent the kinds of emails
# to the Zope maillist in which people claim that Zope has "frozen"
# after it has emitted ZServer messages.
...
...
@@ -106,10 +108,15 @@ class ZopeStarter:
def
run
(
self
):
# the mainloop.
try
:
import
ZServer
import
Lifetime
Lifetime
.
loop
()
sys
.
exit
(
ZServer
.
exit_code
)
from
App.config
import
getConfiguration
config
=
getConfiguration
()
if
config
.
twisted_servers
:
twisted
.
internet
.
reactor
.
run
()
else
:
import
ZServer
import
Lifetime
Lifetime
.
loop
()
sys
.
exit
(
ZServer
.
exit_code
)
finally
:
self
.
shutdown
()
...
...
lib/python/Zope2/Startup/handlers.py
View file @
953c1ee6
import
os
import
sys
import
time
import
logging
from
re
import
compile
from
socket
import
gethostbyaddr
import
twisted.internet
from
twisted.application.service
import
MultiService
import
zope.app.appsetup.interfaces
import
zope.app.twisted.main
# top-level key handlers
...
...
@@ -133,7 +140,7 @@ def catalog_getObject_raises(value):
"'catalog-getObject-raises' option will be removed in Zope 2.10:
\
n
"
,
DeprecationWarning
)
from
Products.ZCatalog
import
CatalogBrains
from
Products.ZCatalog
import
CatalogBrains
CatalogBrains
.
GETOBJECT_RAISES
=
bool
(
value
)
return
value
...
...
@@ -143,7 +150,8 @@ def catalog_getObject_raises(value):
def
root_handler
(
config
):
""" Mutate the configuration with defaults and perform
fixups of values that require knowledge about configuration
values outside of their context. """
values outside of their context.
"""
# Set environment variables
for
k
,
v
in
config
.
environment
.
items
():
...
...
@@ -165,7 +173,7 @@ def root_handler(config):
instanceprod
=
os
.
path
.
join
(
config
.
instancehome
,
'Products'
)
if
instanceprod
not
in
config
.
products
:
config
.
products
.
append
(
instanceprod
)
import
Products
L
=
[]
for
d
in
config
.
products
+
Products
.
__path__
:
...
...
@@ -190,6 +198,23 @@ def root_handler(config):
config
.
cgi_environment
,
config
.
port_base
)
if
not
config
.
twisted_servers
:
config
.
twisted_servers
=
[]
else
:
# Set number of threads (reuse zserver_threads variable)
twisted
.
internet
.
reactor
.
suggestThreadPoolSize
(
config
.
zserver_threads
)
# Create a root service
rootService
=
MultiService
()
for
server
in
config
.
twisted_servers
:
service
=
server
.
create
(
None
)
service
.
setServiceParent
(
rootService
)
rootService
.
startService
()
twisted
.
internet
.
reactor
.
addSystemEventTrigger
(
'before'
,
'shutdown'
,
rootService
.
stopService
)
# set up trusted proxies
if
config
.
trusted_proxies
:
import
ZPublisher.HTTPRequest
...
...
@@ -217,3 +242,29 @@ def _name2Ips(host, isIp_=compile(r'(\d+\.){3}').match):
if
isIp_
(
host
):
return
[
host
]
return
gethostbyaddr
(
host
)[
2
]
# XXX Need to find a better place for this.
import
twisted.web2.wsgi
import
twisted.web2.server
import
twisted.web2.log
try
:
from
twisted.web2.http
import
HTTPFactory
except
ImportError
:
from
twisted.web2.channel.http
import
HTTPFactory
from
zope.component
import
provideUtility
from
zope.app.twisted.server
import
ServerType
,
SSLServerType
from
zope.app.twisted.interfaces
import
IServerType
from
ZPublisher.WSGIPublisher
import
publish_module
def
createHTTPFactory
(
ignored
):
resource
=
twisted
.
web2
.
wsgi
.
WSGIResource
(
publish_module
)
resource
=
twisted
.
web2
.
log
.
LogWrapperResource
(
resource
)
return
HTTPFactory
(
twisted
.
web2
.
server
.
Site
(
resource
))
http
=
ServerType
(
createHTTPFactory
,
8080
)
provideUtility
(
http
,
IServerType
,
'Zope2-HTTP'
)
lib/python/Zope2/Startup/zopeschema.xml
View file @
953c1ee6
...
...
@@ -11,6 +11,12 @@
<import
package=
"tempstorage"
/>
<import
package=
"Zope2.Startup"
file=
"warnfilter.xml"
/>
<sectiontype
name=
"server"
datatype=
"zope.app.twisted.server.ServerFactory"
>
<key
name=
"type"
required=
"yes"
/>
<key
name=
"address"
datatype=
"inet-address"
/>
<key
name=
"backlog"
datatype=
"integer"
default=
"50"
/>
</sectiontype>
<sectiontype
name=
"logger"
datatype=
".LoggerFactory"
>
<description>
This "logger" type only applies to access and request ("trace")
...
...
@@ -805,7 +811,9 @@
<metadefault>
on
</metadefault>
</key>
<multisection
type=
"server"
name=
"*"
attribute=
"twisted_servers"
/>
<multisection
type=
"ZServer.server"
name=
"*"
attribute=
"servers"
/>
<key
name=
"port-base"
datatype=
"integer"
default=
"0"
>
<description>
Base port number that gets added to the specific port numbers
...
...
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