changeset 948:28ea5b3802b1

whitespace-only cleanup
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Mon, 17 Jul 2006 03:43:33 +0200
parents 41f6f7708466
children cbbde07e00c4
files MoinMoin/auth/_PHPsessionParser.py MoinMoin/auth/__init__.py MoinMoin/auth/http.py MoinMoin/auth/interwiki.py MoinMoin/auth/ldap_login.py MoinMoin/auth/mysql_group.py MoinMoin/auth/php_session.py MoinMoin/auth/smb_mount.py
diffstat 8 files changed, 45 insertions(+), 46 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/auth/_PHPsessionParser.py	Mon Jul 17 03:08:12 2006 +0200
+++ b/MoinMoin/auth/_PHPsessionParser.py	Mon Jul 17 03:43:33 2006 +0200
@@ -43,12 +43,12 @@
         first_data = string[start+2:header_end]
     else:
         first_data = None
-    
+
     #print "Saw type %r, first_data is %r." % (val_type, first_data)
     if val_type == 'a': # array (in Python rather a mixture of a list and a dict)
         i = 0
         items = []
-        
+
         current_pos = header_end+2
         data = string
         while i != (int(first_data) * 2):
@@ -56,7 +56,7 @@
             items.append(item)
             i += 1
             current_pos += 1
-        
+
         t_list = list(transformList(items))
         try:
             result = dict(t_list) # note that dict does not retain the order
@@ -64,7 +64,7 @@
             result = list(t_list)
             #print "Warning, could not convert to dict: %r" %  (result, )
         return result, current_pos
-    
+
     if val_type == 's': # string
         current_pos = header_end+2
         end = current_pos + int(first_data)
@@ -91,7 +91,7 @@
 
     if val_type == "N": # Null, called None in Python
         return None, start+1
-        
+
     return UnknownObject(start), start+1
 
 def parseSession(boxed):
@@ -134,10 +134,11 @@
 if __name__ == '__main__':
     # testing code
     import time
-    a=time.clock()
-    
+    a = time.clock()
+
     #print s
     p_s = loadSession("...")
     import pprint; pprint.pprint(p_s)
     print time.clock() - a
     print listSessions()
+
--- a/MoinMoin/auth/__init__.py	Mon Jul 17 03:08:12 2006 +0200
+++ b/MoinMoin/auth/__init__.py	Mon Jul 17 03:43:33 2006 +0200
@@ -80,7 +80,7 @@
             path = '/'
         c[cookie_name]['path'] = path
     # Set expires for older clients
-    c[cookie_name]['expires'] = request.httpDate(when=expires, rfc='850')        
+    c[cookie_name]['expires'] = request.httpDate(when=expires, rfc='850')
     return c.output()
 
 def setCookie(request, u, cookie_name, cookie_string):
@@ -96,7 +96,7 @@
      < 0    -n hours, ignoring user 'remember_me' setting
     """
     # Calculate cookie maxage and expires
-    lifetime = int(request.cfg.cookie_lifetime) * 3600 
+    lifetime = int(request.cfg.cookie_lifetime) * 3600
     forever = 10 * 365 * 24 * 3600 # 10 years
     now = time.time()
     if not lifetime:
@@ -109,7 +109,7 @@
     elif lifetime < 0:
         maxage = (-lifetime)
     expires = now + maxage
-    
+
     cookie = makeCookie(request, cookie_name, cookie_string, maxage, expires)
     # Set cookie
     request.setHttpHeader(cookie)
@@ -141,7 +141,7 @@
     maxage = 0
     # Set expires to one year ago for older clients
     expires = time.time() - (3600 * 24 * 365) # 1 year ago
-    cookie = makeCookie(request, cookie_name, cookie_string, maxage, expires) 
+    cookie = makeCookie(request, cookie_name, cookie_string, maxage, expires)
     # Set cookie
     request.setHttpHeader(cookie)
     # IMPORTANT: Prevent caching of current page and cookie        
@@ -159,7 +159,7 @@
     verbose = False
     if hasattr(cfg, 'moin_login_verbose'):
         verbose = cfg.moin_login_verbose
-    
+
     #request.log("auth.moin_login: name=%s login=%r logout=%r user_obj=%r" % (username, login, logout, user_obj))
 
     if login:
@@ -180,7 +180,7 @@
     ongoing sessions, and logout. Use another method for initial login.
     """
     import base64
-    
+
     username = kw.get('name')
     login = kw.get('login')
     logout = kw.get('logout')
@@ -192,7 +192,7 @@
         verbose = cfg.moin_session_verbose
 
     cookie_name = MOIN_SESSION
-    
+
     if verbose: request.log("auth.moin_session: name=%s login=%r logout=%r user_obj=%r" % (username, login, logout, user_obj))
 
     if login:
@@ -223,14 +223,14 @@
         # No valid cookie
         if verbose: request.log("either no cookie or no %s key" % cookie_name)
         return user_obj, True
-    
+
     try:
         cookie_hash, cookie_body = cookie[cookie_name].value.split(':', 1)
     except ValueError:
         # Invalid cookie
         if verbose: request.log("invalid cookie format: (%s)" % cookie[cookie_name].value)
         return user_obj, True
-    
+
     if cookie_hash != make_security_hash(request, cookie_body):
         # Invalid cookie
         # XXX Cookie clear here???
@@ -239,7 +239,7 @@
 
     # We can trust the cookie
     if verbose: request.log("Cookie OK, authenticated.")
-    params = { 'username': '', 'id': '' }
+    params = {'username': '', 'id': '', }
     cookie_pairs = cookie_body.split(":")
     for key, value in [pair.split("=", 1) for pair in cookie_pairs]:
         params[key] = base64.decodestring(value) # assuming all values are base64 encoded
@@ -251,7 +251,7 @@
                   auth_method='moin_session',
                   auth_attribs=(),
                   )
-        
+
     if logout:
         if verbose: request.log("Logout requested, setting u invalid and 'deleting' cookie")
         u.valid = 0 # just make user invalid, but remember him
--- a/MoinMoin/auth/http.py	Mon Jul 17 03:08:12 2006 +0200
+++ b/MoinMoin/auth/http.py	Mon Jul 17 03:43:33 2006 +0200
@@ -27,9 +27,9 @@
 
     elif not isinstance(request, CLI.Request):
         env = request.env
-        auth_type = env.get('AUTH_TYPE','')
-        if auth_type in ['Basic', 'Digest', 'NTLM', 'Negotiate',]:
-            username = env.get('REMOTE_USER','')
+        auth_type = env.get('AUTH_TYPE', '')
+        if auth_type in ['Basic', 'Digest', 'NTLM', 'Negotiate', ]:
+            username = env.get('REMOTE_USER', '')
             if auth_type in ('NTLM', 'Negotiate',):
                 # converting to standard case so the user can even enter wrong case
                 # (added since windows does not distinguish between e.g.
--- a/MoinMoin/auth/interwiki.py	Mon Jul 17 03:08:12 2006 +0200
+++ b/MoinMoin/auth/interwiki.py	Mon Jul 17 03:43:33 2006 +0200
@@ -24,14 +24,14 @@
 
         if err or wikitag not in request.cfg.trusted_wikis:
             return user_obj, True
-        
+
         if password:
             homewiki = xmlrpclib.Server(wikiurl + "?action=xmlrpc2")
             account_data = homewiki.getUser(wikitail, password)
             if isinstance(account_data, str):
                 # show error message
                 return user_obj, True
-            
+
             u = user.User(request, name=username)
             for key, value in account_data.iteritems():
                 if key not in ["may", "id", "valid", "trusted"
@@ -45,6 +45,6 @@
         else:
             pass
             # XXX redirect to homewiki
-    
+
     return user_obj, True
 
--- a/MoinMoin/auth/ldap_login.py	Mon Jul 17 03:08:12 2006 +0200
+++ b/MoinMoin/auth/ldap_login.py	Mon Jul 17 03:43:33 2006 +0200
@@ -27,14 +27,14 @@
 
     cfg = request.cfg
     verbose = cfg.ldap_verbose
-    
+
     if verbose: request.log("got name=%s login=%r logout=%r" % (username, login, logout))
-    
+
     # we just intercept login and logout for ldap, other requests have to be
     # handled by another auth handler
     if not login and not logout:
         return user_obj, True
-    
+
     u = None
     coding = cfg.ldap_coding
     try:
@@ -68,14 +68,14 @@
         dn, ldap_dict = lusers[0]
         if verbose:
             request.log("LDAP: debug lusers = %r" % lusers)
-            for key,val in ldap_dict.items():
+            for key, val in ldap_dict.items():
                 request.log("LDAP: %s: %s" % (key, val))
 
         try:
             if verbose: request.log("LDAP: DN found is %s, trying to bind with pw" % dn)
             l.simple_bind_s(dn, password.encode(coding))
             if verbose: request.log("LDAP: Bound with dn %s (username: %s)" % (dn, username))
-            
+
             email = ldap_dict.get(cfg.ldap_email_attribute, [''])[0]
             email = email.decode(coding)
             sn, gn = ldap_dict.get('sn', [''])[0], ldap_dict.get('givenName', [''])[0]
@@ -85,14 +85,14 @@
             elif sn:
                 aliasname = sn
             aliasname = aliasname.decode(coding)
-            
+
             u = user.User(request, auth_username=username, password="{SHA}NotStored", auth_method='ldap', auth_attribs=('name', 'password', 'email', 'mailto_author',))
             u.name = username
             u.aliasname = aliasname
             u.email = email
             u.remember_me = 0 # 0 enforces cookie_lifetime config param
             if verbose: request.log("LDAP: creating userprefs with name %s email %s alias %s" % (username, email, aliasname))
-            
+
         except ldap.INVALID_CREDENTIALS, err:
             request.log("LDAP: invalid credentials (wrong password?) for dn %s (username: %s)" % (dn, username))
 
--- a/MoinMoin/auth/mysql_group.py	Mon Jul 17 03:08:12 2006 +0200
+++ b/MoinMoin/auth/mysql_group.py	Mon Jul 17 03:43:33 2006 +0200
@@ -2,8 +2,6 @@
 """
     MoinMoin - auth plugin doing a check against MySQL group db
 
-    ...
-
     @copyright: 2006 by Nick Phillips
     @license: GNU GPL, see COPYING for details.
 """
@@ -17,7 +15,7 @@
     We don't worry about the type of request (login, logout, neither).
     We just check user is part of authorized group.
     """
-    
+
     username = kw.get('name')
 #    login = kw.get('login')
 #    logout = kw.get('logout')
@@ -28,7 +26,7 @@
 
     if hasattr(cfg, 'mysql_group_verbose'):
         verbose = cfg.mysql_group_verbose
-    
+
     if verbose: request.log("auth.mysql_group: name=%s user_obj=%r" % (username, user_obj))
 
     # Has any other method successfully authenticated?
@@ -53,7 +51,7 @@
             request.log("mysql_group: authorization failed due to exception connecting to DB, traceback follows...")
             request.log(''.join(traceback.format_exception(*info)))
             return None, False
-        
+
         c = m.cursor()
         c.execute(cfg.mysql_group_query, user_obj.auth_username)
         results = c.fetchall()
--- a/MoinMoin/auth/php_session.py	Mon Jul 17 03:08:12 2006 +0200
+++ b/MoinMoin/auth/php_session.py	Mon Jul 17 03:43:33 2006 +0200
@@ -24,7 +24,7 @@
             @param s_path: The path where the PHP sessions are stored.
             @param s_prefix: The prefix of the session files.
         """
-        
+
         self.s_path = s_path
         self.s_prefix = s_prefix
         self.apps = apps
@@ -34,18 +34,18 @@
             """ Extracts name, fullname and email from the session. """
             username = session['egw_session']['session_lid'].split("@", 1)[0]
             known_accounts = session['egw_info_cache']['accounts']['cache']['account_data']
-            
+
             # if the next line breaks, then the cache was not filled with the current
             # user information
             user_info = [value for key, value in known_accounts.items()
                          if value['account_lid'] == username][0]
             name = user_info.get('fullname', '')
             email = user_info.get('email', '')
-            
+
             dec = lambda x: x and x.decode("iso-8859-1")
-            
+
             return dec(username), dec(email), dec(name)
-        
+
         user_obj = kw.get('user_obj')
         try:
             cookie = Cookie.SimpleCookie(request.saved_cookie)
@@ -61,9 +61,9 @@
                         break
             else:
                 return user_obj, True
-            
+
             user = user.User(request, name=username, auth_username=username)
-            
+
             changed = False
             if name != user.aliasname:
                 user.aliasname = name
@@ -71,7 +71,7 @@
             if email != user.email:
                 user.email = email
                 changed = True
-            
+
             if user:
                 user.create_or_update(changed)
             if user and user.valid:
--- a/MoinMoin/auth/smb_mount.py	Mon Jul 17 03:08:12 2006 +0200
+++ b/MoinMoin/auth/smb_mount.py	Mon Jul 17 03:43:33 2006 +0200
@@ -21,7 +21,7 @@
     cfg = request.cfg
     verbose = cfg.smb_verbose
     if verbose: request.log("got name=%s login=%r logout=%r" % (username, login, logout))
-    
+
     # we just intercept login to mount and logout to umount the smb share
     if login or logout:
         import os, pwd, subprocess
@@ -36,7 +36,7 @@
             cmd = u"sudo mount -t cifs -o user=%(user)s,domain=%(domain)s,uid=%(uid)d,dir_mode=%(dir_mode)s,file_mode=%(file_mode)s,iocharset=%(iocharset)s //%(server)s/%(share)s %(mountpoint)s >>%(log)s 2>&1"
         elif logout:
             cmd = u"sudo umount %(mountpoint)s >>%(log)s 2>&1"
-            
+
         cmd = cmd % {
             'user': username,
             'uid': web_uid,