[Zope3-checkins] SVN: Zope3/trunk/src/zope/app/authentication/session.py use the new ISession.get method, this way session data is only created for authenticated requests

Bernd Dorn bernd.dorn at fhv.at
Thu Sep 21 13:14:16 EDT 2006


Log message for revision 70292:
  use the new ISession.get method, this way session data is only created for authenticated requests

Changed:
  U   Zope3/trunk/src/zope/app/authentication/session.py

-=-
Modified: Zope3/trunk/src/zope/app/authentication/session.py
===================================================================
--- Zope3/trunk/src/zope/app/authentication/session.py	2006-09-21 17:10:46 UTC (rev 70291)
+++ Zope3/trunk/src/zope/app/authentication/session.py	2006-09-21 17:14:16 UTC (rev 70292)
@@ -183,15 +183,23 @@
         """Extracts credentials from a session if they exist."""
         if not IHTTPRequest.providedBy(request):
             return None
-
-        sessionData = ISession(request)[
-            'zope.app.authentication.browserplugins']
+        session = ISession(request, None)
+        sessionData = session.get(
+            'zope.app.authentication.browserplugins')
         login = request.get(self.loginfield, None)
         password = request.get(self.passwordfield, None)
+        credentials = None
+
         if login and password:
             credentials = SessionCredentials(login, password)
+        elif not sessionData:
+            return None
+        sessionData = session[
+            'zope.app.authentication.browserplugins']
+        if credentials:
             sessionData['credentials'] = credentials
-        credentials = sessionData.get('credentials', None)
+        else:
+            credentials = sessionData.get('credentials', None)
         if not credentials:
             return None
         return {'login': credentials.getLogin(),



More information about the Zope3-Checkins mailing list