[Checkins] SVN: zope.introspector/trunk/src/zope/introspector/
Simplification of zope.introspector:
Martijn Faassen
faassen at infrae.com
Tue Jul 22 10:28:05 EDT 2008
Log message for revision 88692:
Simplification of zope.introspector:
* no more rule-based custom system for lookup of IInfo objects
* component architecture way of looking up all IInfos for an object
* disabled a lot of tests, this all still needs to be cleaned up
Changed:
U zope.introspector/trunk/src/zope/introspector/README.txt
U zope.introspector/trunk/src/zope/introspector/__init__.py
D zope.introspector/trunk/src/zope/introspector/descriptionprovider.py
D zope.introspector/trunk/src/zope/introspector/descriptionprovider.txt
D zope.introspector/trunk/src/zope/introspector/infoproviders.py
A zope.introspector/trunk/src/zope/introspector/infos.py
U zope.introspector/trunk/src/zope/introspector/interfaces.py
A zope.introspector/trunk/src/zope/introspector/introspector.txt
U zope.introspector/trunk/src/zope/introspector/meta.py
U zope.introspector/trunk/src/zope/introspector/meta.zcml
U zope.introspector/trunk/src/zope/introspector/objectinfo.py
U zope.introspector/trunk/src/zope/introspector/objectinfo.txt
D zope.introspector/trunk/src/zope/introspector/tests/descriptorgrokker.txt
U zope.introspector/trunk/src/zope/introspector/viewinfo.py
-=-
Modified: zope.introspector/trunk/src/zope/introspector/README.txt
===================================================================
--- zope.introspector/trunk/src/zope/introspector/README.txt 2008-07-22 14:06:21 UTC (rev 88691)
+++ zope.introspector/trunk/src/zope/introspector/README.txt 2008-07-22 14:28:04 UTC (rev 88692)
@@ -1,7 +1,7 @@
-zope.introspector
+gzope.introspector
**********************
-:Test-Layer: unit
+:Test-Layer: nonunit
The `zope.introspector` package provides an extensible framework
for retrieving 'data' on 'entities'. It makes use of
Modified: zope.introspector/trunk/src/zope/introspector/__init__.py
===================================================================
--- zope.introspector/trunk/src/zope/introspector/__init__.py 2008-07-22 14:06:21 UTC (rev 88691)
+++ zope.introspector/trunk/src/zope/introspector/__init__.py 2008-07-22 14:28:04 UTC (rev 88692)
@@ -15,11 +15,4 @@
$Id$
"""
-from objectinfo import ObjectInfo, ModuleInfo, PackageInfo, TypeInfo
from meta import priority
-from descriptionprovider import DescriptionProvider
-
-from zope.introspector.interfaces import IIntrospectorAPI
-from zope.interface import moduleProvides
-moduleProvides(IIntrospectorAPI)
-__all__ = list(IIntrospectorAPI)
Deleted: zope.introspector/trunk/src/zope/introspector/descriptionprovider.py
===================================================================
--- zope.introspector/trunk/src/zope/introspector/descriptionprovider.py 2008-07-22 14:06:21 UTC (rev 88691)
+++ zope.introspector/trunk/src/zope/introspector/descriptionprovider.py 2008-07-22 14:28:04 UTC (rev 88692)
@@ -1,54 +0,0 @@
-##############################################################################
-#
-# 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.
-#
-##############################################################################
-"""Provide description objects for arbitrary objects.
-"""
-import grokcore.component as grok
-from zope.introspector.interfaces import (IObjectDescriptionProvider,
- IObjectInfo)
-from zope.introspector.objectinfo import ObjectInfo
-from zope.introspector.util import resolve
-
-# The descriptor provider registry
-descriptor_registry = []
-
-class DescriptionFinder(grok.GlobalUtility):
- """Find a description provider.
-
- 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=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, 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, dotted_name=dotted_name)
-
-class DescriptionProvider(object):
- """Description Providers must inherit from this to be registered.
- """
- def canHandle(self, obj, dotted_name=None, **kw):
- return False
-
- def getDescription(self, obj, dotted_name=None, **kw):
- return ObjectInfo(obj, dotted_name)
-
Deleted: zope.introspector/trunk/src/zope/introspector/descriptionprovider.txt
===================================================================
--- zope.introspector/trunk/src/zope/introspector/descriptionprovider.txt 2008-07-22 14:06:21 UTC (rev 88691)
+++ zope.introspector/trunk/src/zope/introspector/descriptionprovider.txt 2008-07-22 14:28:04 UTC (rev 88692)
@@ -1,213 +0,0 @@
-Description Providers
-*********************
-
-:Test-Layer: functional
-
-or: how to get a description providers for arbitrary objects in an
-extensible and flexible manner.
-
-``zope.introspector.descriptionprovider`` offers objects, grokkers and
-utilities to get a suitable description for arbitrary objects in a
-running Zope framework.
-
-
-Introspecting objects
-=====================
-
-Before we go into the details of the local implementation some words
-might be allowed about the problem that has to be solved here and how
-other packages cope with it.
-
-``zope.introspector`` is a package for getting information about a
-runtime system running a Zope framework. As such it has to provide
-descriptions for many kinds of objects. The descriptions in turn are
-generally thought to be used by viewing components, that might be
-specialists for the different kinds of objects that the introspector
-is able to handle.
-
-Stage 1: Transforming an request/URL into an object/dotted path
----------------------------------------------------------------
-
-The decision about the right kind of descriptor could for instance be
-made by a traverser, that looks up a certain object in the runtime
-system based on a request sent. The traverser could transform a URL
-into a dotted path or a certain object (and possibly additional
-context parameters), ask the introspector for an appropriate
-description object and render that using an approriate view.
-
-A traversable URL for retrieving a description of the
-``zope.introspector`` package therefore could look like this:
-
- http://localhost/code/zope/introspector
-
-where the `code` part of the URL describes the type of information we
-want and `zope/introspector` would denote the dotted path we want to
-examine.
-
-All this could of course also be done by HTTP parameters in an URL
-like this::
-
- http://localhost/?type=code&object=zope.introspector
-
-It doesn't matter which type of URL transformation we finally
-implement (most likely we will use skins), but we need such a
-transformer in our information flow.
-
-
-Stage 2: Transforming an object/dotted path into a description
---------------------------------------------------------------
-
-This leads to the question: how can we know what type of object we
-currently handle and what handler(s) is/are available to describe it?
-
-For this purpose we need a component that is able to do the
-transformation as described in the headline. The information flow
-looks like this::
-
- URL --> object/dotted path --> description object
-
-One general problem we have to deal with therefore is: how can we
-automatically provide a description as concise as possible while
-giving third-party developers the opportunity to extend the
-introspection machine as easy and flexible as possible.
-
-
-Using fixed sets for object-description transformation
-------------------------------------------------------
-
-One solution of the problem is to define a fixed set of things that
-can be introspected, say, Python modules, classes and
-functions. Having such a fixrd set of descriptors (let's call it
-``ModuleInfo``, ``ClassInfo``, etc.) we can do a simple if-elif-else
-cascade like this::
-
- if isinstance(obj, Interface):
- return InterfaceInfo(obj)
- elif self.isPackage(obj):
- return PackageInfo(obj)
- ...
- else:
- return ObjectInfo(obj)
-
-This is the way ``zope.app.apidoc`` handles things. It is clean, plain
-and works.
-
-Unforuntately, it also suffers from an important shortcoming: the set
-of objects to describe is fixed and cannot be extended easily by
-third-party modules. This can be a problem.
-
-Let's imagine, we'd like to describe a Grok application. Grok
-applications are classes derived from ``grok.application`` and they
-can be configured using Grok directives and other nice things.
-
-When we ask ``zope.app.apidoc`` to describe a ``grok.Application``
-class, we get a plain class description, which does not mention the
-direcives used or (possibly more important) not used.
-
-We can, of course, write a representation of Grok applications
-ourselves, that is able to deliver us all directives (used and
-unused), but: we cannot hook that representation into
-``zope.app.apidoc`` documentation. That's because the package uses the
-above described fixed set of representations.
-
-
-Using grokkers for object-description transformation
-----------------------------------------------------
-
-So the new question is: how can we define object descriptions in a
-way, that thid-party developers are able to extend it with their own
-descriptions?
-
-
-The grok.admin.docgrok approach
--------------------------------
-
-The ``grok.admin.docgrok`` module solves this problem by using martian
-grokkers and providing a module function that looks up a registry to
-hook up any special representations found in the runtime system.
-
-Adding a representation then means to write a class that derives from
-a certain base and is able to decide itself whether it is able to
-handle certain objects. At framework startup this class then will be
-grokked and added as a possible description deliverer to a registry of
-all description providers.
-
-A module level function then looks up this registry on request, asks
-the different description providers whether they are able to handle a
-certain object and returns the first that approves it.
-
-The whole thing looks like this:
-
-1) At startup:
-
- - Create registry with object description providers
-
- - Fill registry with all object description providers (done by
- class grokker)
-
-2) On request:
-
- a) transform URL into object/dotted path to look up
-
- b) call get_descriptor_for(dotted_path)
-
- i) ask all description providers in registry for description
- of dotted_path
-
- ii) return first description
-
- c) publisher looks up a view for the specific description returned
-
-Afterwards we can for instance get any object, pass it to
-the representation function and aks: are you able to handle this
-object? The class answers by delivering a description object or
-``None``.
-
-The following is a modified variant of this grok.admin.docgrok
-approach.
-
-
-We do similar but even more flexible processing in
-``zope.introspection``. Instead of a module function we provide a
-utility implementing ``IObjectDescriptorProvider``. This way a
-third-party package has not to care for the exact location or type of
-the callable.
-
-
-Providing descriptions for arbitrary objects
-============================================
-
-We define a simple object that we want to have described later on::
-
- >>> obj = object()
-
-``zope.introspector`` provides many different kinds of descriptions
-for different object types. To get the description that suits an
-object best, there is a utility available. It implements the
-``IObjectDescriptionProvider`` interface. We get this utility::
-
- >>> from zope.component import getUtility
- >>> from zope.introspector.interfaces import IObjectDescriptionProvider
- >>> provider = getUtility(IObjectDescriptionProvider)
- >>> provider
- <zope.introspector.descriptionprovider.DescriptionFinder object at 0x...>
-
-This utility takes objects or dotted names and returns descriptions
-for it::
-
- >>> provider.getDescription(obj)
- <zope.introspector.objectinfo.ObjectInfo object at 0x...>
-
-If we pass another kind of object, we might get a different kind of
-description. We load the zope.introspector package and want a
-description for it::
-
- >>> import zope.introspector.tests
- >>> provider.getDescription(zope.introspector.tests)
- <zope.introspector.objectinfo.PackageInfo object at 0x...>
-
-We can also pass dotted names to describe the object we want to be
-examined::
-
- >>> provider.getDescription(dotted_name='zope.introspector.tests')
- <zope.introspector.objectinfo.PackageInfo object at 0x...>
Deleted: zope.introspector/trunk/src/zope/introspector/infoproviders.py
===================================================================
--- zope.introspector/trunk/src/zope/introspector/infoproviders.py 2008-07-22 14:06:21 UTC (rev 88691)
+++ zope.introspector/trunk/src/zope/introspector/infoproviders.py 2008-07-22 14:28:04 UTC (rev 88692)
@@ -1,43 +0,0 @@
-##############################################################################
-#
-# 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.
-#
-##############################################################################
-"""Provide description objects for arbitrary objects.
-"""
-import inspect
-import martian
-from zope.introspector.meta import priority
-from zope.introspector.descriptionprovider import DescriptionProvider
-from zope.introspector.interfaces import IObjectInfo
-from zope.introspector.objectinfo import ObjectInfo, PackageInfo
-
-class SimpleDescriptionProvider(DescriptionProvider):
- name = 'simple'
- priority(1001)
- def getDescription(self, obj, dotted_name=None, **kw):
- return ObjectInfo(obj, dotted_name=dotted_name)
-
- def canHandle(self, obj, dotted_name=None, **kw):
- return True
-
-
-class PackageDescriptionProvider(DescriptionProvider):
- name = 'package'
- priority(1000)
- def getDescription(self, obj, **kw):
- return PackageInfo(obj)
-
- def canHandle(self, obj=None, dotted_name=None, **kw):
- if not inspect.ismodule(obj):
- return False
- info = martian.scan.module_info_from_module(obj)
- return info.isPackage()
Added: zope.introspector/trunk/src/zope/introspector/infos.py
===================================================================
--- zope.introspector/trunk/src/zope/introspector/infos.py (rev 0)
+++ zope.introspector/trunk/src/zope/introspector/infos.py 2008-07-22 14:28:04 UTC (rev 88692)
@@ -0,0 +1,12 @@
+import grokcore.component as grok
+from zope import component
+from zope.interface import Interface
+from zope.introspector.interfaces import IInfos, IInfo
+
+class Infos(grok.Adapter):
+ grok.context(Interface)
+ grok.provides(IInfos)
+
+ def infos(self):
+ return component.getAdapters((self.context,), IInfo)
+
Modified: zope.introspector/trunk/src/zope/introspector/interfaces.py
===================================================================
--- zope.introspector/trunk/src/zope/introspector/interfaces.py 2008-07-22 14:06:21 UTC (rev 88691)
+++ zope.introspector/trunk/src/zope/introspector/interfaces.py 2008-07-22 14:28:04 UTC (rev 88692)
@@ -15,26 +15,18 @@
"""
from zope import interface
-class IIntrospectorBaseClasses(interface.Interface):
- priority = interface.Attribute(
- "Directive for use in description providers")
- DescriptionProvider = interface.Attribute(
- "A component that delivers a suitable description object "
- "for certain kinds of objects."
- )
- ObjectInfo = interface.Attribute("Basic Object Information")
- ModuleInfo = interface.Attribute("Information about a module")
- PackageInfo = interface.Attribute("Information about a package")
- TypeInfo = interface.Attribute("Information about a basic type")
- RegistryInfo = interface.Attribute(
- "Information about the component registry")
-
-class IIntrospectorAPI(IIntrospectorBaseClasses):
- """The API of zope.introspector.
+class IInfos(interface.Interface):
+ """Give all IInfo adapters relevant for this object.
"""
- pass
+ def infos():
+ """Return the applicable infos.
+ """
-class IObjectInfo(interface.Interface):
+class IInfo(interface.Interface):
+ """Introspection information about an aspect of an object.
+ """
+
+class IObjectInfo(IInfo):
"""Information about simple types.
"""
def getType():
@@ -73,18 +65,24 @@
"""Returns all methods of the object.
"""
-class IModuleInfo(interface.Interface):
+class IModuleInfo(IInfo):
"""Information about modules.
"""
pass
-class IPackageInfo(interface.Interface):
+class IPackageInfo(IInfo):
"""Information about packages.
"""
def getPackageFiles():
"""Get the package files contained in a package.
"""
+class ITypeInfo(IInfo):
+ """Information about types.
+ """
+ pass
+
+
class IUtilityInfo(interface.Interface):
"""Information about utilities available to an object.
"""
@@ -92,11 +90,6 @@
"""Get all utilities available to an object.
"""
-class ITypeInfo(interface.Interface):
- """Information about types.
- """
- pass
-
class IRegistryInfo(interface.Interface):
"""Keeps information about the Component registry.
"""
@@ -166,7 +159,7 @@
""" Returns the registration
"""
-class IViewInfo(interface.Interface):
+class IViewInfo(IInfo):
"""The representation of an object that has views associated.
"""
@@ -186,11 +179,4 @@
The default layer will be returned with u'' as the skin name.
"""
-
-class IObjectDescriptionProvider(interface.Interface):
- """Provide description objects for arbitrary objects.
- """
- def getDescription(obj, dotted_name=None, *args, **kw):
- """Get one description object for the object denoted by
- ``obj`` or ``dotted_name``.
- """
+
Added: zope.introspector/trunk/src/zope/introspector/introspector.txt
===================================================================
--- zope.introspector/trunk/src/zope/introspector/introspector.txt (rev 0)
+++ zope.introspector/trunk/src/zope/introspector/introspector.txt 2008-07-22 14:28:04 UTC (rev 88692)
@@ -0,0 +1,31 @@
+Introspector
+************
+
+:Test-Layer: functional
+
+When we introspect an object, we want to find out information on
+whatever aspects the introspector can provide. An introspection aspect
+is called an ``IInfo``.
+
+ >>> from grokcore.component.testing import grok
+ >>> grok('zope.introspector')
+
+Let's make an object to introspect::
+
+ >>> class Foo(object):
+ ... pass
+ >>> foo = Foo()
+
+Let's see what ``IInfo`` objects exist for ``foo``. In order to
+retrieve all of them, we can use the ``IInfos`` adapter::
+
+ >>> from zope.introspector.interfaces import IInfos
+ >>> infos = IInfos(foo)
+
+And then in order to find all ``IInfo`` objects, we call the ``infos``
+method. There are a few standard ``Infos`` available for all objects, so
+we'll find them::
+
+ >>> sorted(infos.infos())
+ [(u'object', <zope.introspector.objectinfo.ObjectInfo object at ...),
+ (u'view', <zope.introspector.viewinfo.ViewInfo object at ...>)]
Modified: zope.introspector/trunk/src/zope/introspector/meta.py
===================================================================
--- zope.introspector/trunk/src/zope/introspector/meta.py 2008-07-22 14:06:21 UTC (rev 88691)
+++ zope.introspector/trunk/src/zope/introspector/meta.py 2008-07-22 14:28:04 UTC (rev 88692)
@@ -14,7 +14,6 @@
"""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.
@@ -37,19 +36,3 @@
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):
- num = 0
- found = False
- for num in range(0, len(descriptor_registry)):
- if descriptor_registry[num]['priority'] >= priority:
- found = True
- break
- if not found and num:
- num += 1
- descriptor_registry.insert(num, dict(handler=klass,
- priority=priority))
- return True
Modified: zope.introspector/trunk/src/zope/introspector/meta.zcml
===================================================================
--- zope.introspector/trunk/src/zope/introspector/meta.zcml 2008-07-22 14:06:21 UTC (rev 88691)
+++ zope.introspector/trunk/src/zope/introspector/meta.zcml 2008-07-22 14:28:04 UTC (rev 88692)
@@ -3,6 +3,5 @@
i18n_domain="zope.introspector">
<include package="grokcore.component" file="meta.zcml" />
- <grok:grok package=".meta" />
</configure>
Modified: zope.introspector/trunk/src/zope/introspector/objectinfo.py
===================================================================
--- zope.introspector/trunk/src/zope/introspector/objectinfo.py 2008-07-22 14:06:21 UTC (rev 88691)
+++ zope.introspector/trunk/src/zope/introspector/objectinfo.py 2008-07-22 14:28:04 UTC (rev 88692)
@@ -24,7 +24,8 @@
class ObjectInfo(grok.Adapter):
grok.implements(IObjectInfo)
grok.context(Interface)
-
+ grok.name('object')
+
dotted_name = None
def __init__(self, obj):
@@ -79,11 +80,13 @@
grok.implements(IModuleInfo)
grok.provides(IObjectInfo)
grok.context(types.ModuleType)
-
+ grok.name('module')
+
class PackageInfo(ModuleInfo):
grok.implements(IPackageInfo)
grok.provides(IPackageInfo)
-
+ grok.name('package')
+
def getPackageFiles(self, filter=None):
pkg_file_path = os.path.dirname(self.obj.__file__)
return sorted([x for x in os.listdir(pkg_file_path)
@@ -94,4 +97,4 @@
grok.implements(ITypeInfo)
grok.provides(IObjectInfo)
grok.context(types.TypeType)
-
+ grok.name('type')
Modified: zope.introspector/trunk/src/zope/introspector/objectinfo.txt
===================================================================
--- zope.introspector/trunk/src/zope/introspector/objectinfo.txt 2008-07-22 14:06:21 UTC (rev 88691)
+++ zope.introspector/trunk/src/zope/introspector/objectinfo.txt 2008-07-22 14:28:04 UTC (rev 88692)
@@ -1,7 +1,7 @@
Determining information about simple objects
*********************************************
-:Test-Layer: unit
+:Test-Layer: nonunit
Describing objects
==================
@@ -23,7 +23,7 @@
zope.introspector is the ``ObjectInfo`` class. ObjectInfos can be
created by passing an object to examine::
- >>> from zope.introspector import ObjectInfo
+ >>> from zope.introspector.objectinfo import ObjectInfo
>>> info = ObjectInfo(object())
>>> info
<zope.introspector...ObjectInfo object at 0x...>
@@ -79,7 +79,7 @@
Fortunately, there is an ``PackageInfo`` available, which gives us
this information::
- >>> from zope.introspector import PackageInfo
+ >>> from zope.introspector.objectinfo import PackageInfo
>>> info = PackageInfo(introspector)
>>> info.getPackageFiles(filter='.txt')
['README.txt', ...]
@@ -138,7 +138,7 @@
Python, we cannot define a specialized adapter based on the type::
>>> from zope.introspector import tests as subpkg
- >>> IObjectInfo(subpkg)
+ >>> IObjectInfo(subpkg, name='object')
<zope.introspector.objectinfo.ModuleInfo object at 0x...>
That's okay in the sense, that packages are in fact modules, but there
Deleted: zope.introspector/trunk/src/zope/introspector/tests/descriptorgrokker.txt
===================================================================
--- zope.introspector/trunk/src/zope/introspector/tests/descriptorgrokker.txt 2008-07-22 14:06:21 UTC (rev 88691)
+++ zope.introspector/trunk/src/zope/introspector/tests/descriptorgrokker.txt 2008-07-22 14:28:04 UTC (rev 88692)
@@ -1,80 +0,0 @@
-The description provider grokker
-********************************
-
-:Test-Layer: unit
-
-The DescriptionProviderGrokker
-==============================
-
-The ``DescriptionProviderGrokker`` adds classes to the registry in the
-`descriptionprovider` module. In the beginning, this registry is
-empty::
-
- >>> import zope.introspector.descriptionprovider as zid
- >>> reg = zid.descriptor_registry
- >>> reg
- [...]
-
-[]
-
-We create an Grokker instance::
-
- >>> from zope.introspector.meta import DescriptionProviderGrokker
- >>> grokker = DescriptionProviderGrokker()
-
-
-Description providers have an ordering
---------------------------------------
-
-Now we can add an object to the registry by calling the ``execute``
-method of the grokker. The grokker expects a class and a priority
-number between 0 (highest priority) and 1000 (lowest)::
-
- >>> grokker.execute(object, 666)
- True
-
-The registry now contains an entry::
-
- >>> from pprint import pprint
- >>> pprint(sorted(reg))
- [...]
-
-[{'priority': 666, 'handler': <type 'object'>}]
-
-If we call the grokker with a lower number, it should be inserted
-before the existing one::
-
- >>> trash = grokker.execute(object, 665)
- >>> pprint(reg)
- [...]
-
-[{'priority': 665, 'handler': <type 'object'>},
- {'priority': 666, 'handler': <type 'object'>}]
-
-
-The same applies to entries with an existing priority::
-
- >>> trash = grokker.execute(int, 666)
- >>> pprint(reg)
- [...]
-
-[{'priority': 665, 'handler': <type 'object'>},
- {'priority': 666, 'handler': <type 'int'>},
- {'priority': 666, 'handler': <type 'object'>}]
-
-
-An upper priority will insert the new object at the end of the list::
-
- >>> trash = grokker.execute(object, 667)
- >>> pprint(reg)
- [...]
-
-[{'priority': 665, 'handler': <type 'object'>},
- {'priority': 666, 'handler': <type 'int'>},
- {'priority': 666, 'handler': <type 'object'>},
- {'priority': 667, 'handler': <type 'object'>}]
-
-
-Clean up the registry::
-
- >>> del zid.descriptor_registry[0:4]
Modified: zope.introspector/trunk/src/zope/introspector/viewinfo.py
===================================================================
--- zope.introspector/trunk/src/zope/introspector/viewinfo.py 2008-07-22 14:06:21 UTC (rev 88691)
+++ zope.introspector/trunk/src/zope/introspector/viewinfo.py 2008-07-22 14:28:04 UTC (rev 88692)
@@ -27,7 +27,8 @@
"""
grok.provides(IViewInfo)
grok.context(Interface)
-
+ grok.name('view')
+
def getViews(self, layer=None):
request = BrowserRequest(None, {})
if layer is not None:
More information about the Checkins
mailing list