[Framework-Team] Re: r15422 - in plone.transforms/trunk/plone/transforms: . interfaces tests

Daniel Nouri daniel.nouri at gmail.com
Thu Jun 21 18:13:11 UTC 2007


Hi Hanno!

hannosch wrote:
> Added: plone.transforms/trunk/plone/transforms/interfaces/transform.py
> ==============================================================================
> --- (empty file)
> +++ plone.transforms/trunk/plone/transforms/interfaces/transform.py	Wed Jun 20 21:18:48 2007
> @@ -0,0 +1,22 @@
> +from zope.interface import Attribute, Interface
> +
> +
> +class ITransform(Interface):
> +    """A transformation utility.
> +    """
> +
> +    inputs = Attribute("List of mimetypes this transform accepts "
> +                       "as inputs.")
> +
> +    output = Attribute("Output mimetype")
> +
> +
> +    title = Attribute("The title of the transform.")
> +
> +    description = Attribute("A description of the transform.")
> +
> +    def convert(data, **kwargs):
> +        """
> +        The convert method takes some data in one of the input formats and
> +        returns it in the output format.
> +        """

Let me try and get a discussion started around this interface.

The 'convert' method doesn't say anything about what 'data' is supposed to
be.  I think it's a good idea to require 'data' to be a file-like object
from the start -- the same should go for the return value.  Also, I can't
say I like the **kwargs.  Would you mind describing what that's for?

Generally, I think it's a good idea to make the interface specification as
unambiguous as possible.  By saying 'some data' and not specifying what the
keyword arguments are, I think we run into the danger of coupling clients
with the transforms at a lower level than the interface.  Thus we lose real
pluggability, because there's no exact specification and everyone can have
their own interpretation of 'data' and 'kwargs'.


Daniel





More information about the Framework-Team mailing list