changeset 1826:8231bca193ef

Demote priority in registry entries so that it is only compared when other fields are equal.
author Cheer Xiao <xiaqqaix@gmail.com>
date Thu, 04 Oct 2012 00:13:22 +0800
parents 38632887ca57
children d4ad8f78afbf
files MoinMoin/converter/__init__.py MoinMoin/converter/everything.py MoinMoin/converter/pygments_in.py MoinMoin/converter/text_in.py MoinMoin/items/content.py
diffstat 5 files changed, 10 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/converter/__init__.py	Mon Oct 01 23:38:17 2012 +0800
+++ b/MoinMoin/converter/__init__.py	Thu Oct 04 00:13:22 2012 +0800
@@ -34,12 +34,12 @@
 
         def __lt__(self, other):
             if isinstance(other, self.__class__):
-                if self.priority != other.priority:
-                    return self.priority < other.priority
                 if self.type_output != other.type_output:
                     return other.type_output.issupertype(self.type_output)
                 if self.type_input != other.type_input:
                     return other.type_input.issupertype(self.type_input)
+                if self.priority != other.priority:
+                    return self.priority < other.priority
                 return False
             return NotImplemented
 
--- a/MoinMoin/converter/everything.py	Mon Oct 01 23:38:17 2012 +0800
+++ b/MoinMoin/converter/everything.py	Thu Oct 04 00:13:22 2012 +0800
@@ -34,7 +34,5 @@
 
 from . import default_registry
 from MoinMoin.util.mime import Type, type_moin_document
-default_registry.register(Converter._factory, Type('application/octet-stream'), type_moin_document,
-                          default_registry.PRIORITY_MIDDLE + 3)
-default_registry.register(Converter._factory, Type(type=None, subtype=None), type_moin_document,
-                          default_registry.PRIORITY_MIDDLE + 3)
+default_registry.register(Converter._factory, Type('application/octet-stream'), type_moin_document)
+default_registry.register(Converter._factory, Type(type=None, subtype=None), type_moin_document)
--- a/MoinMoin/converter/pygments_in.py	Mon Oct 01 23:38:17 2012 +0800
+++ b/MoinMoin/converter/pygments_in.py	Thu Oct 04 00:13:22 2012 +0800
@@ -115,12 +115,8 @@
 
     from . import default_registry
     from MoinMoin.util.mime import Type, type_moin_document
-    # Pygments type detection is rather expensive, therefore we want to register
-    # after all normal parsers but before the compatibility parsers and wildcard
-    default_registry.register(Converter._factory, Type(type='text'), type_moin_document,
-                              default_registry.PRIORITY_MIDDLE + 1)
-    default_registry.register(Converter._factory, Type('x-moin/format'), type_moin_document,
-                              default_registry.PRIORITY_MIDDLE + 1)
+    default_registry.register(Converter._factory, Type(type='text'), type_moin_document)
+    default_registry.register(Converter._factory, Type('x-moin/format'), type_moin_document)
 
 else:
     # we have no Pygments, minimal Converter replacement, so highlight view does not crash
--- a/MoinMoin/converter/text_in.py	Mon Oct 01 23:38:17 2012 +0800
+++ b/MoinMoin/converter/text_in.py	Thu Oct 04 00:13:22 2012 +0800
@@ -42,5 +42,6 @@
 
 from . import default_registry
 from MoinMoin.util.mime import Type, type_moin_document
+# Assign a lower priority (= bigger number) so that it is tried after pygments_in
 default_registry.register(Converter._factory, Type(type='text'), type_moin_document,
-                          default_registry.PRIORITY_MIDDLE + 2)
+                          default_registry.PRIORITY_MIDDLE + 1)
--- a/MoinMoin/items/content.py	Mon Oct 01 23:38:17 2012 +0800
+++ b/MoinMoin/items/content.py	Thu Oct 04 00:13:22 2012 +0800
@@ -82,10 +82,10 @@
 
         def __lt__(self, other):
             if isinstance(other, self.__class__):
+                if self.content_type != other.content_type:
+                    return other.content_type.issupertype(self.content_type)
                 if self.priority != other.priority:
                     return self.priority < other.priority
-                if self.content_type != other.content_type:
-                    return other.content_type.issupertype(self.content_type)
                 return False
             return NotImplemented