[Checkins]
SVN: zope.introspector/branches/ulif-grokui-integration/src/zope/introspector/descriptionprovider.py
DescriptionProviders should accept dotted names to identify objects.
Uli Fouquet
uli at gnufix.de
Fri Jul 18 15:43:20 EDT 2008
Log message for revision 88535:
DescriptionProviders should accept dotted names to identify objects.
Changed:
U zope.introspector/branches/ulif-grokui-integration/src/zope/introspector/descriptionprovider.py
-=-
Modified: zope.introspector/branches/ulif-grokui-integration/src/zope/introspector/descriptionprovider.py
===================================================================
--- zope.introspector/branches/ulif-grokui-integration/src/zope/introspector/descriptionprovider.py 2008-07-18 19:42:22 UTC (rev 88534)
+++ zope.introspector/branches/ulif-grokui-integration/src/zope/introspector/descriptionprovider.py 2008-07-18 19:43:20 UTC (rev 88535)
@@ -25,28 +25,30 @@
class DescriptionFinder(grok.GlobalUtility):
"""Find a description provider.
- Find a component that takes an object and returns some kind of
- info object to describe it.
+ Find a component that takes an object or a dotted name and returns
+ some kind of info object to describe it.
"""
grok.implements(IObjectDescriptionProvider)
- def getDescription(self, obj_or_dotted_path, *args, **kw):
- obj = resolve(obj_or_dotted_path)
+ def getDescription(self, obj=None, dotted_name=None, **kw):
+ if obj is None and dotted_name is not None:
+ obj = resolve(dotted_name)
sorted_reg = sorted(descriptor_registry,
cmp = lambda x,y: x['priority'] - y['priority'])
for descriptor in sorted_reg:
+
handler = descriptor['handler']()
- if handler.canHandle(obj):
- return handler.getDescription(obj)
+ if handler.canHandle(obj, dotted_name=dotted_name):
+ return handler.getDescription(obj, dotted_name=dotted_name)
# If no descriptor could be found, we return the plainest one.
- return ObjectInfo(obj)
+ return ObjectInfo(obj, dotted_name=dotted_name)
class DescriptionProvider(object):
"""Description Providers must inherit from this to be registered.
"""
- def canHandle(self, obj, *args, **kw):
+ def canHandle(self, obj, dotted_name=None, **kw):
return False
- def getDescription(self, obj, *args, **kw):
- return ObjectInfo(obj)
+ def getDescription(self, obj, dotted_name=None, **kw):
+ return ObjectInfo(obj, dotted_name)
More information about the Checkins
mailing list