From 0f1530e2bf7bc85845ba7e388e2b2921f1381eab Mon Sep 17 00:00:00 2001 From: Matthias Jahn Date: Tue, 1 Jan 2013 22:32:18 +0100 Subject: [PATCH 2/4] - add swat prefix - rework deployment skript - add swat.__call__ wrapper for use in wsgi server --- development.ini | 4 ++++ swat/__init__.py | 34 ++++++++++++++++++++++++++++++++++ swat/config/deployment.ini_tmpl | 22 +++++++++++++++++++--- 3 files changed, 57 insertions(+), 3 deletions(-) diff --git a/development.ini b/development.ini index d686692..92fd72e 100644 --- a/development.ini +++ b/development.ini @@ -52,7 +52,11 @@ beaker.session.secret = somesecret # Debug mode will enable the interactive debugging tool, allowing ANYONE to # execute malicious code after an exception is raised. #set debug = false +filter-with = proxy-prefix +[filter:proxy-prefix] +use = egg:PasteDeploy#prefix +prefix = /swat # Logging configuration [loggers] diff --git a/swat/__init__.py b/swat/__init__.py index e69de29..53d2f63 100644 --- a/swat/__init__.py +++ b/swat/__init__.py @@ -0,0 +1,34 @@ +# startup wrapper for swat +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# + +def __call__(environ, start_response): + import os, sys + swat_dir=os.path.abspath(os.path.join(os.path.dirname(__file__), os.path.pardir)) + swat_helpers=os.path.join(swat_dir,'swat','lib','helpers') + sys.path.append(swat_dir) + sys.path.append(swat_helpers) + from paste.deploy import loadapp, loadserver + + #after you installed the swat app with: + #"./setup.py install" + #you need to create a config with: + #"paster make-config swat swat2.ini" and put it in your prefered location + #for example /usr/local/samba/etc + #!!within the file you have to setup a chache_dir and a dir usfull for session data!! + #you have to change the location and filename for your needs + wsgi_app = loadapp('config:swat2.ini', relative_to='/usr/local/samba/etc') + return wsgi_app.__call__(environ, start_response) + diff --git a/swat/config/deployment.ini_tmpl b/swat/config/deployment.ini_tmpl index 0ff7963..96f3fd4 100644 --- a/swat/config/deployment.ini_tmpl +++ b/swat/config/deployment.ini_tmpl @@ -22,11 +22,22 @@ static_files = true # # repoze.who # -who.config_file = %(here)s/who.ini +#who.config_file = /usr/local/lib/python2.7/dist-packages/swat-0.1.1dev-py2.7.egg/who.ini +# +# repoze.who +# +#who.config_file = %(here)s/who.ini +authkit.setup.method = forward,cookie + +authkit.forward.signinpath = /authentication/login +authkit.cookie.signoutpath = /authentication/logout +authkit.cookie.secret = cookie secret +authkit.cookie.name = authkit_cookie_name +#authkit.cookie.params = expires: 3600 -yaml.config = %(here)s/swat/config/yaml +yaml.config = /usr/local/lib/python2.7/dist-packages/swat-0.1.1dev-py2.7.egg/swat/config/yaml -cache_dir = %(here)s/data +cache_dir = /usr/local/samba/var/cache/swat beaker.session.key = swat beaker.session.secret = ${app_instance_secret} app_instance_uuid = ${app_instance_uuid} @@ -42,6 +53,11 @@ app_instance_uuid = ${app_instance_uuid} # execute malicious code after an exception is raised. set debug = false +#handling for /swat prefix +filter-with = proxy-prefix +[filter:proxy-prefix] +use = egg:PasteDeploy#prefix +prefix = /swat # Logging configuration [loggers] -- 1.7.9.5