changeset 3580:fc2f05f2b0bd

server adaptor scripts: make sys.path / logging configuration / comments consistent
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Sun, 11 May 2008 22:42:05 +0200
parents ff4afe930cb2
children 357cea7b7780
files wiki/server/moin.cgi wiki/server/moin.fcg wiki/server/moin.wsgi wiki/server/moin_flup_wsgi.py wiki/server/moinmodpy.htaccess wiki/server/moinmodpy.py wiki/server/mointwisted wiki/server/mointwisted.py wikiserver.py
diffstat 9 files changed, 164 insertions(+), 91 deletions(-) [+]
line wrap: on
line diff
--- a/wiki/server/moin.cgi	Sun May 11 22:38:06 2008 +0200
+++ b/wiki/server/moin.cgi	Sun May 11 22:42:05 2008 +0200
@@ -8,27 +8,31 @@
     @license: GNU GPL, see COPYING for details.
 """
 
-# System path configuration
-
-import sys
+import sys, os
 
-# Path of the directory where wikiconfig.py is located.
-# YOU NEED TO CHANGE THIS TO MATCH YOUR SETUP.
-sys.path.insert(0, '/path/to/wikiconfig')
+# a) Configuration of Python's code search path
+#    If you already have set up the PYTHONPATH environment variable for the
+#    stuff you see below, you don't need to do a1) and a2).
 
-# Path to MoinMoin package, needed if you installed with --prefix=PREFIX
-# or if you did not use setup.py.
-## sys.path.insert(0, 'PREFIX/lib/python2.3/site-packages')
+# a1) Path of the directory where the MoinMoin code package is located.
+#     Needed if you installed with --prefix=PREFIX or you didn't use setup.py.
+#sys.path.insert(0, 'PREFIX/lib/python2.3/site-packages')
 
-# Path of the directory where farmconfig.py is located (if different).
-## sys.path.insert(0, '/path/to/farmconfig')
+# a2) Path of the directory where wikiconfig.py / farmconfig.py is located.
+#     See wiki/config/... for some sample config files.
+#sys.path.insert(0, '/path/to/wikiconfigdir')
+#sys.path.insert(0, '/path/to/farmconfigdir')
+
+# b) Configuration of moin's logging
+#    If you have set up MOINLOGGINGCONF environment variable, you don't need this!
+#    You also don't need this if you are happy with the builtin defaults.
+#    See wiki/config/logging/... for some sample config files.
+#from MoinMoin import log
+#log.load_config('/path/to/logging_configuration_file')
 
 # Debug mode - show detailed error reports
-## import os
-## os.environ['MOIN_DEBUG'] = '1'
+#os.environ['MOIN_DEBUG'] = '1'
 
-from MoinMoin import log
-log.load_config('wiki/config/logging/conffile') # XXX please fix this path!
 
 from MoinMoin.server.server_cgi import CgiConfig, run
 
--- a/wiki/server/moin.fcg	Sun May 11 22:38:06 2008 +0200
+++ b/wiki/server/moin.fcg	Sun May 11 22:42:05 2008 +0200
@@ -7,25 +7,31 @@
     @license: GNU GPL, see COPYING for details.
 """
 
-import sys
+import sys, os
 
-# Path to MoinMoin package, needed if you installed with --prefix=PREFIX
-# or if you did not use setup.py.
+# a) Configuration of Python's code search path
+#    If you already have set up the PYTHONPATH environment variable for the
+#    stuff you see below, you don't need to do a1) and a2).
+
+# a1) Path of the directory where the MoinMoin code package is located.
+#     Needed if you installed with --prefix=PREFIX or you didn't use setup.py.
 #sys.path.insert(0, 'PREFIX/lib/python2.3/site-packages')
 
-# Path of the directory where wikiconfig.py is located.
-# YOU NEED TO CHANGE THIS TO MATCH YOUR SETUP.
-sys.path.insert(0, '/path/to/wikiconfig')
+# a2) Path of the directory where wikiconfig.py / farmconfig.py is located.
+#     See wiki/config/... for some sample config files.
+#sys.path.insert(0, '/path/to/wikiconfigdir')
+#sys.path.insert(0, '/path/to/farmconfigdir')
 
-# Path of the directory where farmconfig is located (if different).
-#sys.path.insert(0, '/path/to/farmconfig')
+# b) Configuration of moin's logging
+#    If you have set up MOINLOGGINGCONF environment variable, you don't need this!
+#    You also don't need this if you are happy with the builtin defaults.
+#    See wiki/config/logging/... for some sample config files.
+#from MoinMoin import log
+#log.load_config('/path/to/logging_configuration_file')
 
 # Debug mode - show detailed error reports
-#import os
 #os.environ['MOIN_DEBUG'] = '1'
 
-from MoinMoin import log
-log.load_config('wiki/config/logging/logfile') # XXX please fix this path!
 
 from MoinMoin.server.server_fastcgi import FastCgiConfig, run
 
--- a/wiki/server/moin.wsgi	Sun May 11 22:38:06 2008 +0200
+++ b/wiki/server/moin.wsgi	Sun May 11 22:42:05 2008 +0200
@@ -21,21 +21,31 @@
     @license: GNU GPL, see COPYING for details.
 """
 
-import sys
-
-# Path to MoinMoin package, needed if you installed with --prefix=PREFIX
-# or if you did not use setup.py.
-## sys.path.insert(0, 'PREFIX/lib/python2.3/site-packages')
+import sys, os
 
-# Path of the directory where farmconfig.py is located (if different).
-## sys.path.insert(0, '/path/to/farmconfig')
+# a) Configuration of Python's code search path
+#    If you already have set up the PYTHONPATH environment variable for the
+#    stuff you see below, you don't need to do a1) and a2).
 
-# Path of the directory where wikiconfig.py is located.
-# YOU NEED TO CHANGE THIS TO MATCH YOUR SETUP.
-sys.path.insert(0, '/path/to/wikiconfig')
+# a1) Path of the directory where the MoinMoin code package is located.
+#     Needed if you installed with --prefix=PREFIX or you didn't use setup.py.
+#sys.path.insert(0, 'PREFIX/lib/python2.3/site-packages')
 
-from MoinMoin import log
-log.load_config('wiki/config/logging/logfile') # XXX please fix this path!
+# a2) Path of the directory where wikiconfig.py / farmconfig.py is located.
+#     See wiki/config/... for some sample config files.
+#sys.path.insert(0, '/path/to/wikiconfigdir')
+#sys.path.insert(0, '/path/to/farmconfigdir')
+
+# b) Configuration of moin's logging
+#    If you have set up MOINLOGGINGCONF environment variable, you don't need this!
+#    You also don't need this if you are happy with the builtin defaults.
+#    See wiki/config/logging/... for some sample config files.
+#from MoinMoin import log
+#log.load_config('/path/to/logging_configuration_file')
+
+# Debug mode - show detailed error reports
+#os.environ['MOIN_DEBUG'] = '1'
+
 
 from MoinMoin.server.server_wsgi import WsgiConfig, moinmoinApp
 
--- a/wiki/server/moin_flup_wsgi.py	Sun May 11 22:38:06 2008 +0200
+++ b/wiki/server/moin_flup_wsgi.py	Sun May 11 22:42:05 2008 +0200
@@ -6,14 +6,34 @@
     @license: GNU GPL, see COPYING for details.
 """
 
+import sys, os
+
+# a) Configuration of Python's code search path
+#    If you already have set up the PYTHONPATH environment variable for the
+#    stuff you see below, you don't need to do a1) and a2).
+
+# a1) Path of the directory where the MoinMoin code package is located.
+#     Needed if you installed with --prefix=PREFIX or you didn't use setup.py.
+#sys.path.insert(0, 'PREFIX/lib/python2.3/site-packages')
+
+# a2) Path of the directory where wikiconfig.py / farmconfig.py is located.
+#     See wiki/config/... for some sample config files.
+#sys.path.insert(0, '/path/to/wikiconfigdir')
+#sys.path.insert(0, '/path/to/farmconfigdir')
+
+# b) Configuration of moin's logging
+#    If you have set up MOINLOGGINGCONF environment variable, you don't need this!
+#    You also don't need this if you are happy with the builtin defaults.
+#    See wiki/config/logging/... for some sample config files.
+#from MoinMoin import log
+#log.load_config('/path/to/logging_configuration_file')
+
+# Debug mode - show detailed error reports
+#os.environ['MOIN_DEBUG'] = '1'
+
 use_threads = True
 unixSocketPath = '/tmp/moin.sock'
 
-import os
-
-from MoinMoin import log
-log.load_config('wiki/config/logging/logfile') # XXX please fix this path!
-
 # Set threads flag, so other code can use proper locking
 from MoinMoin import config
 config.use_threads = use_threads
--- a/wiki/server/moinmodpy.htaccess	Sun May 11 22:38:06 2008 +0200
+++ b/wiki/server/moinmodpy.htaccess	Sun May 11 22:42:05 2008 +0200
@@ -13,7 +13,7 @@
   SetHandler python-program
 
   # add the path where the moinmodpy.py wrapper can be found
-  PythonPath "['/path/to/moin/share/moin/cgi-bin']+sys.path"
+  PythonPath "['/path/to/share/moin/server']+sys.path"
 
   # use the moinmodpy wrapper to handle requests
   PythonHandler moinmodpy
@@ -35,10 +35,11 @@
 #  # Use mod_python as handler
 #  SetHandler python-program
 #
-#  # set the path to the MoinMoin package and to the wikiconfig.py
-#  PythonPath "['/path/to/moin/lib/python','/path/to/wikiconfig']+sys.path"
+#  # set code search path to find farmconfig, wikiconfig and MoinMoin code package
+#  PythonPath "['/path/to/farmconfigdir', '/path/to/wikiconfigdir', '/path/to/moin/lib/python']+sys.path"
 #
 #  # choose the ModPy Request class as handler
 #  PythonHandler MoinMoin.request.request_modpython::Request.run
 #
 #</Files>
+
--- a/wiki/server/moinmodpy.py	Sun May 11 22:38:06 2008 +0200
+++ b/wiki/server/moinmodpy.py	Sun May 11 22:42:05 2008 +0200
@@ -7,7 +7,7 @@
 
     <Files wiki>
       SetHandler python-program
-      PythonPath "['/path/to/moin/share/moin/cgi-bin'] + sys.path"
+      PythonPath "['/path/to/share/moin/server'] + sys.path"
       PythonHandler moinmodpy
     </Files>
 
@@ -22,39 +22,36 @@
     look into INSTALL.html to see how you can fix the bug on your own
     (a simple one line change).
 
-    TODO: this should be refactored so it uses MoinMoin.server package
-          (see how server_twisted, server_wsgi and server_standalone use it)
-
     @copyright: 2004-2005 by Oliver Graf <ograf@bitart.de>
     @license: GNU GPL, see COPYING for details.
 """
 
-# System path configuration
-
-import sys
+import sys, os
 
-# Path of the directory where wikiconfig.py is located.
-# YOU NEED TO CHANGE THIS TO MATCH YOUR SETUP.
-sys.path.insert(0, '/path/to/wikiconfig')
+# a) Configuration of Python's code search path
+#    If you already have set up the PYTHONPATH environment variable for the
+#    stuff you see below, you don't need to do a1) and a2).
 
-# Path to MoinMoin package, needed if you installed with --prefix=PREFIX
-# or if you did not use setup.py.
-## sys.path.insert(0, 'PREFIX/lib/python2.3/site-packages')
+# a1) Path of the directory where the MoinMoin code package is located.
+#     Needed if you installed with --prefix=PREFIX or you didn't use setup.py.
+#sys.path.insert(0, 'PREFIX/lib/python2.3/site-packages')
 
-# Path of the directory where farmconfig is located (if different).
-## sys.path.insert(0, '/path/to/farmconfig')
+# a2) Path of the directory where wikiconfig.py / farmconfig.py is located.
+#     See wiki/config/... for some sample config files.
+#sys.path.insert(0, '/path/to/wikiconfigdir')
+#sys.path.insert(0, '/path/to/farmconfigdir')
+
+# b) Configuration of moin's logging
+#    If you have set up MOINLOGGINGCONF environment variable, you don't need this!
+#    You also don't need this if you are happy with the builtin defaults.
+#    See wiki/config/logging/... for some sample config files.
+#from MoinMoin import log
+#log.load_config('/path/to/logging_configuration_file')
 
 # Debug mode - show detailed error reports
-## import os
-## os.environ['MOIN_DEBUG'] = '1'
+#os.environ['MOIN_DEBUG'] = '1'
 
-from MoinMoin import log
-log.load_config('wiki/config/logging/conffile') # XXX please fix this path!
 
-# Simple way
-#from MoinMoin.server.server_modpython import modpythonHandler as handler
-
-# Complex way
 from MoinMoin.server.server_modpython import ModpythonConfig, modpythonHandler
 
 class MyConfig(ModpythonConfig):
--- a/wiki/server/mointwisted	Sun May 11 22:38:06 2008 +0200
+++ b/wiki/server/mointwisted	Sun May 11 22:42:05 2008 +0200
@@ -6,14 +6,29 @@
     @license: GNU GPL, see COPYING for details.
 """
 
-# Add the path to mointwisted.py directory 
-## import sys
-## sys.path.insert(0, '/path/to/mointwisted')
+import sys, os
 
-import os
+# a) Configuration of Python's code search path
+#    If you already have set up the PYTHONPATH environment variable for the
+#    stuff you see below, you don't need to do a1) and a2).
 
-from MoinMoin import log
-log.load_config('wiki/config/logging/logfile') # XXX please fix this path!
+# a1) Path of the directory where the MoinMoin code package is located.
+#     Needed if you installed with --prefix=PREFIX or you didn't use setup.py.
+#sys.path.insert(0, 'PREFIX/lib/python2.3/site-packages')
+
+# a2) Path of the directory where mointwisted.py is located.
+#sys.path.insert(0, '/path/to/mointwisted')
+
+# b) Configuration of moin's logging
+#    If you have set up MOINLOGGINGCONF environment variable, you don't need this!
+#    You also don't need this if you are happy with the builtin defaults.
+#    See wiki/config/logging/... for some sample config files.
+#from MoinMoin import log
+#log.load_config('/path/to/logging_configuration_file')
+
+# Debug mode - show detailed error reports
+#os.environ['MOIN_DEBUG'] = '1'
+
 
 from MoinMoin.server import daemon
 from mointwisted import Config
--- a/wiki/server/mointwisted.py	Sun May 11 22:38:06 2008 +0200
+++ b/wiki/server/mointwisted.py	Sun May 11 22:42:05 2008 +0200
@@ -8,24 +8,31 @@
     @license: GNU GPL, see COPYING for details.
 """
 
-# System path configuration
-
-import sys
+import sys, os
 
-# Path of the directory where wikiconfig.py is located.
-# YOU NEED TO CHANGE THIS TO MATCH YOUR SETUP.
-sys.path.insert(0, '/path/to/wikiconfig')
+# a) Configuration of Python's code search path
+#    If you already have set up the PYTHONPATH environment variable for the
+#    stuff you see below, you don't need to do a1) and a2).
 
-# Path to MoinMoin package, needed if you installed with --prefix=PREFIX
-# or if you did not use setup.py
-## sys.path.insert(0, 'PREFIX/lib/python2.3/site-packages')
+# a1) Path of the directory where the MoinMoin code package is located.
+#     Needed if you installed with --prefix=PREFIX or you didn't use setup.py.
+#sys.path.insert(0, 'PREFIX/lib/python2.3/site-packages')
 
-# Path to the directory where farmconfig is located (if different).
-## sys.path.insert(0, '/path/to/farmconfig')
+# a2) Path of the directory where wikiconfig.py / farmconfig.py is located.
+#     See wiki/config/... for some sample config files.
+#sys.path.insert(0, '/path/to/wikiconfigdir')
+#sys.path.insert(0, '/path/to/farmconfigdir')
+
+# b) Configuration of moin's logging
+#    If you have set up MOINLOGGINGCONF environment variable, you don't need this!
+#    You also don't need this if you are happy with the builtin defaults.
+#    See wiki/config/logging/... for some sample config files.
+#from MoinMoin import log
+#log.load_config('/path/to/logging_configuration_file')
 
 # Debug mode - show detailed error reports
-## import os
-## os.environ['MOIN_DEBUG'] = '1'
+#os.environ['MOIN_DEBUG'] = '1'
+
 
 from MoinMoin.server.server_twisted import TwistedConfig, makeApp
 
--- a/wikiserver.py	Sun May 11 22:38:06 2008 +0200
+++ b/wikiserver.py	Sun May 11 22:42:05 2008 +0200
@@ -6,21 +6,34 @@
     @license: GNU GPL, see COPYING for details.
 """
 
-import os, sys
+import sys, os
 
-# Path to MoinMoin package, needed if you installed with --prefix=PREFIX
-# or if you did not use setup.py.
+# a) Configuration of Python's code search path
+#    If you already have set up the PYTHONPATH environment variable for the
+#    stuff you see below, you don't need to do a1) and a2).
+
+# a1) Path of the directory where the MoinMoin code package is located.
+#     Needed if you installed with --prefix=PREFIX or you didn't use setup.py.
 #sys.path.insert(0, 'PREFIX/lib/python2.3/site-packages')
 
+# a2) Path of the directory where wikiconfig.py / farmconfig.py is located.
 moinpath = os.path.abspath(os.path.normpath(os.path.dirname(sys.argv[0])))
 sys.path.insert(0, moinpath)
 os.chdir(moinpath)
 
+# b) Configuration of moin's logging
+#    If you have set up MOINLOGGINGCONF environment variable, you don't need this!
+#    You also don't need this if you are happy with the builtin defaults.
+#    See wiki/config/logging/... for some sample config files.
 from MoinMoin import log
 log.load_config('wikiserverlogging.conf')
 
+# Debug mode - show detailed error reports
+#os.environ['MOIN_DEBUG'] = '1'
+
 from MoinMoin.script import MoinScript
 
 if __name__ == '__main__':
     sys.argv = ["moin.py", "server", "standalone"]
     MoinScript().run()
+