from Products.Silva.interfaces import IFolder
from Products.SilvaDocument.interfaces import IDocument, IDocumentVersion

class IMailingFolder(IFolder):
    """ folderish object containing 'mailings' (documents)

        this also harbours functionality to manage subscribers and send out
        mailings (batch emails)
    """

    def set_fromaddr(addr):
        """ set the 'From' address to <addr>
        """

    def send_as_mailing(path, editable=False, test_email=None):
        """ send the contents of a Silva object as a mailing mail

            'path' is the path to the object to use for the mail content

            if 'editable' is True, the edit version rather than the public
            version is used (if appropriate)

            if 'test_email' is provided, email is sent only to this email
            address, not to the rest
        """
    
    def subscribe(address):
        """ subscribe 'address' to the mailing """

    def unsubscribe(address):
        """ unsubscribe 'address' from the mailing """

    def subscribed():
        """ returns a list (or iterator) of subscribers """

    def templates():
        """ returns a list of all available templates

            templates are used for styling HTML parts of emails

            templates are found both in the www/templates dir (filesystem)
            and in the service (ZODB, service is a Folder type) to allow
            custom templates for each mailing
        """

    def subscribe_to_mailing():
        """ subscribe to or unsubscribe from the mailing

            this handles form submits of the form provided by the codesource
            and calls 'subscribe' or 'unsubscribe' depending on the form vars
        """

class IMailingDocument(IDocument):
    """ plain document type that can be added to a mailing folders
    """

class IMailingDocumentVersion(IDocumentVersion):
    """ version for IMailingDocument
    """

