changeset 4198:988b2b672219

Fix tests: source code (indentation, whitespace) mostly
author Florian Krupicka <florian.krupicka@googlemail.com>
date Mon, 30 Jun 2008 12:00:33 +0200
parents 4acb272b1759
children 04c37245e12d
files MoinMoin/auth/__init__.py MoinMoin/config/multiconfig.py MoinMoin/logfile/editlog.py MoinMoin/web/contexts.py MoinMoin/web/request.py MoinMoin/web/session.py MoinMoin/web/utils.py MoinMoin/wsgiapp.py
diffstat 8 files changed, 38 insertions(+), 40 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/auth/__init__.py	Mon Jun 30 11:16:17 2008 +0200
+++ b/MoinMoin/auth/__init__.py	Mon Jun 30 12:00:33 2008 +0200
@@ -309,7 +309,7 @@
         auth_method = session['user.auth_method']
         auth_attrs = session['user.auth_attribs']
         if auth_method and auth_method in \
-                [ auth.name for auth in request.cfg.auth]:
+                [auth.name for auth in request.cfg.auth]:
             userobj = user.User(request, id=auth_userid,
                                 auth_method=auth_method,
                                 auth_attribs=auth_attrs)
--- a/MoinMoin/config/multiconfig.py	Mon Jun 30 11:16:17 2008 +0200
+++ b/MoinMoin/config/multiconfig.py	Mon Jun 30 12:00:33 2008 +0200
@@ -530,7 +530,7 @@
 
     session_handler = session.DefaultSessionHandler()
     session_id_handler = session.MoinCookieSessionIDHandler()
-    
+
     # new session service
     session_service = FileSessionService()
 
--- a/MoinMoin/logfile/editlog.py	Mon Jun 30 11:16:17 2008 +0200
+++ b/MoinMoin/logfile/editlog.py	Mon Jun 30 12:00:33 2008 +0200
@@ -163,7 +163,7 @@
         If `host` is None, it's read from request vars.
         """
         if host is None:
-            host = request.remote_addr
+            host = request.remote_addr or ''
 
         if request.cfg.log_reverse_dns_lookups:
             import socket
--- a/MoinMoin/web/contexts.py	Mon Jun 30 11:16:17 2008 +0200
+++ b/MoinMoin/web/contexts.py	Mon Jun 30 12:00:33 2008 +0200
@@ -60,7 +60,7 @@
             else:
                 res = obj.environ.setdefault(self.full_name, factory)
         return res
-    
+
     def set(self, obj, value):
         logging.debug("SET: '%s' on '%r' to '%r'", self.name, obj, value)
         obj.environ[self.full_name] = value
@@ -80,7 +80,7 @@
     environ and also keeps track of it's changes.
     """
     __slots__ = ['request', 'environ']
-    __implements__ = (IContext,)
+    __implements__ = (IContext, )
 
     def __init__(self, request):
         assert isinstance(request, Request)
@@ -167,17 +167,17 @@
     """ Mixin for HTTP attributes and methods. """
     forbidden = EnvironProxy('old.forbidden', 0)
     session = EnvironProxy('session')
-    
+
     _auth_redirected = EnvironProxy('old._auth_redirected', 0)
     _cache_disabled = EnvironProxy('old._cache_disabled', 0)
     cacheable = EnvironProxy('old.cacheable', 0)
-        
+
     def write(self, *data):
         if len(data) > 1:
             logging.warning("Some code still uses write with multiple arguments, "
                             "consider changing this soon")
         self.request.stream.writelines(data)
-    
+
     # implementation of methods expected by RequestBase
     def send_file(self, fileobj, bufsize=8192, do_flush=None):
         pass
@@ -189,10 +189,10 @@
             return self.request.input_stream.read(n)
 
     def makeForbidden(self, resultcode, msg):
-        status = { 401: Unauthorized,
-                   403: Forbidden,
-                   404: NotFound,
-                   503: SurgeProtection }
+        status = {401: Unauthorized,
+                  403: Forbidden,
+                  404: NotFound,
+                  503: SurgeProtection}
         raise status[resultcode](msg)
 
     def setHttpHeader(self, header):
@@ -202,7 +202,7 @@
     def disableHttpCaching(self, level=1):
         if level <= self._cache_disabled:
             return
-        
+
         if level == 1:
             self.headers.add('Cache-Control', 'private, must-revalidate, mag-age=10')
         elif level == 2:
@@ -222,7 +222,7 @@
 class ActionMixin(object):
     """ Mixin for the action related attributes. """
     def action(self):
-        return self.request.values.get('action','show')
+        return self.request.values.get('action', 'show')
     action = EnvironProxy(action)
 
     def rev(self):
@@ -274,8 +274,6 @@
     pragma = EnvironProxy('pragma', lambda o: {})
     _login_messages = EnvironProxy('_login_messages', lambda o: [])
     _login_multistage = EnvironProxy('_login_multistage', None)
-
-
     _setuid_real_user = EnvironProxy('_setuid_real_user', None)
 
     def uid_generator(self):
@@ -312,7 +310,7 @@
 
             Keys are not case-sensitive.
         """
-        self.pragma[key.lower()] = value    
+        self.pragma[key.lower()] = value
 
 class ThemeMixin(object):
     """ Mixin for the theme attributes and methods. """
@@ -354,17 +352,16 @@
                   LanguageMixin, AuxilaryMixin):
     """ Context to act mainly in HTTP handling related phases. """
     def __getattribute__(self, name):
-         try:
-             logging.debug('Attribute access: %s', name)
-             return super(HTTPContext, self).__getattribute__(name)
-         except AttributeError:
-             try:
-                 return getattr(self.request, name)
-             except AttributeError:
-                 msg = "'%s' object has no attribute '%s'"
-                 msg = msg % (self.__class__.__name__,
-                              name)
-                 raise AttributeError(msg)
+        try:
+            return super(HTTPContext, self).__getattribute__(name)
+        except AttributeError:
+            try:
+                return getattr(self.request, name)
+            except AttributeError:
+                msg = "'%s' object has no attribute '%s'"
+                msg = msg % (self.__class__.__name__,
+                             name)
+                raise AttributeError(msg)
 
 class RenderContext(Context, RedirectMixin, ConfigMixin, UserMixin,
                     LanguageMixin, ThemeMixin, AuxilaryMixin,
@@ -380,5 +377,5 @@
 class XMLRPCContext(HTTPContext):
     """ Context to act during a XMLRPC request. """
 
-class AllContext(HTTPContext, RenderContext):
+class AllContext(HTTPContext, RenderContext, AuxilaryMixin):
     """ Catchall context to be able to quickly test old Moin code. """
--- a/MoinMoin/web/request.py	Mon Jun 30 11:16:17 2008 +0200
+++ b/MoinMoin/web/request.py	Mon Jun 30 12:00:33 2008 +0200
@@ -63,4 +63,4 @@
     environ = create_environ(path=pagename)
     environ['HTTP_USER_AGENT'] = 'CLI/Script'
     return Request(environ)
-        
+
--- a/MoinMoin/web/session.py	Mon Jun 30 11:16:17 2008 +0200
+++ b/MoinMoin/web/session.py	Mon Jun 30 12:00:33 2008 +0200
@@ -29,13 +29,13 @@
     directory and identifis the session via a cookie in the request/response
     cycle.
     """
-    
-    __implements__ = (ISessionService,)
+
+    __implements__ = (ISessionService, )
 
     def __init__(self, cookie_name='MOIN_SESSION'):
         self.store = FilesystemSessionStore(session_class=MoinSession)
         self.cookie_name = cookie_name
-        
+
     def get_session(self, request):
         sid = request.cookies.get(self.cookie_name, None)
         if sid is None:
--- a/MoinMoin/web/utils.py	Mon Jun 30 11:16:17 2008 +0200
+++ b/MoinMoin/web/utils.py	Mon Jun 30 12:00:33 2008 +0200
@@ -20,7 +20,7 @@
 
 def check_spider(useragent, cfg):
     """ Simple check if useragent is a spider bot
-    
+
     @param useragent: werkzeug.useragents.UserAgent
     @param cfg: wikiconfig instance
     """
@@ -33,7 +33,7 @@
     """ Check for setuid conditions.
     Returns a tuple of either new user and old user
     or just user and None.
-    
+
     @param request: a moin request object
     @param userobj: a moin user object
     @rtype: boolean
@@ -83,7 +83,8 @@
         return False
 
     validuser = request.user.valid
-    current_id = validuser and request.user.name or request.remote_addr
+    current_id = validuser and request.user.name or request.remote_addr or ''
+
     if not validuser and current_id.startswith('127.'): # localnet
         return False
     current_action = request.action
@@ -247,4 +248,4 @@
         self.page_ids[namespace][base] = count
         if not count:
             return base
-        return u'%s-%d' % (base, count)        
+        return u'%s-%d' % (base, count)
--- a/MoinMoin/wsgiapp.py	Mon Jun 30 11:16:17 2008 +0200
+++ b/MoinMoin/wsgiapp.py	Mon Jun 30 12:00:33 2008 +0200
@@ -39,7 +39,7 @@
     # first try setting up from session
     userobj = auth.setup_from_session(request, request.session)
 
-    # then handle login/logout forms 
+    # then handle login/logout forms
     form = request.values
 
     if 'login' in form:
@@ -76,7 +76,7 @@
     return request
 
 def run(request):
-    
+
     _ = request.getText
     request.clock.start('run')
 
@@ -182,7 +182,7 @@
                     handler(request.page.page_name, request)
 
         # every action that didn't use to raise MoinMoinFinish must call this now:
-        # request.theme.send_closing_html()    
+        # request.theme.send_closing_html()
 
     except MoinMoinFinish:
         pass