changeset 1603:767109c48208

rearrange testing setup, make moin.py runnable from toplevel dir
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Tue, 03 Oct 2006 00:17:04 +0200
parents f5773070c915
children b2322cdabd8a
files .hgignore MANIFEST.in Makefile MoinMoin/script/__init__.py MoinMoin/script/maint/mkpagepacks.py MoinMoin/script/moin.py docs/CHANGES moin.py tests/maketestwiki.py tests/runtests.py tests/wikiconfig.py wiki/server/moin.py
diffstat 12 files changed, 170 insertions(+), 158 deletions(-) [+]
line wrap: on
line diff
--- a/.hgignore	Mon Oct 02 17:41:13 2006 +0200
+++ b/.hgignore	Tue Oct 03 00:17:04 2006 +0200
@@ -3,6 +3,6 @@
 .*\.py[co]
 sa
 cover
-testwiki
+tests/wiki
 wiki/underlay
 
--- a/MANIFEST.in	Mon Oct 02 17:41:13 2006 +0200
+++ b/MANIFEST.in	Tue Oct 03 00:17:04 2006 +0200
@@ -5,6 +5,7 @@
 
 # additional files not known by setup.py
 include README MANIFEST.in setup.cfg moin.spec ChangeLog
+include moin.py wikiconfig.py
 
 # documentation and licenses
 recursive-include docs *
--- a/Makefile	Mon Oct 02 17:41:13 2006 +0200
+++ b/Makefile	Tue Oct 03 00:17:04 2006 +0200
@@ -3,9 +3,9 @@
 #
 
 # location for the wikiconfig.py we use for testing:
-export PYTHONPATH=`pwd`/tests
+export PYTHONPATH=$(PWD)/tests:$(PWD)
 
-testwiki := ./testwiki
+testwiki := ./tests/wiki
 share := ./wiki
 
 all:
@@ -51,7 +51,7 @@
 
 pagepacks:
 	@python tests/maketestwiki.py
-	@MoinMoin/script/moin.py maint mkpagepacks # must NOT use --config-dir or --wiki-url here!
+	@MoinMoin/script/moin.py --config-dir=$(testwiki)/.. maint mkpagepacks
 	cd $(share) ; rm -rf underlay
 	cp -a $(testwiki)/underlay $(share)/
 	
--- a/MoinMoin/script/__init__.py	Mon Oct 02 17:41:13 2006 +0200
+++ b/MoinMoin/script/__init__.py	Tue Oct 03 00:17:04 2006 +0200
@@ -181,9 +181,11 @@
     def mainloop(self):
         # Insert config dir or the current directory to the start of the path.
         config_dir = self.options.config_dir
-        if config_dir and not os.path.isdir(config_dir):
-            fatal("bad path given to --config-dir option")
-        sys.path.insert(0, os.path.abspath(config_dir or os.curdir))
+        if config_dir:
+            if os.path.isdir(config_dir):
+                sys.path.insert(0, os.path.abspath(config_dir))
+            else:
+                fatal("bad path given to --config-dir option")
 
         args = self.args
         if len(args) < 2:
--- a/MoinMoin/script/maint/mkpagepacks.py	Mon Oct 02 17:41:13 2006 +0200
+++ b/MoinMoin/script/maint/mkpagepacks.py	Tue Oct 03 00:17:04 2006 +0200
@@ -137,16 +137,15 @@
         if self.options.wiki_url and '.' in self.options.wiki_url:
             print "NEVER EVER RUN THIS ON A REAL WIKI!!! This must be run on a local testwiki."
             return
-        if self.options.config_dir:
-            print "NEVER EVER RUN THIS ON A REAL WIKI!!! This must be run on a local testwiki without any --config-dir!"
-            return
 
-        self.init_request() # this request will work on a test wiki in testwiki/ directory
+        self.init_request() # this request will work on a test wiki in tests/wiki/ directory
                             # we assume that there are current moinmaster pages there
         request = self.request
         request.form = request.args = request.setup_args()
 
-        if not ('testwiki' in request.cfg.data_dir and 'testwiki' in request.cfg.data_underlay_dir):
+        if not ('tests/wiki' in request.cfg.data_dir and 'tests/wiki' in request.cfg.data_underlay_dir):
+            import sys
+            print sys.path
             print "NEVER EVER RUN THIS ON A REAL WIKI!!! This must be run on a local testwiki."
             return
 
@@ -157,7 +156,7 @@
         pageSets = self.buildPageSets()
 
         print "Creating packages ..."
-        generate_filename = lambda name: os.path.join('testwiki', 'underlay', 'pages', 'SystemPagesSetup', 'attachments', '%s.zip' % name)
+        generate_filename = lambda name: os.path.join('tests', 'wiki', 'underlay', 'pages', 'SystemPagesSetup', 'attachments', '%s.zip' % name)
 
         self.packageCompoundInstaller(pageSets, generate_filename(ALL))
 
--- a/MoinMoin/script/moin.py	Mon Oct 02 17:41:13 2006 +0200
+++ b/MoinMoin/script/moin.py	Tue Oct 03 00:17:04 2006 +0200
@@ -17,7 +17,9 @@
 if __name__ == "__main__":
     # Insert the path to MoinMoin in the start of the path
     import sys, os
-    sys.path.insert(0, os.path.join(os.path.dirname(sys.argv[0]), os.pardir, os.pardir))
+    # we use position 1 (not 0) to give a config dir inserted at 0 a chance
+    # beware: we have a wikiconfig.py at the toplevel directory in the branch
+    sys.path.insert(1, os.path.join(os.path.dirname(sys.argv[0]), os.pardir, os.pardir))
 
     run()
 
--- a/docs/CHANGES	Mon Oct 02 17:41:13 2006 +0200
+++ b/docs/CHANGES	Tue Oct 03 00:17:04 2006 +0200
@@ -65,6 +65,8 @@
     get reverted.
 
   Developer notes (these should be moved to the end in the release):
+    * the testing wikiconfig moved to tests/wikiconfig.py, the testing wiki
+      is now created in tests/wiki/...
     * killed "processors" (finally), formatter method changed to:
       formatter.parser(parsername, lines)
     * refactored some actions to use ActionBase base class
@@ -165,6 +167,12 @@
     
 
   New Features:
+    * The standalone server script moved to the toplevel directory. This makes
+      it possible to directly start moin.py without additional configuration
+      to run a MoinMoin DesktopEdition like wiki setup.
+      Be careful: DesktopEdition uses relaxed security settings only suitable
+      for personal and local use.
+    * Added the MMDE scripts to contrib/DesktopEdition.
     * Removed "underscore in URL" == "blank in pagename magic" - it made more
       trouble than it was worth. If you still want to have a _ in URL, just
       put a _ into pagename.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/moin.py	Tue Oct 03 00:17:04 2006 +0200
@@ -0,0 +1,138 @@
+#!/usr/bin/env python
+"""
+    Start script for the standalone Wiki server.
+
+    @copyright: 2004-2006 Thomas Waldmann, Nir Soffer, Alexander Schremmer
+    @license: GNU GPL, see COPYING for details.
+"""
+
+print "Loading ..."
+
+import os, sys
+
+class PythonTooOldError:
+    pass
+
+try:
+    if sys.version_info[:3] < (2, 3, 0):
+        raise PythonTooOldError
+except:
+    sys.exit("Unfortunately, your installed Python is too old. Please download at "
+             "least Python 2.3.0 (Python 2.4.3 is recommended).\n\n"
+             "You can get Python here: http://www.python.org/download/")
+
+
+# We insert the path where THIS script is located into the python search path.
+# If your wikiconfig.py / farmconfig.py / etc. is located there, this is all
+# you'll need.
+moinpath = os.path.abspath(os.path.normpath(os.path.dirname(sys.argv[0])))
+sys.path.insert(0, moinpath)
+
+# Path of the directory where wikiconfig.py is located.
+# YOU MAYBE NEED TO CHANGE THIS TO MATCH YOUR SETUP.
+#sys.path.insert(0, '/path/to/wikiconfig')
+
+# 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')
+
+# Path of the directory where farmconfig is located (if different).
+#sys.path.insert(0, '/path/to/farmconfig')
+
+# Debug mode - show detailed error reports
+## import os
+## os.environ['MOIN_DEBUG'] = '1'
+
+from MoinMoin.server.standalone import StandaloneConfig, run
+from MoinMoin.version import project, release, revision
+
+print "%s - %s [%s]" % (project, release, revision)
+
+if os.name == 'nt':
+    print
+    print "Just close this window to shutdown MoinMoin DesktopEdition."
+print
+
+
+class DefaultConfig(StandaloneConfig):
+
+    # Server name
+    # Used to create .log, .pid and .prof files
+    name = 'moin'
+
+    # Path to moin shared files (default '/usr/share/moin/wiki/htdocs')
+    # If you installed with --prefix=PREFIX, use 'PREFIX/share/moin/wiki/htdocs'
+    #docs = '/usr/share/moin/htdocs'
+    # If your wiki/ directory is below the moin.py command, you don't need to
+    # change this:
+    docs = os.path.join(moinpath, 'wiki', 'htdocs')
+
+    # URL prefix for the static stuff (used to access stuff in docs) - you
+    # usually should not need to change this because moin standalone uses
+    # matching defaults for here and for wikiconfig.py:
+    #url_prefix_static = '/moin_static160'
+
+    # The server will run with as this user and group (default 'www-data')
+    #user = 'www-data'
+    #group = 'www-data'
+
+    # Port (default 8000)
+    # To serve privileged port under 1024 you will have to run as root
+    port = 8080
+
+    # Interface (default 'localhost')
+    # '' - will listen to any interface
+    interface = 'localhost'
+
+    # Log (default commented)
+    # Log is written to stderr or to a file you specify here.
+    ## logPath = name + '.log'
+
+    # Server class (default ThreadPoolServer)
+    # 'ThreadPoolServer' - create a constant pool of threads, simplified
+    # Apache worker mpm.
+    # 'ThreadingServer' - serve each request in a new thread. Much
+    # slower for static files.
+    # 'ForkingServer' - serve each request on a new child process -
+    # experimental, slow.
+    # 'SimpleServer' - server one request at a time. Fast, low
+    # memory footprint.
+    # If you set one of the threading servers and threads are not
+    # available, the server will fallback to ForkingServer. If fork is
+    # not available, the server will fallback to SimpleServer.
+    #serverClass = 'ThreadPoolServer'
+
+    # Thread limit (default 10)
+    # Limit the number of threads created. Ignored on non threaded servers.
+    #threadLimit = 10
+
+    # Request queue size (default 50)
+    # The size of the socket listen backlog.
+    #requestQueueSize = 50
+
+    # Properties
+    # Allow overriding any request property by the value defined in
+    # this dict e.g properties = {'script_name': '/mywiki'}.
+    #properties = {}
+
+    # Memory profile (default commented)
+    # Useful only if you are a developer or interested in moin memory usage
+    # A memory profile named 'moin--2004-09-27--01-24.log' is
+    # created each time you start the server.
+    ## from MoinMoin.util.profile import Profiler
+    ## memoryProfile = Profiler(name, requestsPerSample=100, collect=0)
+
+    # Hotshot profile (default commented)
+    # Not compatible with threads - use with SimpleServer only.
+    ## hotshotProfile = name + '.prof'
+
+
+try:
+    from wikiserverconfig import Config
+except ImportError:
+    Config = DefaultConfig
+
+if __name__ == '__main__':
+    # Run moin moin server:
+    run(Config)
+
--- a/tests/maketestwiki.py	Mon Oct 02 17:41:13 2006 +0200
+++ b/tests/maketestwiki.py	Tue Oct 03 00:17:04 2006 +0200
@@ -15,7 +15,7 @@
 moinpath = os.path.join(os.path.dirname(sys.argv[0]), os.pardir)
 sys.path.insert(0, os.path.abspath(moinpath))
 
-WIKI = os.path.abspath('testwiki')
+WIKI = os.path.abspath(os.path.join('tests', 'wiki'))
 SHARE = os.path.abspath('wiki')
 
 def removeTestWiki():
--- a/tests/runtests.py	Mon Oct 02 17:41:13 2006 +0200
+++ b/tests/runtests.py	Tue Oct 03 00:17:04 2006 +0200
@@ -14,14 +14,12 @@
 
 import os, sys
 
-moinpath = os.path.join(os.path.dirname(sys.argv[0]), os.pardir)
-sys.path.insert(0, os.path.abspath(moinpath))
-
 from MoinMoin import _tests
 
-def run():   
+def run():
     _tests.run(names=sys.argv[1:])
 
 
 if __name__ == '__main__':
     run()
+
--- a/tests/wikiconfig.py	Mon Oct 02 17:41:13 2006 +0200
+++ b/tests/wikiconfig.py	Tue Oct 03 00:17:04 2006 +0200
@@ -12,8 +12,8 @@
 class Config(DefaultConfig):
     sitename = u'Developer Test Wiki'
     logo_string = sitename
-    data_dir = './testwiki/data/'
-    data_underlay_dir = './testwiki/underlay/'
+    data_dir = './tests/wiki/data/'
+    data_underlay_dir = './tests/wiki/underlay/'
     show_hosts = 1                  
     # used to check if it is really a wiki we may modify 
     is_test_wiki = True
--- a/wiki/server/moin.py	Mon Oct 02 17:41:13 2006 +0200
+++ b/wiki/server/moin.py	Tue Oct 03 00:17:04 2006 +0200
@@ -1,138 +1,2 @@
-#!/usr/bin/env python
-"""
-    Start script for the standalone Wiki server.
-
-    @copyright: 2004-2006 Thomas Waldmann, Nir Soffer, Alexander Schremmer
-    @license: GNU GPL, see COPYING for details.
-"""
-
-print "Loading ..."
-
-import os, sys
-
-class PythonTooOldError:
-    pass
-
-try:
-    if sys.version_info[:3] < (2, 3, 0):
-        raise PythonTooOldError
-except:
-    sys.exit("Unfortunately, your installed Python is too old. Please download at "
-             "least Python 2.3.0 (Python 2.4.3 is recommended).\n\n"
-             "You can get Python here: http://www.python.org/download/")
-
-
-# We insert the path where THIS script is located into the python search path.
-# If your wikiconfig.py / farmconfig.py / etc. is located there, this is all
-# you'll need.
-moinpath = os.path.abspath(os.path.normpath(os.path.dirname(sys.argv[0])))
-sys.path.insert(0, moinpath)
-
-# Path of the directory where wikiconfig.py is located.
-# YOU MAYBE NEED TO CHANGE THIS TO MATCH YOUR SETUP.
-#sys.path.insert(0, '/path/to/wikiconfig')
-
-# 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')
-
-# Path of the directory where farmconfig is located (if different).
-#sys.path.insert(0, '/path/to/farmconfig')
-
-# Debug mode - show detailed error reports
-## import os
-## os.environ['MOIN_DEBUG'] = '1'
-
-from MoinMoin.server.standalone import StandaloneConfig, run
-from MoinMoin.version import project, release, revision
-
-print "%s - %s [%s]" % (project, release, revision)
-
-if os.name == 'nt':
-    print
-    print "Just close this window to shutdown MoinMoin DesktopEdition."
-print
-
-
-class DefaultConfig(StandaloneConfig):
-
-    # Server name
-    # Used to create .log, .pid and .prof files
-    name = 'moin'
-
-    # Path to moin shared files (default '/usr/share/moin/wiki/htdocs')
-    # If you installed with --prefix=PREFIX, use 'PREFIX/share/moin/wiki/htdocs'
-    #docs = '/usr/share/moin/htdocs'
-    # If your wiki/ directory is below the moin.py command, you don't need to
-    # change this:
-    docs = os.path.join(moinpath, 'wiki', 'htdocs')
+# see the toplevel directory for the real moin.py
 
-    # URL prefix for the static stuff (used to access stuff in docs) - you
-    # usually should not need to change this because moin standalone uses
-    # matching defaults for here and for wikiconfig.py:
-    #url_prefix_static = '/moin_static160'
-
-    # The server will run with as this user and group (default 'www-data')
-    #user = 'www-data'
-    #group = 'www-data'
-
-    # Port (default 8000)
-    # To serve privileged port under 1024 you will have to run as root
-    port = 8080
-
-    # Interface (default 'localhost')
-    # '' - will listen to any interface
-    interface = 'localhost'
-
-    # Log (default commented)
-    # Log is written to stderr or to a file you specify here.
-    ## logPath = name + '.log'
-
-    # Server class (default ThreadPoolServer)
-    # 'ThreadPoolServer' - create a constant pool of threads, simplified
-    # Apache worker mpm.
-    # 'ThreadingServer' - serve each request in a new thread. Much
-    # slower for static files.
-    # 'ForkingServer' - serve each request on a new child process -
-    # experimental, slow.
-    # 'SimpleServer' - server one request at a time. Fast, low
-    # memory footprint.
-    # If you set one of the threading servers and threads are not
-    # available, the server will fallback to ForkingServer. If fork is
-    # not available, the server will fallback to SimpleServer.
-    #serverClass = 'ThreadPoolServer'
-
-    # Thread limit (default 10)
-    # Limit the number of threads created. Ignored on non threaded servers.
-    #threadLimit = 10
-
-    # Request queue size (default 50)
-    # The size of the socket listen backlog.
-    #requestQueueSize = 50
-
-    # Properties
-    # Allow overriding any request property by the value defined in
-    # this dict e.g properties = {'script_name': '/mywiki'}.
-    #properties = {}
-
-    # Memory profile (default commented)
-    # Useful only if you are a developer or interested in moin memory usage
-    # A memory profile named 'moin--2004-09-27--01-24.log' is
-    # created each time you start the server.
-    ## from MoinMoin.util.profile import Profiler
-    ## memoryProfile = Profiler(name, requestsPerSample=100, collect=0)
-
-    # Hotshot profile (default commented)
-    # Not compatible with threads - use with SimpleServer only.
-    ## hotshotProfile = name + '.prof'
-
-
-try:
-    from wikiserverconfig import Config
-except ImportError:
-    Config = DefaultConfig
-
-if __name__ == '__main__':
-    # Run moin moin server:
-    run(Config)
-