I proposal the following Widget API, to complet with some explication about difference between value and input_values, what is error... :

class Widget(declarative.Declarative):
    """
    Interface to be implemented by all Widget

    :attention: implementation are stateless
    """

def render(self, value=None, input_values={}, error=None, format="html", convert=True, **kw):
        """
        This method is used by ???

        :param value: the value to display
        :type value: must be define by each Widget implementation
        :param input_values: ??
        :type input_values: a dict of ??
        :param error: ??
        :type error: ??
        :param format: ??
        :type error: ??
        :param format: ??
        :type format: a string from 'html', 'xml'
        :param convert: ??

        :return: the html fragment
        :rtype: an unicode string

        :attention: method must be stateless
        :see: insert()
        """
        pass

def insert(self, value=None, input_values={}, error=None, convert=True, **kw):
        """
        This method is used by the page/template to display the Widget.
        Return an html fragment to display value or input_values

        :param value: the value to display
        :type value: must be define by each Widget implementation
        :param input_values: ??
        :type input_values: a dict of ??
        :param error: ??
        :type error: ??
        :param format: ??
        :type error: ??
        :param format: ??
        :type format: a string from 'html', 'xml'
        :param convert: ??

        :return: the html fragment
        :rtype: an Element or a tuple/list of Elements
        :attention: method must be stateless
        """
        pass

    def retrieve_javascript(self):
        """
:return: the list of javascript to insert into the page using the template
            empty list when no Javascript are required by the widget
        :rtype: a list of Widget (like JLink or JSource)
        :see: JLink
        :see: JSource
        """
        pass

    def retrieve_css(self):
        """
:return: the list of javascript to insert into the page using the template,
            empty list when no CSS are required by the widget
        :rtype: a list of Widget (like JLink or JSource)
        :see: CSSLink
        :see: CSSSource
        """
        pass

    def sample(self):
        """
Return a sample html fragment, (may be return the result of render with sample value)

        :return: the html fragment
        :rtype: an unicode string
        :see: render()
        """
        pass


class InputWidget(Widget):

    def input(self, value):
        """
        Check and convert value

        :param params: value to check
        :type params: ??
        :return: ??
        :rtype: ??
        """
        pass


--
--------------------------------------------------------------
David "Dwayne" Bernard            Freelance Developer
                                  mailto:[EMAIL PROTECTED]
      \|/                         http://dwayne.java-fan.com
--o0O @.@ O0o-------------------------------------------------

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to