[Zope3-checkins] CVS: Zope3/src/zope/app/interfaces - renderer.py:1.1

Stephan Richter srichter@cosmos.phy.tufts.edu
Thu, 31 Jul 2003 13:59:37 -0400


Update of /cvs-repository/Zope3/src/zope/app/interfaces
In directory cvs.zope.org:/tmp/cvs-serv10168/interfaces

Added Files:
	renderer.py 
Log Message:
First checkin of the ZWiki Renderer package into the core. The renderer
package can convert some sort of code to a particular presentation. Examples
include ReST --> HTML or Plain Text to HTML. However, it could be also used
to convert Python code --> Pretty HTML Python code and so on. 

To Do:

- Make a vocabulary, so that it is easier to list all the available source 
  types in an HTML form.

- Update Wiki code. (This actually already done...)



=== Added File Zope3/src/zope/app/interfaces/renderer.py ===
##############################################################################
#
# Copyright (c) 2003 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (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.
#
##############################################################################
"""ZWiki Interface Declarations

This module defines the ZWiki relevant interfaces.

$Id: renderer.py,v 1.1 2003/07/31 17:59:33 srichter Exp $
"""
from zope.interface import Interface
from zope.schema import Text, TextLine, List

class ISourceTypeService(Interface):
    """The source type service keeps track of all interfaces that have been
    reported as a source type.

    Source Types are plain text input formats, such as ReST, STX or Plain
    Text. However, it could be also something like Python code.
    """

    def get(title, default=None):
        """Get the type interface by title. If the type was not found, return
        default."""

    def query(title):
        """Get the type interface by title. Throw an error, if not found."""

    def getAllTitles():
        """Return a list of all titles."""

    def createObject(title):
        """Creates an object that implements the interface (note these are
        just marker interfaces, so the object is minimal) that is registered
        with the title passed."""


class IGlobalSourceTypeService(ISourceTypeService):
    """Adds some write methods to the service, so that we can reguster new
    source types."""

    def provide(title, iface):
        """The title is the description of the source type and the interface
        is used to recognize the type."""


class ISource(Interface):
    """Simple base interface for all possible Wiki Page Source types."""

    def createComment(comment, number):
        """Create a comment from the comment content and the number of the
        comment.

        Various source types want to create comments in various different
        ways. This method allows us to specify a way to create comments for
        every different source type.
        """

class IPlainTextSource(ISource):
    """Marker interface for a plain text source. Note that an implementation
    of this interface should always derive from unicode or behave like a
    unicode class."""


class IStructuredTextSource(ISource):
    """Marker interface for a structured text source. Note that an
    implementation of this interface should always derive from unicode or
    behave like a unicode class."""


class IReStructuredTextSource(ISource):
    """Marker interface for a restructured text source. Note that an
    implementation of this interface should always derive from unicode or
    behave like a unicode class."""


class ISourceRenderer(Interface):
    """Objecrt implementing this interface are responsible for rendering an
    ISource objects to an output format. This is the base class for all
    possible output types."""

    def render(context):
        """Renders the source into another format.

        The context argument is passed, since some rendering might require
        some knowledge about the environment. If this turns out to be
        unnecessary, we can remove this attribute later."""
        

class IHTMLRenderer(ISourceRenderer):
    """Renders an ISource object to HTML."""