[Mpuls-commits] r748 - in wasko/branches/2.0: . waskaweb/config waskaweb/controllers waskaweb/lib
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Wed Jan 13 09:48:51 CET 2010
Author: torsten
Date: 2010-01-13 09:48:49 +0100 (Wed, 13 Jan 2010)
New Revision: 748
Modified:
wasko/branches/2.0/ChangeLog.txt
wasko/branches/2.0/development.ini
wasko/branches/2.0/setup.py
wasko/branches/2.0/waskaweb/config/middleware.py
wasko/branches/2.0/waskaweb/controllers/waska.py
wasko/branches/2.0/waskaweb/lib/base.py
wasko/branches/2.0/waskaweb/lib/helpers.py
wasko/branches/2.0/waskaweb/lib/security.py
Log:
Update to Pylons 0.9.7. Enabled paster mode
Modified: wasko/branches/2.0/ChangeLog.txt
===================================================================
--- wasko/branches/2.0/ChangeLog.txt 2010-01-12 15:15:20 UTC (rev 747)
+++ wasko/branches/2.0/ChangeLog.txt 2010-01-13 08:48:49 UTC (rev 748)
@@ -1,3 +1,19 @@
+2010-01-13 Torsten Irlaender <torsten.irlaender at intevation.de>
+
+ Update to pylons 0.9.7 and reactivate running the application in
+ standalone mode.
+
+ * setup.py,
+ development.ini,
+ waskaweb/config/middleware.py,
+ waskaweb/controllers/waska.py,
+ waskaweb/lib/helpers.py,
+ waskaweb/lib/security.py,
+ waskaweb/lib/base.py: Updateded WASKO according to:
+ http://wiki.pylonshq.com/display/pylonsdocs/Upgrading.
+ Further enabled feature to run the appliction as paster app. DB-Name
+ ist then fetched from the config file.
+
2010-01-08 Frank Koormann <frank.koormann at intevation.de>
* waskaweb/templates/caselifetime/overview.mako: Typo fixed
Modified: wasko/branches/2.0/development.ini
===================================================================
--- wasko/branches/2.0/development.ini 2010-01-12 15:15:20 UTC (rev 747)
+++ wasko/branches/2.0/development.ini 2010-01-13 08:48:49 UTC (rev 748)
@@ -4,16 +4,38 @@
# The %(here)s variable will be replaced with the parent directory of this file
#
[DEFAULT]
-debug = true
+debug = false
# Uncomment and replace with the address which should receive any error reports
#email_to = you at yourdomain.com
smtp_server = localhost
error_email_from = paste at localhost
+formed_tree = ../../formed/formedtree_web.xml
+# for connections to PostgeSQL database
+# db_database: %s will be replaced by certificate value
+# db_user: first %s -> database name, second %s -> user
+db_name = mydb
+db_database = ka_%s_db
+db_user = ka_%s_%s
+db_host = 127.0.0.1
+db_port = 5432
+
+# Name of the application
+app_name = "Default application name"
+
+# for connections to PDF2XFA server
+#pdf2xfa_host = 192.168.11.17
+#pdf2xfa_port = 1111
+
+# set this to 'false' if you do not want the application
+# to handle static content.
+serve_static = true
+
[server:main]
use = egg:Paste#http
host = 0.0.0.0
port = 5001
+#ssl_pem = *
[app:main]
use = egg:waskaweb
@@ -22,6 +44,9 @@
cache_dir = %(here)s/data
beaker.session.key = waskaweb
beaker.session.secret = somesecret
+beaker.session.timeout = 1800
+#beaker.session.type = memory
+#beaker.session.invalidate_corrupt = True
# If you'd like to fine-tune the individual locations of the cache data dirs
# for the Cache data, or the Session saves, un-comment the desired settings
@@ -29,23 +54,16 @@
#beaker.cache.data_dir = %(here)s/data/cache
#beaker.session.data_dir = %(here)s/data/sessions
+# You can provide a user specific configuration for the mpuls server.
+# In this file you can configure various things like the database connection,
+# enable or disable modules etc.
+#mpuls_config=%(here)s/myconfig.json
+
# WARNING: *THE LINE BELOW MUST BE UNCOMMENTED ON A PRODUCTION ENVIRONMENT*
# Debug mode will enable the interactive debugging tool, allowing ANYONE to
# execute malicious code after an exception is raised.
-#set debug = false
+set debug = false
-#Authkit
-#authkit.setup.method = form, cookie
-#authkit.form.authenticate.user.data = anton:admin
-#authkit.cookie.secret = random string
-#authkit.cookie.secret = c040503178d7eca202b416398671a50f75afa86be6e1938a5e75b55a52d14026
-#authkit.cookie.params = {expires:'10'}
-#authkit.form.template.obj = waskaweb.lib.template:make_template
-#authkit.cookie.signoutpath = /waska/logout
-
-#authkit.method.formauthenticate.function = waskaweb.lib.security:checkLogin
-#authkit.form.authenticate.function = waskaweb.lib.security:checkLogin
-
# Logging configuration
[loggers]
keys = root, waskaweb
Modified: wasko/branches/2.0/setup.py
===================================================================
--- wasko/branches/2.0/setup.py 2010-01-12 15:15:20 UTC (rev 747)
+++ wasko/branches/2.0/setup.py 2010-01-13 08:48:49 UTC (rev 748)
@@ -35,7 +35,7 @@
#author='',
#author_email='',
#url='',
- install_requires=["Pylons>=0.9.6"],
+ install_requires=["Pylons>=0.9.6", "pyOpenSSL"],
packages=find_packages(exclude=['ez_setup']),
include_package_data=True,
test_suite='nose.collector',
Modified: wasko/branches/2.0/waskaweb/config/middleware.py
===================================================================
--- wasko/branches/2.0/waskaweb/config/middleware.py 2010-01-12 15:15:20 UTC (rev 747)
+++ wasko/branches/2.0/waskaweb/config/middleware.py 2010-01-13 08:48:49 UTC (rev 748)
@@ -27,6 +27,9 @@
#from authkit.permissions import ValidAuthKitUser
#import authkit
+from beaker.middleware import CacheMiddleware, SessionMiddleware
+from routes.middleware import RoutesMiddleware
+
from paste.cascade import Cascade
from paste.registry import RegistryManager
from paste.urlparser import StaticURLParser
@@ -84,6 +87,10 @@
app = PylonsApp()
# CUSTOM MIDDLEWARE HERE (filtered by error handling middlewares)
+ app = RoutesMiddleware(app, config['routes.map'])
+ app = SessionMiddleware(app, config)
+ app = CacheMiddleware(app, config)
+
if asbool(full_stack):
pass
# Handle Python exceptions
Modified: wasko/branches/2.0/waskaweb/controllers/waska.py
===================================================================
--- wasko/branches/2.0/waskaweb/controllers/waska.py 2010-01-12 15:15:20 UTC (rev 747)
+++ wasko/branches/2.0/waskaweb/controllers/waska.py 2010-01-13 08:48:49 UTC (rev 748)
@@ -158,13 +158,14 @@
session['USER_AUTHORIZED'] = user
session['AUTH'] = md5.new(shared + userIdentity()).digest()
session.save()
- response.set_cookie('waska_auth', shared, secure=True)
+ #response.set_cookie('waska_auth', shared, secure=True)
+ response.set_cookie('waska_auth', shared)
redirect_to(action="start")
else:
c.login_failed = True
return self.login()
except KeyError:
- pass
+ log.error('Error while fetching username and password')
return self.login()
# vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8:
Modified: wasko/branches/2.0/waskaweb/lib/base.py
===================================================================
--- wasko/branches/2.0/waskaweb/lib/base.py 2010-01-12 15:15:20 UTC (rev 747)
+++ wasko/branches/2.0/waskaweb/lib/base.py 2010-01-13 08:48:49 UTC (rev 748)
@@ -26,6 +26,8 @@
Provides the BaseController class for subclassing, and other objects
utilized by Controllers.
"""
+import logging
+
from pylons import c, cache, config, g, request, response, session
from pylons.controllers import WSGIController
from pylons.controllers.util import abort, etag_cache, redirect_to
@@ -53,6 +55,8 @@
COOKIE_NOT_FOUND = "Cookie konnte nicht gefunden werden. Haben Sie Cookies in Ihrem Browser aktiviert?"
IDENTITY_CHANGED = "Ihre Identitaet hat sich geaendert."
+log = logging.getLogger(__name__)
+
class BaseController(WSGIController):
def __init__(self):
@@ -68,6 +72,7 @@
storedHash = session['AUTH']
try:
shared = request.cookies['waska_auth']
+
except KeyError:
print >> sys.stderr, "Cannot find waska_auth cookie -> HTTPUnauthorized"
raise HTTPUnauthorized(detail = COOKIE_NOT_FOUND)
Modified: wasko/branches/2.0/waskaweb/lib/helpers.py
===================================================================
--- wasko/branches/2.0/waskaweb/lib/helpers.py 2010-01-12 15:15:20 UTC (rev 747)
+++ wasko/branches/2.0/waskaweb/lib/helpers.py 2010-01-13 08:48:49 UTC (rev 748)
@@ -26,30 +26,29 @@
Consists of functions to typically be used within templates, but also
available to Controllers. This module is available to both as 'h'.
"""
-#from waskaweb.lib.base import *
import locale
+import logging
import sys
import re
+import datetime
+from string import printable
from pylons import c, cache, config, g, request, response, session
-from webhelpers import *
-from waskaweb.lib.adelexml import EVAL_NAMES, EVAL_DESCRIPTIONS
from pylons.i18n import _
-from string import printable
-import datetime
+# Use url_for from prior versions
+from routes import url_for
+from webhelpers import *
-#from waskaweb.lib.renderer import ErrorRenderer
+from waskaweb.lib.adelexml import EVAL_NAMES, EVAL_DESCRIPTIONS
from waskaweb.lib.filecache import FileCache
-#from types import IntType
-
-#from waskaweb.model.data import PageNode
-
VALID_DATE = re.compile(r'^([0-9]{1,2})\.([0-9]{1,2})\.([0-9]{4})$')
VALID_TIME = re.compile(r'^([0-9]{1,2}):([0-9]{2})')
PRINTABLE = frozenset(printable)
+log = logging.getLogger(__name__)
+
def render_navigation(mode="r"):
tree = session['navigation.tree']
#factory = InstanceFactory(g.formed, PostgresDBInterface())
@@ -380,10 +379,12 @@
# There are two OU. We want the one != WASKA
if field[0] == "OU" and field[1] != "WASKA":
kaname = field[1]
- return kaname
except:
- print >> sys.stderr, "Could not fetch KA-name from client certificate"
- return ''
+ try:
+ kaname = config.get('app_name')
+ except:
+ log.error("Could not fetch KA-name from client certificate")
+ return kaname
def safe_unicode(s):
return u''.join([c for c in s if ord(c) > 127 or c in PRINTABLE])
Modified: wasko/branches/2.0/waskaweb/lib/security.py
===================================================================
--- wasko/branches/2.0/waskaweb/lib/security.py 2010-01-12 15:15:20 UTC (rev 747)
+++ wasko/branches/2.0/waskaweb/lib/security.py 2010-01-13 08:48:49 UTC (rev 748)
@@ -30,8 +30,9 @@
#
from waskaweb.lib.db import DB, db, enter, leave
-from pylons import request, session
+from pylons import request, session, config
import re
+import logging
import traceback
import sys
import time
@@ -68,6 +69,8 @@
ASCII_DECODER = getdecoder("ascii")
+log = logging.getLogger(__name__)
+
def validPassword(s):
try:
ASCII_DECODER(s)
@@ -84,7 +87,8 @@
or not check_re.match(user) \
or not check_re.match(dbname):
return None
-
+
+ log.info('Login: user "%s" in "%s"' % (user, dbname))
try:
mydb = DB(
dbname = DBNAME % dbname,
@@ -150,6 +154,7 @@
print "Error on creating user Object: %s" % err
#RETURN userobject
+ log.info('Login ok :)')
return userobject
finally:
leave(mydb)
@@ -161,6 +166,7 @@
traceback.print_exc(file=sys.stderr)
except:
traceback.print_exc(file=sys.stderr)
+ log.info('Login failed :(')
return None
def generateID(obj=None):
@@ -206,7 +212,11 @@
dbname = request.environ['SSL_CLIENT_S_DN_CN'].split(' ')[3].lower()
return NEW_DBS.get(dbname, dbname)
except:
- print >> sys.stderr, "Could not fetch database name from client certificate"
+ try:
+ dbname = config.get('db_name')
+ return NEW_DBS.get(dbname, dbname)
+ except:
+ log.debug("Could not fetch database name from client certificate")
return dbname
def checkRole(role):
More information about the Mpuls-commits
mailing list