changeset 4182:ca0cf44dab89

Moved request.clock into property
author Florian Krupicka <florian.krupicka@googlemail.com>
date Thu, 19 Jun 2008 18:23:02 +0200
parents eacb4c9e83e5
children fc20a076aad0
files MoinMoin/web/contexts.py MoinMoin/wsgiapp.py
diffstat 2 files changed, 8 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/web/contexts.py	Thu Jun 19 17:41:39 2008 +0200
+++ b/MoinMoin/web/contexts.py	Thu Jun 19 18:23:02 2008 +0200
@@ -17,6 +17,7 @@
 from MoinMoin.config import multiconfig
 from MoinMoin.formatter import text_html
 from MoinMoin.theme import load_theme_fallback
+from MoinMoin.util.clock import Clock
 from MoinMoin.web.request import Request
 from MoinMoin.web.utils import check_spider, UniqueIDGenerator
 from MoinMoin.web.exceptions import Forbidden, SurgeProtection
@@ -70,6 +71,7 @@
         assert isinstance(request, Request)
         self.request = request
         self.environ = request.environ
+        self.personalities.append(self.__class__)
 
     personalities = EnvironProxy('context.personalities', lambda o: list())
 
@@ -314,8 +316,11 @@
         else:
             self.write = self.writestack.pop()
 
+class ClockMixin(object):
+    clock = EnvironProxy('clock', lambda o: Clock())
+
 class HTTPContext(Context, HTTPMixin, ConfigMixin, UserMixin,
-                  LanguageMixin, RenamedMixin, ActionMixin):
+                  LanguageMixin, RenamedMixin, ClockMixin):
     def __getattribute__(self, name):
          try:
              return super(HTTPContext, self).__getattribute__(name)
@@ -324,7 +329,8 @@
 
 class RenderContext(Context, RedirectMixin, ConfigMixin, UserMixin,
                     LanguageMixin, PragmaMixin, ThemeMixin,
-                    AuxilaryMixin, DictsMixin, ActionMixin): pass
+                    AuxilaryMixin, DictsMixin, ActionMixin,
+                    ClockMixin): pass
 
 class XMLRPCContext(HTTPContext):
     pass
--- a/MoinMoin/wsgiapp.py	Thu Jun 19 17:41:39 2008 +0200
+++ b/MoinMoin/wsgiapp.py	Thu Jun 19 18:23:02 2008 +0200
@@ -22,7 +22,6 @@
 from MoinMoin.config import multiconfig
 from MoinMoin.support.python_compatibility import set
 from MoinMoin.util import IsWin9x
-from MoinMoin.util.clock import Clock
 from MoinMoin.request import MoinMoinFinish, RemoteClosedConnection
 from MoinMoin import auth
 
@@ -31,7 +30,6 @@
 
 def init(request):
     request = HTTPContext(request)
-    request.clock = Clock()
     request.clock.start('total')
     request.clock.start('base__init__')