[Checkins] SVN: zope.introspector/trunk/src/zope/introspector/meta.py Move Grokker definition to meta.py.

Uli Fouquet uli at gnufix.de
Thu Jul 3 09:09:05 EDT 2008


Log message for revision 87959:
  Move Grokker definition to meta.py.

Changed:
  A   zope.introspector/trunk/src/zope/introspector/meta.py

-=-
Added: zope.introspector/trunk/src/zope/introspector/meta.py
===================================================================
--- zope.introspector/trunk/src/zope/introspector/meta.py	                        (rev 0)
+++ zope.introspector/trunk/src/zope/introspector/meta.py	2008-07-03 13:09:04 UTC (rev 87959)
@@ -0,0 +1,47 @@
+##############################################################################
+#
+# Copyright (c) 2008 Zope Corporation and Contributors.
+# 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.
+#
+##############################################################################
+"""Grokkers that look for description providers in the framework.
+"""
+import martian
+from descriptionprovider import (DescriptionProvider, descriptor_registry,)
+
+class priority(martian.Directive):
+    """Determine in which order your descriptor provider should be applied.
+
+    The order is a number up to 1000.
+
+    This is important, because the descriptor finder will ask the
+    descriptors in the order of their priorities whether they are
+    willing to handle a certain object and normally it will return the
+    first one, that agreed to do this.
+
+    The more little the number is, the earlier your description
+    provider will appear in the list of all providers. The builtin
+    providers all have a range above 900.
+
+    The most basic description provider
+    (``SimpleDescriptionProvider``) registers with an order number of
+    1001 and handles every object.
+    """
+    scope = martian.CLASS
+    store = martian.ONCE
+    default = 500
+
+class DescriptionProviderGrokker(martian.ClassGrokker):
+    martian.component(DescriptionProvider)
+    martian.directive(priority)
+    def execute(self, klass, priority, *args, **kw):
+        descriptor_registry.append(dict(handler=klass,
+                                        priority=priority))
+        return True



More information about the Checkins mailing list