[Zope-Checkins] CVS: Zope3/lib/python/Zope/App/Formulator/Widgets/XUL - IXULWidget.py:1.1.4.1 TextWidget.py:1.1.4.1 XULWidget.py:1.1.4.1 __init__.py:1.1.4.1 xul.zcml:1.1.4.1
Stephan Richter
srichter@cbu.edu
Mon, 1 Apr 2002 21:10:25 -0500
Update of /cvs-repository/Zope3/lib/python/Zope/App/Formulator/Widgets/XUL
In directory cvs.zope.org:/tmp/cvs-serv6377/Formulator/Widgets/XUL
Added Files:
Tag: Zope-3x-branch
IXULWidget.py TextWidget.py XULWidget.py __init__.py xul.zcml
Log Message:
Issue 25: Resolved by janko & srichter
This checkin fixes all the license headers of all the files that needed
fixing it. :) This was made possible by Janko Hauser's script, which is now
available in the ZopeRoot/utilities directory.
Also, cleaned up the Formualtor tag insanity!
=== Added File Zope3/lib/python/Zope/App/Formulator/Widgets/XUL/IXULWidget.py ===
##############################################################################
#
# Copyright (c) 2001, 2002 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.
#
##############################################################################
"""
$Id: IXULWidget.py,v 1.1.4.1 2002/04/02 02:10:23 srichter Exp $
"""
from Interface import Interface
class IXULWidget(Interface):
"""A field widget contains all the properties that are required
to represent a field. Properties include css_sheet,
default value and so on.
"""
def render(field, key, value, REQUEST):
"""Renders this widget as HTML using property values in field.
"""
def render_hidden(field, key, value, REQUEST):
"""Renders this widget as a hidden field.
"""
=== Added File Zope3/lib/python/Zope/App/Formulator/Widgets/XUL/TextWidget.py ===
##############################################################################
#
# Copyright (c) 2001, 2002 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.
#
##############################################################################
"""
$Id: TextWidget.py,v 1.1.4.1 2002/04/02 02:10:24 srichter Exp $
"""
from Zope.App.Formulator.Widgets.XUL.XULWidget import XULWidget
from Zope.App.Formulator.Widgets.XUL.XULWidget import renderElement
class TextWidget(XULWidget):
"""Text widget
"""
__implements__ = XULWidget.__implements__
propertyNames = XULWidget.propertyNames + \
['displayMaxWidth', 'extra', 'default']
tag = 'textbox'
default = ''
displayMaxWidth = ''
extra = ''
def render(self, REQUEST=None):
"""Renders this widget as HTML using property values in field.
"""
displayMaxWidth = self.getValue('displayMaxWidth') or 0
if displayMaxWidth > 0:
return renderElement(self.getValue('tag'),
id = self.getContext().id,
value = self._getValueToInsert(REQUEST),
cssClass = self.getValue('cssClass'),
maxlength = displayMaxWidth,
extra = self.getValue('extra'))
else:
return renderElement(self.getValue('tag'),
id = self.getContext().id,
value = self._getValueToInsert(REQUEST),
cssClass = self.getValue('cssClass'),
extra = self.getValue('extra'))
=== Added File Zope3/lib/python/Zope/App/Formulator/Widgets/XUL/XULWidget.py ===
##############################################################################
#
# Copyright (c) 2001, 2002 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.
#
##############################################################################
"""
$Id: XULWidget.py,v 1.1.4.1 2002/04/02 02:10:24 srichter Exp $
"""
from IXULWidget import IXULWidget
from Zope.App.Formulator.Widget import Widget
from Zope.App.Formulator.IPropertyFieldAdapter import IPropertyFieldAdapter
from Zope.ComponentArchitecture import getAdapter
class XULWidget(Widget):
"""A field widget that knows how to display itself as HTML.
"""
__implements__ = IXULWidget
propertyNames = Widget.propertyNames + \
['tag', 'type', 'cssClass', 'hidden', 'extra']
tag = ''
type = 'text'
cssClass = ''
hidden = 0
extra = ''
def __init__(self, field):
''' '''
self._field = field
def getValueFromRequest(self, REQUEST):
""" """
return REQUEST.get('field_'+self.getContext().id, None)
def _getValueToInsert(self, REQUEST):
""" """
field = self.getContext()
if REQUEST and REQUEST.has_key('field_'+field.id):
return REQUEST['field_'+field.id]
else:
return getAdapter(field, IPropertyFieldAdapter).getPropertyInContext()
def render(self, REQUEST=None):
"""Renders this widget as HTML using property values in field.
"""
return renderElement(self.getValue('tag'),
type = self.getValue('type'),
name = self.getContext().id,
value = self._getValueToInsert(REQUEST),
cssClass = self.getValue('cssClass'),
extra = self.getValue('extra'))
def render_hidden(self, REQUEST=None):
"""Renders this widget as a hidden field.
"""
return renderElement(self.getValue('tag'),
type = 'hidden',
name = self.getContext().id,
value = self._getValueToInsert(REQUEST),
cssClass = self.getValue('cssClass'),
extra = self.getValue('extra'))
def renderTag(tag, **kw):
"""Render the tag. Well, not all of it, as we may want to / it.
"""
attr_list = []
kw['id'] = 'field_' + kw['id']
# special case handling for css_class
if kw.has_key('cssClass'):
if kw['cssClass'] != "":
attr_list.append('class="%s"' % kw['cssClass'])
del kw['cssClass']
# special case handling for extra 'raw' code
if kw.has_key('extra'):
extra = kw['extra'] # could be empty string but we don't care
del kw['extra']
else:
extra = ""
# handle other attributes
for key, value in kw.items():
if value == None:
value = key
attr_list.append('%s="%s"' % (key, str(value)))
attr_str = " ".join(attr_list)
return "<%s %s %s" % (tag, attr_str, extra)
def renderElement(tag, **kw):
if kw.has_key('contents'):
contents = kw['contents']
del kw['contents']
return "%s>%s</%s>" % (apply(renderTag, (tag,), kw), contents, tag)
else:
return apply(renderTag, (tag,), kw) + " />"
=== Added File Zope3/lib/python/Zope/App/Formulator/Widgets/XUL/__init__.py ===
##############################################################################
#
# Copyright (c) 2001, 2002 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.
#
##############################################################################
"""
$Id: __init__.py,v 1.1.4.1 2002/04/02 02:10:24 srichter Exp $
"""
=== Added File Zope3/lib/python/Zope/App/Formulator/Widgets/XUL/xul.zcml ===
<zopeConfigure
xmlns='http://namespaces.zope.org/zope'
xmlns:security='http://namespaces.zope.org/security'
>
<security:protectClass
name="Zope.App.Formulator.Widgets.XUL.TextWidget."
permission_id="Zope.ManageContent"
methods="render, getContext" />
</zopeConfigure>