-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add shop.tac to be able to start zope with twisted.
- Loading branch information
Showing
1 changed file
with
35 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
############################################################################## | ||
# Start zope with twisted WSGI server | ||
# | ||
# Install required python packages with pip: | ||
# | ||
# ./venv/bin/pip install twisted plaster plaster_pastedeploy | ||
# | ||
# Start zope: | ||
# | ||
# ./venv/bin/twistd -ny shop.tac | ||
############################################################################## | ||
|
||
from twisted.application import internet | ||
from twisted.application import service | ||
from twisted.internet import reactor | ||
from twisted.web.server import Site | ||
from twisted.web.wsgi import WSGIResource | ||
import os | ||
import plaster | ||
|
||
config='./instance/etc/zope.ini' | ||
config = os.path.abspath(config) | ||
port = 8081 | ||
|
||
# Get the WSGI application | ||
loader = plaster.get_loader(config, protocols=['wsgi']) | ||
app = loader.get_wsgi_app('main') | ||
|
||
# Twisted WSGI server setup | ||
resource = WSGIResource(reactor, reactor.getThreadPool(), app) | ||
factory = Site(resource) | ||
|
||
# Twisted Application setup | ||
application = service.Application('zope') | ||
internet.TCPServer(port, factory).setServiceParent(application) |