changeset 2253:2c8f25796120

merged main
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Mon, 25 Jun 2007 20:49:51 +0200
parents ece659592dd9 (current diff) 4197965b0820 (diff)
children 564dee5eb254
files
diffstat 4 files changed, 34 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/Page.py	Mon Jun 25 20:49:29 2007 +0200
+++ b/MoinMoin/Page.py	Mon Jun 25 20:49:51 2007 +0200
@@ -734,8 +734,7 @@
 
         # look for the end of words and the start of a new word,
         # and insert a space there
-        split_re = re.compile('([%s])([%s])' % (config.chars_lower, config.chars_upper))
-        splitted = split_re.sub(r'\1 \2', self.page_name)
+        splitted = config.split_regex.sub(r'\1 \2', self.page_name)
         return splitted
 
     def url(self, request, querystr=None, anchor=None, relative=True, **kw):
--- a/MoinMoin/config/__init__.py	Mon Jun 25 20:49:29 2007 +0200
+++ b/MoinMoin/config/__init__.py	Mon Jun 25 20:49:51 2007 +0200
@@ -34,6 +34,9 @@
 # benefit for the user. IMPORTANT: use only lowercase 'utf-8'!
 charset = 'utf-8'
 
+# Regex to find lower->upper transitions (word boundaries in WikiNames), used by split_title
+split_regex = re.compile('([%s])([%s])' % (chars_lower, chars_upper), re.UNICODE)
+
 # Invalid characters - invisible characters that should not be in page
 # names. Prevent user confusion and wiki abuse, e.g u'\u202aFrontPage'.
 page_invalid_chars_regex = re.compile(
--- a/MoinMoin/server/STANDALONE.py	Mon Jun 25 20:49:29 2007 +0200
+++ b/MoinMoin/server/STANDALONE.py	Mon Jun 25 20:49:51 2007 +0200
@@ -485,8 +485,17 @@
 
 def quit(signo, stackframe):
     """ Signal handler for aborting signals """
-    global httpd
+    global httpd, config
     logging.info("Thanks for using MoinMoin!")
+
+    fname = config.pycallgraph_output
+    if fname:
+         import pycallgraph
+         if fname.endswith('.png'):
+             pycallgraph.make_dot_graph(fname)
+         elif fname.endswith('.dot'):
+             pycallgraph.save_dot(fname)
+         
     if httpd:
         httpd.die()
 
@@ -550,7 +559,7 @@
     # Development options
     memoryProfile = None
     hotshotProfile = None
-
+    pycallgraph_output = None
 
 def run(configClass):
     """ Create and run a moin server
@@ -580,6 +589,20 @@
         MoinRequestHandler.serve_moin = memoryProfileDecorator(
             MoinRequestHandler.serve_moin, config.memoryProfile)
 
+    # initialize pycallgraph, if wanted
+    if config.pycallgraph_output:
+        try:
+            import pycallgraph
+            pycallgraph.settings['include_stdlib'] = False
+            pcg_filter = pycallgraph.GlobbingFilter(exclude=['pycallgraph.*',
+                                                             'unknown.*',
+                                                    ],
+                                                    max_depth=9999)
+            pycallgraph.start_trace(reset=True, filter_func=pcg_filter)
+        except ImportError:
+            config.pycallgraph_output = None
+
+
     registerSignalHandlers(quit)
     httpd = makeServer(config)
 
--- a/moin.py	Mon Jun 25 20:49:29 2007 +0200
+++ b/moin.py	Mon Jun 25 20:49:51 2007 +0200
@@ -127,6 +127,11 @@
     # Not compatible with threads - use with SimpleServer only.
     ## hotshotProfile = name + '.prof'
 
+    # Using pycallgraph to make nice graphics of how moin works internally
+    # hint: using zgrviewer to view .dot is much more effective than using
+    #       some .png viewer
+    ##pycallgraph_output = 'moin-pycallgraph.dot' # can be either .dot or .png
+    ##serverClass = 'SimpleServer' # pycallgraph doesn't support multithreading
 
 try:
     from wikiserverconfig import Config