diff options
| author | Chris McDonough <chrism@plope.com> | 2011-11-25 22:09:41 -0500 |
|---|---|---|
| committer | Chris McDonough <chrism@plope.com> | 2011-11-25 22:09:41 -0500 |
| commit | 7f72f8d8607607a15b1c460db5fdf25ee9692a3c (patch) | |
| tree | 8d64e97e7f14f618474e0f20005ad1c556967ca8 | |
| parent | 8b6f09d965a6e637b795a8268c310c81fcb43a10 (diff) | |
| download | pyramid-7f72f8d8607607a15b1c460db5fdf25ee9692a3c.tar.gz pyramid-7f72f8d8607607a15b1c460db5fdf25ee9692a3c.tar.bz2 pyramid-7f72f8d8607607a15b1c460db5fdf25ee9692a3c.zip | |
add more introspectables, fix object_description so tests pass
| -rw-r--r-- | pyramid/config/rendering.py | 12 | ||||
| -rw-r--r-- | pyramid/config/security.py | 24 | ||||
| -rw-r--r-- | pyramid/config/views.py | 1 | ||||
| -rw-r--r-- | pyramid/util.py | 7 |
4 files changed, 37 insertions, 7 deletions
diff --git a/pyramid/config/rendering.py b/pyramid/config/rendering.py index f70dea118..f828f453b 100644 --- a/pyramid/config/rendering.py +++ b/pyramid/config/rendering.py @@ -43,9 +43,15 @@ class RenderingConfiguratorMixin(object): name = '' def register(): self.registry.registerUtility(factory, IRendererFactory, name=name) + intr = self.introspectable('renderer factories', name, + self.object_description(factory), + 'renderer factory') + intr['factory'] = factory + intr['name'] = name # we need to register renderers early (in phase 1) because they are # used during view configuration (which happens in phase 3) - self.action((IRendererFactory, name), register, order=PHASE1_CONFIG) + self.action((IRendererFactory, name), register, order=PHASE1_CONFIG, + introspectables=(intr,)) @action_method def set_renderer_globals_factory(self, factory, warn=True): @@ -83,4 +89,8 @@ class RenderingConfiguratorMixin(object): factory = self.maybe_dotted(factory) def register(): self.registry.registerUtility(factory, IRendererGlobalsFactory) + intr = self.introspectable('renderer globals factory', None, + self.object_description(factory), + 'renderer globals factory') + intr['factory'] = factory self.action(IRendererGlobalsFactory, register) diff --git a/pyramid/config/security.py b/pyramid/config/security.py index 935e2fd95..20c830e75 100644 --- a/pyramid/config/security.py +++ b/pyramid/config/security.py @@ -29,8 +29,13 @@ class SecurityConfiguratorMixin(object): 'Cannot configure an authentication policy without ' 'also configuring an authorization policy ' '(use the set_authorization_policy method)') + intr = self.introspectable('authentication policy', None, + self.object_description(policy), + 'authentication policy') + intr['policy'] = policy # authentication policy used by view config (phase 3) - self.action(IAuthenticationPolicy, register, order=PHASE2_CONFIG) + self.action(IAuthenticationPolicy, register, order=PHASE2_CONFIG, + introspectables=(intr,)) def _set_authentication_policy(self, policy): policy = self.maybe_dotted(policy) @@ -60,6 +65,10 @@ class SecurityConfiguratorMixin(object): 'also configuring an authentication policy ' '(use the set_authorization_policy method)') + intr = self.introspectable('authorization policy', None, + self.object_description(policy), + 'authorization policy') + intr['policy'] = policy # authorization policy used by view config (phase 3) and # authentication policy (phase 2) self.action(IAuthorizationPolicy, register, order=PHASE1_CONFIG) @@ -108,9 +117,18 @@ class SecurityConfiguratorMixin(object): :class:`pyramid.config.Configurator` constructor can be used to achieve the same purpose. """ - # default permission used during view registration (phase 3) def register(): self.registry.registerUtility(permission, IDefaultPermission) - self.action(IDefaultPermission, register, order=PHASE1_CONFIG) + intr = self.introspectable('default permission', + None, + permission, + 'default permission') + intr['value'] = permission + perm_intr = self.introspectable('permissions', permission, + permission, 'permission') + perm_intr['value'] = permission + # default permission used during view registration (phase 3) + self.action(IDefaultPermission, register, order=PHASE1_CONFIG, + introspectables=(intr, perm_intr,)) diff --git a/pyramid/config/views.py b/pyramid/config/views.py index 12193b478..00ea2fdd2 100644 --- a/pyramid/config/views.py +++ b/pyramid/config/views.py @@ -1108,6 +1108,7 @@ class ViewsConfiguratorMixin(object): tmpl_intr['name'] = renderer.name tmpl_intr['type'] = renderer.type tmpl_intr['renderer'] = renderer + tmpl_intr.relate('renderer factories', renderer.type) introspectables.append(tmpl_intr) if permission is not None: perm_intr = self.introspectable('permissions', permission, diff --git a/pyramid/util.py b/pyramid/util.py index fd3bcd48d..ee909c316 100644 --- a/pyramid/util.py +++ b/pyramid/util.py @@ -265,6 +265,8 @@ def object_description(object): if isinstance(object, dict): return shortrepr(object, '}') module = inspect.getmodule(object) + if module is None: + return 'object %s' % str(object) modulename = module.__name__ if inspect.ismodule(object): return 'module %s' % modulename @@ -272,9 +274,8 @@ def object_description(object): oself = getattr(object, '__self__', None) if oself is None: oself = getattr(object, 'im_self', None) - oself.__class__ - return 'method %s of class %s.%s' (object.__name__, modulename, - oself.__class__.__name___) + return 'method %s of class %s.%s' % (object.__name__, modulename, + oself.__class__.__name__) if inspect.isclass(object): dottedname = '%s.%s' % (modulename, object.__name__) |
