Zine

open source content publishing system


Changeset 909:423e80aa13a9


Ignore:
Timestamp:
01/06/09 03:43:23 (3 years ago)
Author:
mitsuhiko
Branch:
default
Message:

Added support for BEHIND_PROXY and documented environment variables in the README file of the servers.

Files:
7 edited

Legend:

Unmodified
Added
Removed
  • servers/README

    r465 r909  
    2222Just take the file of choice, copy it to where you want it to be and 
    2323adjust it. 
     24 
     25All this files have some variables you can configure and invoke the 
     26actual handler code.  Variables written in uppercase are there for 
     27you to change if you want. 
     28 
     29Some of these can be set from the process environment as well (for 
     30example via the apache `SetEnv` directive) if you prefix them with 
     31``ZINE_``.  This works for the following keys: 
     32 
     33`POOL_SIZE` 
     34    The size of the pool to be maintained.  This is the largest number 
     35    of connections that will be kept persistently in the pool.  Note 
     36    that the pool begins with no connections; once this number of 
     37    connections is requested, that number of connections will remain. 
     38    Defaults to 5. 
     39    If you are deploying Zine in a forking environment you want to set 
     40    this number to 1 or 2. 
     41 
     42`POOL_RECYCLE` 
     43    If set to non -1, number of seconds between connection recycling, 
     44    which means upon checkout, if this timeout is surpassed the 
     45    connection will be closed and replaced with a newly opened 
     46    connection.  Defaults to -1. 
     47 
     48`POOL_TIMEOUT` 
     49    The number of seconds to wait before giving up on returning a 
     50    connection.  Defaults to 30. 
     51 
     52`BEHIND_PROXY` 
     53    If you are proxying into Zine somehow (caching proxies or external 
     54    fastcgi/http servers) set this value to True to enable proxy support. 
     55    Do not set this to True if you are not using proxies as this would 
     56    be a security risk. 
     57    If you specify this value from the process environment use the values 
     58    ``1`` and ``0`` instead of ``True`` and ``False``. 
  • servers/zine.cgi

    r661 r909  
    66 
    77    Run Zine as CGI. Requires python 2.5 or python 2.4 with 
    8     the wsgiref module installed. 
     8    the wsgiref module installed.  For help con configuration 
     9    have a look at the README file. 
    910 
    10     :copyright: 2008 by Armin Ronacher. 
     11    :copyright: (c) 2009 by the Zine Team, see AUTHORS for more details. 
    1112    :license: BSD, see LICENSE for more details. 
    1213""" 
     
    2021ZINE_LIB = '/usr/lib/zine' 
    2122 
     23# these values can be use to override database pool settings. 
     24# see deployment guide for more details. 
     25POOL_SIZE = None 
     26POOL_RECYCLE = None 
     27POOL_TIMEOUT = None 
     28 
     29# if you are proxying into zine somehow (caching proxies or external 
     30# fastcgi servers) set this value to True to enable proxy support.  Do 
     31# not set this to True if you are not using proxies as this would be a 
     32# security risk. 
     33BEHIND_PROXY = None 
     34 
    2235# enable this to enable an internal CGI debugging feature. 
    2336CGI_DEBUG = False 
    2437 
    2538 
     39# ---------------------------------------------------------------------------- 
    2640# here you can further configure the wsgi app settings but usually you don't 
    2741# have to touch them 
     
    3347sys.path.insert(0, ZINE_LIB) 
    3448 
    35 from zine import get_wsgi_app 
     49from zine import get_wsgi_app, override_environ_config 
    3650from wsgiref.handlers import CGIHandler 
     51override_environ_config(POOL_SIZE, POOL_RECYCLE, POOL_TIMEOUT, BEHIND_PROXY) 
    3752app = get_wsgi_app(INSTANCE_FOLDER) 
    3853 
  • servers/zine.fcgi

    r688 r909  
    88    For working FastCGI support you have to have flup installed. 
    99 
    10     :copyright: 2008 by Armin Ronacher. 
     10    For help on configuration have a look at the README file. 
     11 
     12    :copyright: (c) 2009 by the Zine Team, see AUTHORS for more details. 
    1113    :license: BSD, see LICENSE for more details. 
    1214""" 
     
    2628POOL_TIMEOUT = None 
    2729 
     30# if you are proxying into zine somehow (caching proxies or external 
     31# fastcgi servers) set this value to True to enable proxy support.  Do 
     32# not set this to True if you are not using proxies as this would be a 
     33# security risk. 
     34BEHIND_PROXY = None 
     35 
    2836# ---------------------------------------------------------------------------- 
    2937# here you can further configure the fastcgi and wsgi app settings 
    3038# but usually you don't have to touch them. 
    3139import sys 
    32 import os 
    33  
    3440sys.path.insert(0, ZINE_LIB) 
    3541 
    36 for key in 'POOL_SIZE', 'POOL_RECYCLE', 'POOL_TIMEOUT': 
    37     value = locals().get(key) 
    38     if value is not None: 
    39         os.environ['ZINE_DATABASE_' + key] = value 
    40  
    41 from zine import get_wsgi_app 
     42from zine import get_wsgi_app, override_environ_config 
    4243from flup.server.fcgi import WSGIServer 
     44override_environ_config(POOL_SIZE, POOL_RECYCLE, POOL_TIMEOUT, BEHIND_PROXY) 
    4345app = get_wsgi_app(INSTANCE_FOLDER) 
    4446srv = WSGIServer(app) 
  • servers/zine.wsgi

    r688 r909  
    22""" 
    33    Zine mod_wsgi Runner 
    4     ~~~~~~~~~~~~~~~~~~~~~~~~~ 
     4    ~~~~~~~~~~~~~~~~~~~~ 
    55 
    6     Run Zine in mod_wsgi. 
     6    Run Zine in mod_wsgi.  For help on configuration have a look at the 
     7    README file. 
    78 
    8     :copyright: 2008 by Armin Ronacher. 
     9    :copyright: (c) 2009 by the Zine Team, see AUTHORS for more details. 
    910    :license: BSD, see LICENSE for more details. 
    1011""" 
     
    2425POOL_TIMEOUT = None 
    2526 
     27# if you are proxying into zine somehow (caching proxies or external 
     28# fastcgi servers) set this value to True to enable proxy support.  Do 
     29# not set this to True if you are not using proxies as this would be a 
     30# security risk. 
     31BEHIND_PROXY = None 
     32 
     33# ---------------------------------------------------------------------------- 
    2634# here you can further configure the wsgi app settings but usually you don't 
    2735# have to touch them 
     
    3139    sys.path.insert(0, ZINE_LIB) 
    3240 
    33 for key in 'POOL_SIZE', 'POOL_RECYCLE', 'POOL_TIMEOUT': 
    34     value = locals().get(key) 
    35     if value is not None: 
    36         os.environ['ZINE_DATABASE_' + key] = value 
    37  
    38 from zine import get_wsgi_app 
     41from zine import get_wsgi_app, override_environ_config 
     42from flup.server.fcgi import WSGIServer 
     43override_environ_config(POOL_SIZE, POOL_RECYCLE, POOL_TIMEOUT, BEHIND_PROXY) 
    3944application = get_wsgi_app(INSTANCE_FOLDER) 
  • zine/__init__.py

    r873 r909  
    3434# the core module is *not* reloaded, thus stuff will get lost if it's not 
    3535# properly listed. 
    36 from zine._core import setup, get_wsgi_app 
    37 __all__ = ('setup', 'get_wsgi_app') 
     36from zine._core import setup, get_wsgi_app, override_environ_config 
     37__all__ = ('setup', 'get_wsgi_app', 'override_environ_config') 
  • zine/_core.py

    r873 r909  
    1010""" 
    1111 
     12import os 
    1213from thread import allocate_lock 
    1314from time import time, sleep 
     
    141142        return app(environ, start_response) 
    142143    return application 
     144 
     145 
     146def override_environ_config(pool_size=None, pool_recycle=None, 
     147                            pool_timeout=None, behind_proxy=None): 
     148    """Some configuration parameters are not stored in the zine.ini but 
     149    in the os environment.  These are process wide configuration settings 
     150    used for different deployments. 
     151    """ 
     152    for key, value in locals().items(): 
     153        if value is not None: 
     154            if key == 'behind_proxy': 
     155                value = int(bool(value)) 
     156            os.environ['ZINE_' + key.upper()] = str(value) 
  • zine/application.py

    r889 r909  
    1111    :license: BSD, see LICENSE for more details. 
    1212""" 
    13 from os import path, remove, makedirs, walk 
     13from os import path, remove, makedirs, walk, environ 
    1414from time import time 
    1515from itertools import izip 
     
    232232    """This class holds the incoming request data.""" 
    233233 
     234 
    234235    def __init__(self, environ, app=None): 
    235236        RequestBase.__init__(self, environ) 
     
    255256        self.user = user 
    256257        self.session = session 
     258 
     259    @property 
     260    def is_behind_proxy(self): 
     261        """Are we behind a proxy?""" 
     262        return environ.get('ZINE_BEHIND_PROXY') == '1' 
    257263 
    258264    def login(self, user, permanent=False): 
Note: See TracChangeset for help on using the changeset viewer.