[Mpuls-commits] r1218 - in wasko/branches/2.0: . mpulsweb mpulsweb/lib waskaweb/lib

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Wed Feb 3 15:10:33 CET 2010


Author: torsten
Date: 2010-02-03 15:10:29 +0100 (Wed, 03 Feb 2010)
New Revision: 1218

Added:
   wasko/branches/2.0/mpulsweb/lib/
   wasko/branches/2.0/mpulsweb/lib/__init__.py
   wasko/branches/2.0/mpulsweb/lib/base.py
Modified:
   wasko/branches/2.0/ChangeLog
   wasko/branches/2.0/waskaweb/lib/base.py
Log:
Outsourced waskaweb.lib.base to muplsweb.lib.base


Modified: wasko/branches/2.0/ChangeLog
===================================================================
--- wasko/branches/2.0/ChangeLog	2010-02-03 13:56:34 UTC (rev 1217)
+++ wasko/branches/2.0/ChangeLog	2010-02-03 14:10:29 UTC (rev 1218)
@@ -55,6 +55,10 @@
 	  be configured.
 	* waskaweb/config/environment.py (load_environment): Set default
 	  path for controllers to mpulsweb.  
+	* mpulsweb/lib,
+	  mpulsweb/lib/base.py,
+	  mpulsweb/lib/__init__.py: Added new directory for base libs.
+	* waskaweb/lib/base.py: Import all from mpulsweb.lib.base 
 
 2010-02-03  Torsten Irländer <torsten.irlaender at intevation.de>
 

Added: wasko/branches/2.0/mpulsweb/lib/__init__.py
===================================================================

Added: wasko/branches/2.0/mpulsweb/lib/base.py
===================================================================
--- wasko/branches/2.0/mpulsweb/lib/base.py	2010-02-03 13:56:34 UTC (rev 1217)
+++ wasko/branches/2.0/mpulsweb/lib/base.py	2010-02-03 14:10:29 UTC (rev 1218)
@@ -0,0 +1,163 @@
+# Copyright 2007, 2008, 2010 Intevation GmbH, Germany, <info at intevation.de>
+#
+# 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
+# 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
+# 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 paste.httpexceptions import HTTPUnauthorized, HTTPNotFound
+
+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.lib.db as db
+from waskaweb.lib.timelog import timeLog
+from waskaweb.lib.security import HOST, PORT, DBNAME, USER, getDbName, \
+     userIdentity
+
+import waskaweb.model as model
+
+
+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.page_cache = None
+
+    def __before__(self):
+        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")
+                raise HTTPUnauthorized(detail = IDENTITY_CHANGED)
+        except KeyError:
+            pass
+
+        # Check if the user is already authorized.
+        # If not then redirect the user to the login page
+        try:
+            user = session['USER_AUTHORIZED']
+            dbname = getDbName()
+
+            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')):
+                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")
+
+        except KeyError:
+            p = str(request.path_info)
+            if not p in ('/waska/login', '/waska/loginAction'):
+                redirect_to(h.url_for(controller='/waska', action='login'))
+
+    def __call__(self, environ, start_response):
+        """Invoke the Controller"""
+        # WSGIController.__call__ dispatches to the Controller method
+        # the request is routed to. This routing information is
+        # available in environ['pylons.routes_dict']
+        startTime = time()
+        try:
+            return WSGIController.__call__(self, environ, start_response)
+        finally:
+            _cache = self.page_cache
+            if _cache:
+                self.page_cache = None
+            _db = self.db
+            if _db:
+                self.db = None
+                db.leave(_db)
+                _db.closeConnections()
+            stopTime = time()
+            timeLog(stopTime - startTime)
+
+    def _checkInt(self, i):
+        try:
+            return int(i)
+        except (TypeError, ValueError):
+            self.showError()
+
+    def _checkBool(self, bool):
+        confirmed = self._checkInt(bool)
+        if confirmed not in [0, 1]:
+            self.showError()
+        return confirmed == 1
+
+    def showError(self, err=None):
+        raise HTTPNotFound()
+
+    def merge_dict(self, leftd, rightd):
+        for key in rightd.keys():
+            # overwrite key value pairs
+            leftd[key] = rightd[key]
+        return leftd
+
+
+class CaseBaseController(BaseController):
+    pass
+
+# Include the '_' function in the public names
+__all__ = [__name for __name in locals().keys() if not __name.startswith('_') \
+           or __name == '_']

Modified: wasko/branches/2.0/waskaweb/lib/base.py
===================================================================
--- wasko/branches/2.0/waskaweb/lib/base.py	2010-02-03 13:56:34 UTC (rev 1217)
+++ wasko/branches/2.0/waskaweb/lib/base.py	2010-02-03 14:10:29 UTC (rev 1218)
@@ -27,151 +27,4 @@
 Provides the BaseController class for subclassing, and other objects
 utilized by Controllers.
 """
-
-import sys
-import md5
-import logging
-from time import time
-
-from paste.httpexceptions import HTTPUnauthorized, HTTPNotFound
-
-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.lib.db as db
-from waskaweb.lib.timelog import timeLog
-from waskaweb.lib.security import HOST, PORT, DBNAME, USER, getDbName, \
-     userIdentity
-
-import waskaweb.model as model
-
-
-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.page_cache = None
-
-    def __before__(self):
-        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")
-                raise HTTPUnauthorized(detail = IDENTITY_CHANGED)
-        except KeyError:
-            pass
-
-        # Check if the user is already authorized.
-        # If not then redirect the user to the login page
-        try:
-            user = session['USER_AUTHORIZED']
-            dbname = getDbName()
-
-            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')):
-                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")
-
-        except KeyError:
-            p = str(request.path_info)
-            if not p in ('/waska/login', '/waska/loginAction'):
-                redirect_to(h.url_for(controller='/waska', action='login'))
-
-    def __call__(self, environ, start_response):
-        """Invoke the Controller"""
-        # WSGIController.__call__ dispatches to the Controller method
-        # the request is routed to. This routing information is
-        # available in environ['pylons.routes_dict']
-        startTime = time()
-        try:
-            return WSGIController.__call__(self, environ, start_response)
-        finally:
-            _cache = self.page_cache
-            if _cache:
-                self.page_cache = None
-            _db = self.db
-            if _db:
-                self.db = None
-                db.leave(_db)
-                _db.closeConnections()
-            stopTime = time()
-            timeLog(stopTime - startTime)
-
-    def _checkInt(self, i):
-        try:
-            return int(i)
-        except (TypeError, ValueError):
-            self.showError()
-
-    def _checkBool(self, bool):
-        confirmed = self._checkInt(bool)
-        if confirmed not in [0, 1]:
-            self.showError()
-        return confirmed == 1
-
-    def showError(self, err=None):
-        raise HTTPNotFound()
-
-    def merge_dict(self, leftd, rightd):
-        for key in rightd.keys():
-            # overwrite key value pairs
-            leftd[key] = rightd[key]
-        return leftd
-
-
-class CaseBaseController(BaseController):
-
-    def __init__(self):
-        BaseController.__init__(self)
-        self.case_session = None
-        self.case_navigation = None
-
-    def __before__(self):
-        BaseController.__before__(self)
-        self.case_session = session.get('case')
-        self.case_navigation = session.get('case_navigation')
-
-    def __after__(self):
-        BaseController.__after__(self)
-
-
-# Include the '_' function in the public names
-__all__ = [__name for __name in locals().keys() if not __name.startswith('_') \
-           or __name == '_']
+from mpulsweb.lib.base import *



More information about the Mpuls-commits mailing list