diff options
| author | Chris McDonough <chrism@plope.com> | 2011-12-03 19:37:38 -0500 |
|---|---|---|
| committer | Chris McDonough <chrism@plope.com> | 2011-12-03 19:37:38 -0500 |
| commit | 58c01ff8863971f81db59d437d49fd9e97b59e5c (patch) | |
| tree | 188de60a7ee61680246ea203e10149546a310cb9 | |
| parent | 422bf50d7c3b99ab7c4655f81d373eb5ca29301b (diff) | |
| download | pyramid-58c01ff8863971f81db59d437d49fd9e97b59e5c.tar.gz pyramid-58c01ff8863971f81db59d437d49fd9e97b59e5c.tar.bz2 pyramid-58c01ff8863971f81db59d437d49fd9e97b59e5c.zip | |
flesh out categories more
| -rw-r--r-- | TODO.txt | 4 | ||||
| -rw-r--r-- | docs/narr/introspector.rst | 80 | ||||
| -rw-r--r-- | docs/narr/tb_introspector.png | bin | 0 -> 46164 bytes | |||
| -rw-r--r-- | pyramid/config/assets.py | 9 | ||||
| -rw-r--r-- | pyramid/config/i18n.py | 2 | ||||
| -rw-r--r-- | pyramid/config/tweens.py | 6 | ||||
| -rw-r--r-- | pyramid/config/views.py | 2 |
7 files changed, 82 insertions, 21 deletions
@@ -8,6 +8,10 @@ Must-Have * Narrative docs. + * ``default root factory`` category? + + * ``default view mapper`` category? + * ActionInfo for ZCML actions (begin/end lineno/cols?) * Document ActionInfo. diff --git a/docs/narr/introspector.rst b/docs/narr/introspector.rst index 8adfde7d1..ac0859164 100644 --- a/docs/narr/introspector.rst +++ b/docs/narr/introspector.rst @@ -15,6 +15,10 @@ feature is useful for debug toolbars, command-line scripts which show some aspect of configuration, and for runtime reporting of startup-time configuration settings. +.. warning:: + + Introspection is new in Pyramid 1.3. + Using the Introspector ---------------------- @@ -86,6 +90,12 @@ The important attributes shared by all introspectables are the following: often be a singular version of the category name but it can be an arbitrary value. +``action_info`` + + An object describing the directive call site which caused this + introspectable to be registered; contains attributes described in + :class:`pyramid.interfaces.IActionInfo`. + Besides having the attributes described above, an introspectable is a dictionary-like object. An introspectable can be queried for data values via its ``__getitem__``, ``get``, ``keys``, ``values``, or ``items`` methods. @@ -107,7 +117,7 @@ introspectables in categories not described here. ``subscribers`` Each introspectable in the ``subscribers`` category represents a call to - :meth:`pryamid.config.Configurator.add_subscriber` (or the decorator + :meth:`pyramid.config.Configurator.add_subscriber` (or the decorator equivalent); each will have the following data. ``subscriber`` @@ -138,8 +148,6 @@ introspectables in categories not described here. ``root factories`` - XXX ``default root factory`` category? - Each introspectable in the ``root factories`` category represents a call to :meth:`pyramid.config.Configurator.set_root_factory` (or the Configurator constructor equivalent) *or* a ``factory`` argument passed to @@ -435,8 +443,6 @@ introspectables in categories not described here. ``view mapper`` - XXX default view mapper category? - Each introspectable in the ``permissions`` category represents a call to :meth:`pyramid.config.Configurator.add_view` that has an explicit ``mapper`` argument to *or* a call to @@ -450,17 +456,69 @@ introspectables in categories not described here. ``asset overrides`` - XXX + Each introspectable in the ``asset overrides`` category represents a call + to :meth:`pyramid.config.Configurator.override_asset`; each will have the + following data. + + ``to_override`` + + The ``to_override`` argument (an asset spec) passed to + ``override_asset``. + + ``override_with`` + + The ``override_with`` argument (an asset spec) passed to + ``override_asset``. ``translation directories`` - XXX + Each introspectable in the ``asset overrides`` category represents an + individual element in a ``specs`` argument passed to to + :meth:`pyramid.config.Configurator.add_translation_dirs`; each will have + the following data. + + ``directory`` + + The absolute path of the translation directory. + + ``spec`` + + The asset specification passed to ``add_translation_dirs``. + +``tweens`` + + Each introspectable in the ``tweens`` category represents a call to + :meth:`pyramid.config.Configurator.add_tween`; each will have the following + data. + + ``name`` + + The dotted name to the tween factory as a string (passed as + the ``tween_factory`` argument to ``add_tween``). + + ``factory`` + + The (resolved) tween factory object. + + ``type`` + + ``implict`` or ``explicit`` as a string. + + ``under`` + + The ``under`` argument passed to ``add_tween`` (a string). + + ``over`` + + The ``over`` argument passed to ``add_tween`` (a string). -``tweens (implicit)`` +Toolbar Introspection +--------------------- - XXX +The Pyramid debug toolbar (part of the ``pyramid_debugtoolbar`` package) +provides a canned view of all registered introspectables and their +relationships. It looks something like this: -``tweens (explicit)`` +.. image:: tb_introspector.png - XXX diff --git a/docs/narr/tb_introspector.png b/docs/narr/tb_introspector.png Binary files differnew file mode 100644 index 000000000..231a094f7 --- /dev/null +++ b/docs/narr/tb_introspector.png diff --git a/pyramid/config/assets.py b/pyramid/config/assets.py index 7080e5e7c..c93431987 100644 --- a/pyramid/config/assets.py +++ b/pyramid/config/assets.py @@ -239,14 +239,11 @@ class AssetsConfiguratorMixin(object): intr = self.introspectable( 'asset overrides', (package, override_package, path, override_prefix), - '%s/%s -> %s/%s' % (package, path, override_package, - override_prefix), + '%s -> %s' % (to_override, override_with), 'asset override', ) - intr['package'] = package - intr['override_package'] = package - intr['override_prefix'] = override_prefix - intr['path'] = path + intr['to_override'] = to_override + intr['override_with'] = override_with self.action(None, register, introspectables=(intr,)) override_resource = override_asset # bw compat diff --git a/pyramid/config/i18n.py b/pyramid/config/i18n.py index 5770f84c8..60c7a71c1 100644 --- a/pyramid/config/i18n.py +++ b/pyramid/config/i18n.py @@ -93,6 +93,7 @@ class I18NConfiguratorMixin(object): intr = self.introspectable('translation directories', directory, spec, 'translation directory') intr['directory'] = directory + intr['spec'] = spec introspectables.append(intr) directories.append(directory) @@ -106,7 +107,6 @@ class I18NConfiguratorMixin(object): ITranslationDirectories) tdirs.insert(0, directory) - # XXX no action? if directories: # We actually only need an IChameleonTranslate function diff --git a/pyramid/config/tweens.py b/pyramid/config/tweens.py index e36e9e84e..1a83f0de9 100644 --- a/pyramid/config/tweens.py +++ b/pyramid/config/tweens.py @@ -144,10 +144,11 @@ class TweensConfiguratorMixin(object): if tweens is None: tweens = Tweens() registry.registerUtility(tweens, ITweens) - ex_intr = self.introspectable('tweens (implicit)', + ex_intr = self.introspectable('tweens', ('tween', EXCVIEW, False), EXCVIEW, 'implicit tween') + ex_intr['name'] = EXCVIEW ex_intr['factory'] = excview_tween_factory ex_intr['type'] = 'implicit' ex_intr['under'] = None @@ -164,10 +165,11 @@ class TweensConfiguratorMixin(object): discriminator = ('tween', name, explicit) tween_type = explicit and 'explicit' or 'implicit' - intr = self.introspectable('tweens (%s)' % tween_type, + intr = self.introspectable('tweens', discriminator, name, '%s tween' % tween_type) + intr['name'] = name intr['factory'] = tween_factory intr['type'] = tween_type intr['under'] = under diff --git a/pyramid/config/views.py b/pyramid/config/views.py index 02dcbf2ee..0b6c6070f 100644 --- a/pyramid/config/views.py +++ b/pyramid/config/views.py @@ -1119,7 +1119,7 @@ class ViewsConfiguratorMixin(object): if mapper: mapper_intr = self.introspectable('view mappers', discriminator, - view_desc, + 'view mapper for %s' % view_desc, 'view mapper') mapper_intr['mapper'] = mapper mapper_intr.relate('views', discriminator) |
