-
Notifications
You must be signed in to change notification settings - Fork 15
/
shop.tac
39 lines (33 loc) · 1.11 KB
/
shop.tac
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
##############################################################################
# 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
##############################################################################
# use asyncio main loop in twisted
from twisted.internet import asyncioreactor
asyncioreactor.install()
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)