[Zope-Checkins] CVS: Zope3/lib/python/Zope/App/Forms/Views/Browser - CheckboxWidget.py:1.1 FormView.py:1.1 TextWidget.py:1.1 __init__.py:1.1

Martijn Faassen m.faassen@vet.uu.nl
Tue, 25 Jun 2002 09:34:59 -0400


Update of /cvs-repository/Zope3/lib/python/Zope/App/Forms/Views/Browser
In directory cvs.zope.org:/tmp/cvs-serv4911/Forms/Views/Browser

Added Files:
	CheckboxWidget.py FormView.py TextWidget.py __init__.py 
Log Message:
Add beginnings of the Forms package, which provides widgets for
schema fields.


=== Added File Zope3/lib/python/Zope/App/Forms/Views/Browser/CheckboxWidget.py ===

from Zope.Publisher.Browser.BrowserView import BrowserView

class CheckboxWidget(BrowserView):
    def render(self):
        return '<input type="checkbox" name="%s" value="%s" />' %\
               (self.context.title, self.context.default)
    


=== Added File Zope3/lib/python/Zope/App/Forms/Views/Browser/FormView.py ===
from Zope.Publisher.Browser.BrowserView import BrowserView
from Interface import Interface
from Schema.IField import IField
from Zope.ComponentArchitecture import getView

class FormView(BrowserView):
    def getWidgetsForSchema(self, schema, view_name):
        """Given a schema and a desired field name, get a list of
        widgets for it.
        """
        result = []
        for name in schema.names(1):
            attr = schema.getDescriptionFor(name)
            if IField.isImplementedBy(attr):
                widget = getView(attr, view_name, self.request)
                result.append(widget)
        return result
    
    


=== Added File Zope3/lib/python/Zope/App/Forms/Views/Browser/TextWidget.py ===
from Zope.Publisher.Browser.BrowserView import BrowserView

class TextWidget(BrowserView):
    def render(self):
        return '<input type="text" name="%s" value="%s" />' %\
               (self.context.title, self.context.default)

    


=== Added File Zope3/lib/python/Zope/App/Forms/Views/Browser/__init__.py ===