changeset 4611:c6e4ccbbb1b3

simplified shared/htdocs processing
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Sat, 28 Feb 2009 19:34:44 +0100
parents 79480a001506
children a6461afbc0ce
files MoinMoin/web/frontend.py MoinMoin/web/serving.py
diffstat 2 files changed, 15 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/web/frontend.py	Sat Feb 28 19:25:46 2009 +0100
+++ b/MoinMoin/web/frontend.py	Sat Feb 28 19:34:44 2009 +0100
@@ -33,10 +33,7 @@
         options, args = self.parser.parse_args(args)
         logging.debug('Options: %r', options)
 
-        if options.htdocs:
-            application = make_application(shared=options.htdocs)
-        else:
-            application = make_application()
+        application = make_application(shared=options.htdocs)
 
         try:
             self.run_server(application, options)
--- a/MoinMoin/web/serving.py	Sat Feb 28 19:25:46 2009 +0100
+++ b/MoinMoin/web/serving.py	Sat Feb 28 19:34:44 2009 +0100
@@ -72,8 +72,12 @@
     Make an instance of the MoinMoin WSGI application. This involves
     wrapping it in middlewares as needed (static files, debugging, etc.).
 
-    @param shared: directory where static files are located
-    @param trusted_proxies: list of trusted proxies
+    @param shared: directory where static files are located (then we create the
+                   usual mapping dict we need automatically), or a ready-to-use
+                   mapping dict for SharedDataMiddleware. If None or empty, do
+                   not use the SharedDateMiddleware.
+    @param trusted_proxies: list of trusted proxies. If None or empty, do not
+                            use the ProxyTrust middleware.
     @rtype: callable
     @return: a WSGI callable
     """
@@ -82,17 +86,15 @@
     if trusted_proxies:
         application = ProxyTrust(application, trusted_proxies)
 
-    if isinstance(shared, dict):
+    if shared:
+        if not isinstance(shared, dict):
+            if os.path.isdir(shared):
+                shared = {config.url_prefix_static: shared,
+                          '/favicon.ico': os.path.join(shared, 'favicon.ico'),
+                          '/robots.txt': os.path.join(shared, 'robots.txt')}
+            else:
+                raise ValueError("Invalid path given for shared parameter")
         application = SharedDataMiddleware(application, shared)
-    elif shared:
-        if shared is True:
-            shared = '/usr/share/moin/htdocs'
-
-        if os.path.isdir(shared):
-            mapping = {config.url_prefix_static: shared,
-                       '/favicon.ico': os.path.join(shared, 'favicon.ico'),
-                       '/robots.txt': os.path.join(shared, 'robots.txt')}
-            application = SharedDataMiddleware(application, mapping)
 
     return application