[Mpuls-commits] r768 - in wasko/branches/2.0: . waskaweb/lib
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Tue Jan 19 19:24:08 CET 2010
Author: bh
Date: 2010-01-19 19:24:07 +0100 (Tue, 19 Jan 2010)
New Revision: 768
Modified:
wasko/branches/2.0/ChangeLog.txt
wasko/branches/2.0/waskaweb/lib/base.py
Log:
* waskaweb/lib/base.py: Fix formatting and remove commented out code
Modified: wasko/branches/2.0/ChangeLog.txt
===================================================================
--- wasko/branches/2.0/ChangeLog.txt 2010-01-19 17:59:38 UTC (rev 767)
+++ wasko/branches/2.0/ChangeLog.txt 2010-01-19 18:24:07 UTC (rev 768)
@@ -1,5 +1,9 @@
2010-01-19 Bernhard Herzog <bh at intevation.de>
+ * waskaweb/lib/base.py: Fix formatting and remove commented out code
+
+2010-01-19 Bernhard Herzog <bh at intevation.de>
+
* waskaweb/lib/base.py (BaseController.__before__): Write error
message to log instead of stderr. Remove unnecessary debug log
Modified: wasko/branches/2.0/waskaweb/lib/base.py
===================================================================
--- wasko/branches/2.0/waskaweb/lib/base.py 2010-01-19 17:59:38 UTC (rev 767)
+++ wasko/branches/2.0/waskaweb/lib/base.py 2010-01-19 18:24:07 UTC (rev 768)
@@ -1,124 +1,123 @@
# Copyright 2007, 2008, 2010 Intevation GmbH, Germany, <info at intevation.de>
-#
-# This file is part of mpuls WASKA (CoMPUter-based case fiLeS -
+#
+# This file is part of mpuls WASKA (CoMPUter-based case fiLeS -
# Web-Anwendungs-Server fuer Kompetenzagenturen).
-#
+#
# mpuls WASKA is free software: you can redistribute it and/or modify it under
# the terms of the GNU Affero General Public License as published by the
# Free Software Foundation, either version 3 of the License, or (at your
# option) any later version.
-#
+#
# mpuls WASKA 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 Affero General Public
# License for more details.
-#
+#
# You should have received a copy of the GNU Affero General Public
# License along with mpuls WASKA. If not, see <http://www.gnu.org/licenses/>.
-#
-# mpuls WASKA has been developed on behalf of the
+#
+# mpuls WASKA has been developed on behalf of the
# Projekttraeger im Deutschen Zentrum fuer Luft- und Raumfahrt e.V. (PT-DLR)
# within the programme Kompetenzagenturen (Durchfuehrungsphase) funded by
-# the Bundesministerium fuer Familie, Senioren, Frauen und Jugend and
+# the Bundesministerium fuer Familie, Senioren, Frauen und Jugend and
# European Social Fund resources.
+
"""The base Controller API
Provides the BaseController class for subclassing, and other objects
utilized by Controllers.
"""
+
+import sys
+import md5
import logging
+from time import time
-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
-from pylons.i18n import _, ungettext, N_
-from pylons.templating import render
-
-import waskaweb.lib.helpers as h
-import waskaweb.model as model
-#import waskaweb.model.casedocument as casedocument
-
-import waskaweb.lib.db as db
-
from paste.httpexceptions import HTTPUnauthorized, HTTPNotFound
-from waskaweb.lib.security import \
- HOST, PORT, DBNAME, USER, getDbName, userIdentity
+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
+from pylons.i18n import _, ungettext, N_
+from pylons.templating import render
-import sys
-import md5
+import waskaweb.lib.helpers as h
+import waskaweb.lib.db as db
+from waskaweb.lib.timelog import timeLog
+from waskaweb.lib.security import HOST, PORT, DBNAME, USER, getDbName, \
+ userIdentity
-from time import time
+import waskaweb.model as model
-from waskaweb.lib.timelog import timeLog
-COOKIE_NOT_FOUND = "Cookie konnte nicht gefunden werden. Haben Sie Cookies in Ihrem Browser aktiviert?"
+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):
- self.db = None
+ self.db = None
self.page_cache = None
def __before__(self):
-
- # Determine if we have a server for normal use or for evalutation purpose.
+ # Determine if we have a server for normal use or for
+ # evalutation purpose.
c.isEvaluationServer = config.get('evaluation_server', '0') == '1'
try:
storedHash = session['AUTH']
try:
shared = request.cookies['waska_auth']
-
except KeyError:
log.error("Cannot find waska_auth cookie -> HTTPUnauthorized")
raise HTTPUnauthorized(detail = COOKIE_NOT_FOUND)
if storedHash != md5.new(shared + userIdentity()).digest():
- log.error("Stored hash does't match new hash -> HTTPUnauthorized")
+ log.error("Stored hash does't match new hash "
+ "-> HTTPUnauthorized")
raise HTTPUnauthorized(detail = IDENTITY_CHANGED)
except KeyError:
pass
- # Check if the user is already authorized.
+ # Check if the user is already authorized.
# If not then redirect the user to the login page
try:
user = session['USER_AUTHORIZED']
- dbname = getDbName()
+ dbname = getDbName()
- self.db = db.DB(
- dbname = DBNAME % dbname,
- host = HOST,
- port = PORT,
- user = USER % (dbname, user.login),
- password = user.password)
-
+ self.db = db.DB(dbname=DBNAME % dbname,
+ host=HOST,
+ port=PORT,
+ user=USER % (dbname, user.login),
+ password=user.password)
db.enter(self.db)
# Is the user activated?
- if not user.isActivated() \
- and not request.path_info in ('/administration/accountDeactivated', '/styles/web.css', '/styles/all.css'):
- #print request.path_info
- redirect_to(controller="administration", action="accountDeactivated")
+ if (not user.isActivated()
+ and not request.path_info in
+ ('/administration/accountDeactivated', '/styles/web.css',
+ '/styles/all.css'):
+ redirect_to(controller="administration",
+ action="accountDeactivated")
# Do the user needs to change his passwort?
- if user.needsNewPass() \
- and not request.path_info in ('/usersettings/changePasswordOnLogin', '/usersettings/changePasswordOnLoginAction', '/styles/web.css', '/styles/all.css'):
- redirect_to(controller="usersettings", action="changePasswordOnLogin")
+ if (user.needsNewPass() \
+ and not request.path_info in
+ ('/usersettings/changePasswordOnLogin',
+ '/usersettings/changePasswordOnLoginAction',
+ '/styles/web.css', '/styles/all.css'):
+ redirect_to(controller="usersettings",
+ action="changePasswordOnLogin")
except KeyError:
p = str(request.path_info)
- if not p in ( '/waska/login', '/waska/loginAction'):# and not inPositive(p):
- #print >> sys.stderr, "Redirect to: '%s'" % request.path_info
+ if not p in ('/waska/login', '/waska/loginAction'):
redirect_to(h.url_for(controller='/waska', action='login'))
- #self.page_cache = casedocument.PageCache()
- #casedocument.enter(self.page_cache)
-
-
def __call__(self, environ, start_response):
"""Invoke the Controller"""
# WSGIController.__call__ dispatches to the Controller method
@@ -131,7 +130,6 @@
_cache = self.page_cache
if _cache:
self.page_cache = None
- #casedocument.leave(_cache)
_db = self.db
if _db:
self.db = None
@@ -147,9 +145,10 @@
self.showError()
def _checkBool(self, bool):
- confirmed = self._checkInt(bool)
- if confirmed not in [0,1]: self.showError()
- return confirmed == 1
+ confirmed = self._checkInt(bool)
+ if confirmed not in [0, 1]:
+ self.showError()
+ return confirmed == 1
def showError(self, err=None):
raise HTTPNotFound()
@@ -160,8 +159,9 @@
leftd[key] = rightd[key]
return leftd
+
class CaseBaseController(BaseController):
-
+
def __init__(self):
BaseController.__init__(self)
self.case_session = None
@@ -174,7 +174,6 @@
def __after__(self):
BaseController.__after__(self)
- #session.save()
# Include the '_' function in the public names
More information about the Mpuls-commits
mailing list