Chris McDonough
2011-12-15 0dab2ba3056852acc632952881e08b63d71b7dad
fix tox.ini with latest requirements for this version, backport the egg:pyramid#wsgiref and egg:pyramid#cherrypy server runners
4 files modified
170 ■■■■■ changed files
CHANGES.txt 8 ●●●●● patch | view | raw | blame | history
pyramid/paster.py 114 ●●●●● patch | view | raw | blame | history
setup.py 3 ●●●●● patch | view | raw | blame | history
tox.ini 45 ●●●●● patch | view | raw | blame | history
CHANGES.txt
@@ -12,6 +12,14 @@
1.0 (2011-01-30)
================
Features
--------
- Backport the ``egg:pyramid#wsgiref`` and ``egg:pyramid#cherrypy`` server
  runners from the 1.3 branch.  This change is to primarily allow scaffolding
  authors to rely on the wsgiref entry point for projects that are meant to
  work on both Pyramid 1.1.3 and 1.3.X.
Documentation
-------------
pyramid/paster.py
@@ -191,3 +191,117 @@
                        (IViewClassifier, request_iface, Interface),
                        IView, name='', default=None)
                    self.out(fmt % (route.name, route.pattern, view_callable))
# For paste.deploy server instantiation (egg:pyramid#wsgiref)
def wsgiref_server_runner(wsgi_app, global_conf, **kw): # pragma: no cover
    from wsgiref.simple_server import make_server
    host = kw.get('host', '0.0.0.0')
    port = int(kw.get('port', 8080))
    server = make_server(host, port, wsgi_app)
    print('Starting HTTP server on http://%s:%s' % (host, port))
    server.serve_forever()
# For paste.deploy server instantiation (egg:pyramid#cherrypy)
def cherrypy_server_runner(
        app, global_conf=None, host='127.0.0.1', port=None,
        ssl_pem=None, protocol_version=None, numthreads=None,
        server_name=None, max=None, request_queue_size=None,
        timeout=None
        ): # pragma: no cover
    """
    Entry point for CherryPy's WSGI server
    Serves the specified WSGI app via CherryPyWSGIServer.
    ``app``
        The WSGI 'application callable'; multiple WSGI applications
        may be passed as (script_name, callable) pairs.
    ``host``
        This is the ipaddress to bind to (or a hostname if your
        nameserver is properly configured).  This defaults to
        127.0.0.1, which is not a public interface.
    ``port``
        The port to run on, defaults to 8080 for HTTP, or 4443 for
        HTTPS. This can be a string or an integer value.
    ``ssl_pem``
        This an optional SSL certificate file (via OpenSSL) You can
        generate a self-signed test PEM certificate file as follows:
            $ openssl genrsa 1024 > host.key
            $ chmod 400 host.key
            $ openssl req -new -x509 -nodes -sha1 -days 365  \\
                          -key host.key > host.cert
            $ cat host.cert host.key > host.pem
            $ chmod 400 host.pem
    ``protocol_version``
        The protocol used by the server, by default ``HTTP/1.1``.
    ``numthreads``
        The number of worker threads to create.
    ``server_name``
        The string to set for WSGI's SERVER_NAME environ entry.
    ``max``
        The maximum number of queued requests. (defaults to -1 = no
        limit).
    ``request_queue_size``
        The 'backlog' argument to socket.listen(); specifies the
        maximum number of queued connections.
    ``timeout``
        The timeout in seconds for accepted connections.
    """
    is_ssl = False
    if ssl_pem:
        port = port or 4443
        is_ssl = True
    if not port:
        if ':' in host:
            host, port = host.split(':', 1)
        else:
            port = 8080
    bind_addr = (host, int(port))
    kwargs = {}
    for var_name in ('numthreads', 'max', 'request_queue_size', 'timeout'):
        var = locals()[var_name]
        if var is not None:
            kwargs[var_name] = int(var)
    from cherrypy import wsgiserver
    server = wsgiserver.CherryPyWSGIServer(bind_addr, app,
                                           server_name=server_name, **kwargs)
    server.ssl_certificate = server.ssl_private_key = ssl_pem
    if protocol_version:
        server.protocol = protocol_version
    try:
        protocol = is_ssl and 'https' or 'http'
        if host == '0.0.0.0':
            print('serving on 0.0.0.0:%s view at %s://127.0.0.1:%s' %
                  (port, protocol, port))
        else:
            print('serving on %s://%s:%s' % (protocol, host, port))
        server.start()
    except (KeyboardInterrupt, SystemExit):
        server.stop()
    return server
setup.py
@@ -86,6 +86,9 @@
        proutes=pyramid.paster:PRoutesCommand
        [console_scripts]
        bfg2pyramid = pyramid.fixers.fix_bfg_imports:main
        [paste.server_runner]
        wsgiref = pyramid.paster:wsgiref_server_runner
        cherrypy = pyramid.paster:cherrypy_server_runner
      """
      )
tox.ini
@@ -1,3 +1,4 @@
#  git commit -c 879ae2600
[tox]
envlist = 
    py24,py25,py26,py27,pypy,jython,cover
@@ -14,10 +15,50 @@
    Chameleon<1.4
    WebOb<=1.0.99
    WebTest<=1.2.99
    zope.configuration<3.8.0
[testenv:py24]
commands =
    python setup.py test -q
deps =
    Sphinx
    repoze.sphinx.autointerface
    virtualenv
    PasteDeploy<1.5
    Chameleon<1.4
    WebOb<=1.0.99
    WebTest<=1.2.99
    zope.configuration<3.8.0
    zope.schema<4.0.0
[testenv:py25]
commands =
    python setup.py test -q
deps =
    Sphinx
    repoze.sphinx.autointerface
    virtualenv
    PasteDeploy<1.5
    Chameleon<1.4
    WebOb<=1.0.99
    WebTest<=1.2.99
    zope.configuration<3.8.0
    zope.schema<4.0.0
[testenv:jython]
commands = 
   jython setup.py test -q
    jython setup.py test -q
deps =
    Sphinx
    docutils<0.8
    repoze.sphinx.autointerface
    virtualenv
    PasteDeploy<1.5
    Chameleon<1.4
    WebOb<=1.0.99
    WebTest<=1.2.99
    zope.configuration<3.8.0
    zope.schema<4.0.0
[testenv:cover]
basepython =
@@ -33,6 +74,7 @@
    Chameleon<1.4
    WebOb<=1.0.99
    WebTest<=1.2.99
    zope.configuration<3.8.0
    nose
    coverage==3.4
    nosexcover
@@ -40,4 +82,3 @@
# we separate coverage into its own testenv because a) "last run wins" wrt
# cobertura jenkins reporting and b) pypy and jython can't handle any
# combination of versions of coverage and nosexcover that i can find.