changeset 850:71875396f812

merge with main
author Franz Pletz <fpletz AT franz-pletz DOT org>
date Fri, 16 Jun 2006 14:20:17 +0200
parents 02d6697b000d (current diff) 910ed4667859 (diff)
children 4d1bc2e51184
files
diffstat 4 files changed, 48 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/action/thread_monitor.py	Thu Jun 15 20:29:29 2006 +0200
+++ b/MoinMoin/action/thread_monitor.py	Fri Jun 16 14:20:17 2006 +0200
@@ -7,14 +7,30 @@
     @copyright: 2006 by MoinMoin:AlexanderSchremmer
     @license: GNU GPL, see COPYING for details.
 """
-
-from time import sleep
+import os, time
 from StringIO import StringIO
+ 
+from MoinMoin import wikiutil
+from MoinMoin.util import thread_monitor
+ 
+def execute_fs(pagename, request):
+    if thread_monitor.hook_enabled:
+        s = StringIO()
+        thread_monitor.trigger_dump(s)
+        time.sleep(5) # allow for all threads to dump to request
+        data = s.getvalue()
+        timestamp = time.time()
+        dump_fname = os.path.join(request.cfg.data_dir, "tm_%d.log" % timestamp)
+        f = file(dump_fname, "w")
+        f.write(data)
+        f.close()
+    else:
+        dump_fname = "nowhere"
 
-from MoinMoin.wikiutil import escape
-from MoinMoin.util import thread_monitor
+    request.http_headers()
+    request.write('<html><body>A dump has been saved to %s.</body></html>' % dump_fname)
 
-def execute(pagename, request):
+def execute_wiki(pagename, request):
     request.http_headers()
 
     request.theme.send_title("Thread monitor")
@@ -25,10 +41,12 @@
     else:
         s = StringIO()
         thread_monitor.trigger_dump(s)
-        sleep(5) # allow for all threads to dump to request
-        request.write(escape(s.getvalue()))
+        time.sleep(5) # allow for all threads to dump to request
+        request.write(wikiutil.escape(s.getvalue()))
         
     request.write('</pre>')
     request.theme.send_footer(pagename)
     request.theme.send_closing_html()
+  
+execute = execute_fs
 
--- a/MoinMoin/logfile/editlog.py	Thu Jun 15 20:29:29 2006 +0200
+++ b/MoinMoin/logfile/editlog.py	Fri Jun 16 14:20:17 2006 +0200
@@ -143,17 +143,19 @@
     
             If `host` is None, it's read from request vars.
             """
-            import socket
-            
             if host is None:
                 host = request.remote_addr
-                
-            try:
-                hostname = socket.gethostbyaddr(host)[0]
-                hostname = unicode(hostname, config.charset)
-            except (socket.error, UnicodeError), err:
+
+            if request.cfg.log_reverse_dns_lookups:
+                import socket
+                try:
+                    hostname = socket.gethostbyaddr(host)[0]
+                    hostname = unicode(hostname, config.charset)
+                except (socket.error, UnicodeError), err:
+                    hostname = host
+            else:
                 hostname = host
-
+            
             remap_chars = {u'\t': u' ', u'\r': u' ', u'\n': u' ',}
             comment = comment.translate(remap_chars)
             user_id = request.user.valid and request.user.id or ''
--- a/MoinMoin/multiconfig.py	Thu Jun 15 20:29:29 2006 +0200
+++ b/MoinMoin/multiconfig.py	Fri Jun 16 14:20:17 2006 +0200
@@ -272,6 +272,9 @@
     language_ignore_browser = False # ignore browser settings, use language_default
                                     # or user prefs
 
+    log_reverse_dns_lookups = True  # if we do reverse dns lookups for logging hostnames
+                                    # instead of just IPs
+
     xapian_search = False # disabled until xapian is finished
 
     mail_login = None # or "user pwd" if you need to use SMTP AUTH
--- a/docs/CHANGES	Thu Jun 15 20:29:29 2006 +0200
+++ b/docs/CHANGES	Fri Jun 16 14:20:17 2006 +0200
@@ -99,9 +99,14 @@
       types because the official ones suck)
     * renamed parsers to module names representing sane mimetypes, e.g.:
       parser.wiki -> parser.text_moin_wiki
-    * Added thread_monitor. It can be activated using:
+    * Added thread_monitor debugging aid. It can be activated using:
       from MoinMoin.util import thread_monitor; thread_monitor.activate_hook()
-      or by requesting URL ...?action=thread_monitor
+      and then triggered by requesting URL ...?action=thread_monitor - please
+      be aware that monitoring threads has a big performance impact on its own,
+      so you only want to temporarily enable this for debugging.
+      By default, it dumps its output to the data_dir as tm_<timestamp>.log,
+      you can change this at bottom of action/thread_monitor.py if you want to
+      see output in your browser.
     * Introduced scope parameter to CacheEntry() - if you specify 'farm', it
       will cache into a common directory for all wikis in the same farm, if you
       specify 'wiki', it will use a cache directory per wiki and if you specify
@@ -135,6 +140,9 @@
       To use TLS/SSL support you must also install the TLSLite library
       (http://trevp.net/tlslite/). Version 0.3.8 was used for development and
       testing.
+    * cfg.log_reverse_dns_lookups [default: True] - you can set this to False
+      if rev. dns lookups are broken in your network (leading to long delays
+      on page saves). With False, edit-log will only contain IP, not hostname.
 
   Bugfixes:
     * on action "info" page, "revert" link will not be displayed for empty page