changeset 5161:d751e9807213

Introduced a new config var "extensions_mapping". You can set up a mapping of attachment extensions to actions. By the drawing syntax these actions are called for the given target.
author Reimar Bauer <rb.proj AT googlemail DOT com>
date Tue, 22 Sep 2009 11:21:51 +0200
parents cb9b62a2a223
children bc06d7e092bc
files MoinMoin/action/AttachFile.py MoinMoin/config/multiconfig.py
diffstat 2 files changed, 9 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/action/AttachFile.py	Mon Sep 21 10:59:37 2009 +0200
+++ b/MoinMoin/action/AttachFile.py	Tue Sep 22 11:21:51 2009 +0200
@@ -84,15 +84,6 @@
 
 
 def get_action(request, filename, do):
-    ext_mapping = {
-        # file extension -> do -> action
-        '.tdraw': {
-            'modify': 'twikidraw',
-        },
-        '.adraw': {
-            'modify': 'anywikidraw',
-        },
-    }
     generic_do_mapping = {
         # do -> action
         'get': action_name,
@@ -104,7 +95,7 @@
         'upload_form': action_name,
     }
     basename, ext = os.path.splitext(filename)
-    do_mapping = ext_mapping.get(ext, {})
+    do_mapping = request.cfg.extensions_mapping.get(ext, {})
     action = do_mapping.get(do, None)
     if action is None:
         # we have no special support for this,
--- a/MoinMoin/config/multiconfig.py	Mon Sep 21 10:59:37 2009 +0200
+++ b/MoinMoin/config/multiconfig.py	Tue Sep 22 11:21:51 2009 +0200
@@ -698,6 +698,14 @@
 # information on the layout of this structure.
 #
 options_no_group_name = {
+  # =========================================================================
+  'attachment_extension': ("Mapping of attachment extensions to actions", None,
+  (
+   ('extensions_mapping',
+       {'.tdraw': {'modify': 'twikidraw'},
+        '.adraw': {'modify': 'anywikidraw'},
+       }, "file extension -> do -> action"),
+  )),
   # ==========================================================================
   'datastruct': ('Datastruct settings', None, (
     ('dicts', lambda cfg, request: datastruct.WikiDicts(request),