Added ZEO connection name adapter
authorThierry Florac <thierry.florac@onf.fr>
Wed, 15 Apr 2015 14:23:20 +0200
changeset 29 4bbddbc10590
parent 28 95b0d06b702d
child 30 80ae7e361ee3
Added ZEO connection name adapter
src/pyams_utils/zmi/zeo.py
--- a/src/pyams_utils/zmi/zeo.py	Wed Apr 15 14:22:37 2015 +0200
+++ b/src/pyams_utils/zmi/zeo.py	Wed Apr 15 14:23:20 2015 +0200
@@ -16,6 +16,7 @@
 # import standard library
 
 # import interfaces
+from pyams_skin.interfaces.container import ITableElementName
 from pyams_skin.interfaces.viewlet import IToolbarAddingMenu
 from pyams_skin.layer import IPyAMSLayer
 from pyams_utils.interfaces.zeo import IZEOConnection
@@ -27,6 +28,7 @@
 from pyams_form.form import AJAXAddForm, AJAXEditForm
 from pyams_pagelet.pagelet import pagelet_config
 from pyams_skin.viewlet.toolbar import ToolbarMenuItem
+from pyams_utils.adapter import adapter_config, ContextRequestAdapter
 from pyams_utils.registry import query_utility
 from pyams_utils.url import absolute_url
 from pyams_utils.zodb import ZEOConnectionUtility
@@ -41,6 +43,16 @@
 from pyams_utils import _
 
 
+@adapter_config(context=(IZEOConnection, IAdminLayer), provides=ITableElementName)
+class ZEOConnectionNameAdapter(ContextRequestAdapter):
+    """ZEO connection name adapter"""
+
+    @property
+    def name(self):
+        translate = self.request.localizer.translate
+        return translate(_("ZEO: {0}")).format(self.context.name)
+
+
 @viewlet_config(name='add-zeo-connection.menu', context=ISite, layer=IAdminLayer,
                 view=UtilitiesTable, manager=IToolbarAddingMenu, permission='system.manage')
 class ZEOConnectionAddMenu(ToolbarMenuItem):