--- a/src/pyams_content/shared/form/handler.py Wed Oct 02 10:54:20 2019 +0200
+++ b/src/pyams_content/shared/form/handler.py Thu Oct 03 14:56:57 2019 +0200
@@ -9,20 +9,23 @@
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
-
-__docformat__ = 'restructuredtext'
+from collections import OrderedDict
from persistent import Persistent
from zope.componentvocabulary.vocabulary import UtilityTerm, UtilityVocabulary
from zope.schema.fieldproperty import FieldProperty
-from pyams_content.shared.form.interfaces import IFormHandler, IMailtoHandlerInfo, IMailtoHandlerTarget
-from pyams_utils.adapter import adapter_config, get_annotation_adapter
+from pyams_content.shared.form.interfaces import IFormHandler, IMailtoHandlerInfo, \
+ IMailtoHandlerTarget
+from pyams_utils.adapter import adapter_config, get_adapter_weight, get_annotation_adapter
from pyams_utils.factory import factory_config
from pyams_utils.registry import utility_config
from pyams_utils.request import check_request
from pyams_utils.vocabulary import vocabulary_config
+
+__docformat__ = 'restructuredtext'
+
from pyams_content import _
@@ -38,8 +41,9 @@
translate = request.localizer.translate
utils = [(None, translate(_("No selected handler...")))] + \
[(name, translate(util.label))
- for (name, util) in registry.getUtilitiesFor(self.interface)]
- self._terms = dict((title, UtilityTerm(name, title)) for name, title in utils)
+ for (name, util) in sorted(registry.getUtilitiesFor(self.interface),
+ key=get_adapter_weight)]
+ self._terms = OrderedDict((title, UtilityTerm(name, title)) for name, title in utils)
def __iter__(self):
return iter(self._terms.values())
@@ -73,6 +77,8 @@
"""Mailto form handler"""
label = _("Direct mailto form handler")
+ weight = 10
+
target_interface = IMailtoHandlerTarget
handler_info = IMailtoHandlerInfo