From deb0dc316b64d5fb7bd0e15a1bafe269d3b33fbc Mon Sep 17 00:00:00 2001 From: Chris McDonough Date: Fri, 7 Nov 2008 10:47:28 +0000 Subject: Features - Added a ``repoze.bfg.testing`` module to attempt to make it slightly easier to write unittest-based automated tests of BFG applications. Information about this class is in the documentation. - The default template renderer now supports testing better by looking for ``ITestingTemplateRenderer`` using a relative pathname. This is exposed indirectly through the API named ``registerTemplate`` in ``repoze.bfg.testing``. Deprecations - The names ``repoze.bfg.interfaces.ITemplate`` , ``repoze.bfg.interfaces.ITemplateFactory`` and ``repoze.bfg.interfaces.INodeTemplate`` have been deprecated. These should now be imported as ``repoze.bfg.interfaces.ITemplateRenderer`` and ``repoze.bfg.interfaces.ITemplateRendererFactory``, and ``INodeTemplateRenderer`` respectively. - The name ``repoze.bfg.chameleon_zpt.ZPTTemplateFactory`` is deprecated. Use ``repoze.bfg.chameleon_zpt.ZPTTemplateRenderer``. - The name ``repoze.bfg.chameleon_genshi.GenshiTemplateFactory`` is deprecated. Use ``repoze.bfg.chameleon_genshi.GenshiTemplateRenderer``. - The name ``repoze.bfg.xslt.XSLTemplateFactory`` is deprecated. Use ``repoze.bfg.xslt.XSLTemplateRenderer``. --- repoze/bfg/interfaces.py | 46 +++++++++++++++++++++++++++++++++++++--------- 1 file changed, 37 insertions(+), 9 deletions(-) (limited to 'repoze/bfg/interfaces.py') diff --git a/repoze/bfg/interfaces.py b/repoze/bfg/interfaces.py index bbff9bca7..71ef619c2 100644 --- a/repoze/bfg/interfaces.py +++ b/repoze/bfg/interfaces.py @@ -1,5 +1,6 @@ from zope.interface import Interface from zope.interface import Attribute +from zope.deprecation import deprecated from zope.component.interfaces import IObjectEvent @@ -26,20 +27,47 @@ class ITraverser(Interface): class ITraverserFactory(Interface): def __call__(context): - """ Return an object that implements IPublishTraverser """ + """ Return an object that implements ITraverser """ -class ITemplateFactory(Interface): - def __call__(path, auto_reload=False): - """ Return an an ITemplate given a filesystem path """ +class ITemplateRenderer(Interface): + def implementation(): + """ Return the object that the underlying templating system + uses to render the template; it is typically a callable that + accepts arbitrary keyword arguments and returns a string or + unicode object """ + + def __call__(**kw): + """ Call a the template implementation with the keywords + passed in as arguments and return the result (a string or + unicode object) """ -class ITemplate(Interface): +class ITestingTemplateRenderer(Interface): def __call__(**kw): - """ Return a string result given a template path """ + """ Accept keywords and process for test comparison purposes + (usually set all keywords as attributes of self); return value + is a string """ -class INodeTemplate(Interface): +class ITemplateRendererFactory(Interface): + def __call__(path, auto_reload=False): + """ Return an object that implements ``ITemplateRenderer`` """ + +class INodeTemplateRenderer(Interface): def __call__(node, **kw): - """ Return a string result given a template path """ - + """ Return a string result given a node and a template path """ + +ITemplate = ITemplateRenderer +deprecated('ITemplate', + ('repoze.bfg.interfaces.ITemplate should now be imported ' + 'as repoze.bfg.interfaces.ITemplateRenderer')) +INodeTemplate = INodeTemplateRenderer +deprecated('INodeTemplate', + ('repoze.bfg.interfaces.INodeTemplate should now be imported ' + 'as repoze.bfg.interfaces.INodeTemplateRenderer')) +ITemplateFactory = ITemplateRendererFactory +deprecated('ITemplateFactory', + ('repoze.bfg.interfaces.ITemplateFactory should now be imported ' + 'as repoze.bfg.interfaces.ITemplateRendererFactory')) + class ISecurityPolicy(Interface): """ A utility that provides a mechanism to check authorization using authentication data """ -- cgit v1.2.3