Moved module from pyams_base package
authorThierry Florac <thierry.florac@onf.fr>
Wed, 07 Oct 2015 17:48:53 +0200
changeset 51 56fc7fc505d3
parent 50 f4e90f45ebb3
child 52 19019589cc19
Moved module from pyams_base package
src/pyams_utils/zmi/intids.py
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/pyams_utils/zmi/intids.py	Wed Oct 07 17:48:53 2015 +0200
@@ -0,0 +1,51 @@
+#
+# Copyright (c) 2008-2015 Thierry Florac <tflorac AT ulthar.net>
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+
+__docformat__ = 'restructuredtext'
+
+
+# import standard library
+
+# import interfaces
+from pyams_skin.layer import IPyAMSLayer
+from pyams_utils.interfaces import VIEW_SYSTEM_PERMISSION
+from pyams_utils.interfaces.intids import IIndexLength
+from zope.intid.interfaces import IIntIds
+
+# import packages
+from pyams_pagelet.pagelet import pagelet_config
+from pyams_utils.adapter import ContextAdapter, adapter_config
+from pyams_zmi.form import AdminDialogDisplayForm
+from z3c.form import field
+
+from pyams_utils import _
+
+
+@adapter_config(context=IIntIds, provides=IIndexLength)
+class IntIdsLengthAdapter(ContextAdapter):
+    """IntIds length adapter"""
+
+    @property
+    def count(self):
+        return len(self.context)
+
+
+@pagelet_config(name='properties.html', context=IIntIds, layer=IPyAMSLayer, permission=VIEW_SYSTEM_PERMISSION)
+class IntIdsPropertiesDisplayForm(AdminDialogDisplayForm):
+    """intIds properties edit form"""
+
+    legend = _("Display indexer properties")
+    fields = field.Fields(IIndexLength)
+
+    @property
+    def title(self):
+        return self.context.__name__