[Zope3-checkins] SVN: Zope3/trunk/src/zope/ Applied patch of issue
419.
Stephan Richter
srichter at cosmos.phy.tufts.edu
Fri Jul 29 16:46:23 EDT 2005
Log message for revision 37565:
Applied patch of issue 419.
Changed:
U Zope3/trunk/src/zope/app/form/browser/__init__.py
U Zope3/trunk/src/zope/app/form/browser/configure.zcml
U Zope3/trunk/src/zope/app/form/browser/tests/test_registrations.py
U Zope3/trunk/src/zope/app/form/browser/textwidgets.py
U Zope3/trunk/src/zope/schema/__init__.py
U Zope3/trunk/src/zope/schema/_field.py
U Zope3/trunk/src/zope/schema/interfaces.py
-=-
Modified: Zope3/trunk/src/zope/app/form/browser/__init__.py
===================================================================
--- Zope3/trunk/src/zope/app/form/browser/__init__.py 2005-07-29 20:44:06 UTC (rev 37564)
+++ Zope3/trunk/src/zope/app/form/browser/__init__.py 2005-07-29 20:46:23 UTC (rev 37565)
@@ -23,12 +23,13 @@
from zope.app.form.browser.textwidgets import TextWidget, BytesWidget
from zope.app.form.browser.textwidgets import TextAreaWidget, BytesAreaWidget
from zope.app.form.browser.textwidgets import PasswordWidget, FileWidget
-from zope.app.form.browser.textwidgets import ASCIIWidget
+from zope.app.form.browser.textwidgets import ASCIIWidget, ASCIIAreaWidget
from zope.app.form.browser.textwidgets import IntWidget, FloatWidget
from zope.app.form.browser.textwidgets import DatetimeWidget, DateWidget
from zope.app.form.browser.textwidgets import DatetimeDisplayWidget
from zope.app.form.browser.textwidgets import DateDisplayWidget
from zope.app.form.browser.textwidgets import BytesDisplayWidget
+from zope.app.form.browser.textwidgets import ASCIIDisplayWidget
from zope.app.form.browser.textwidgets import URIDisplayWidget
# Widgets for boolean fields
Modified: Zope3/trunk/src/zope/app/form/browser/configure.zcml
===================================================================
--- Zope3/trunk/src/zope/app/form/browser/configure.zcml 2005-07-29 20:44:06 UTC (rev 37564)
+++ Zope3/trunk/src/zope/app/form/browser/configure.zcml 2005-07-29 20:46:23 UTC (rev 37565)
@@ -72,6 +72,22 @@
<view
type="zope.publisher.interfaces.browser.IBrowserRequest"
+ for="zope.schema.interfaces.IASCII"
+ provides="zope.app.form.interfaces.IDisplayWidget"
+ factory=".textwidgets.ASCIIDisplayWidget"
+ permission="zope.Public"
+ />
+
+ <view
+ type="zope.publisher.interfaces.browser.IBrowserRequest"
+ for="zope.schema.interfaces.IASCIILine"
+ provides="zope.app.form.interfaces.IDisplayWidget"
+ factory=".DisplayWidget"
+ permission="zope.Public"
+ />
+
+ <view
+ type="zope.publisher.interfaces.browser.IBrowserRequest"
for="zope.schema.interfaces.IURI"
provides="zope.app.form.interfaces.IDisplayWidget"
factory=".textwidgets.URIDisplayWidget"
@@ -140,12 +156,20 @@
type="zope.publisher.interfaces.browser.IBrowserRequest"
for="zope.schema.interfaces.IASCII"
provides="zope.app.form.interfaces.IInputWidget"
- factory=".BytesAreaWidget"
+ factory=".ASCIIAreaWidget"
permission="zope.Public"
/>
<view
type="zope.publisher.interfaces.browser.IBrowserRequest"
+ for="zope.schema.interfaces.IASCIILine"
+ provides="zope.app.form.interfaces.IInputWidget"
+ factory=".ASCIIWidget"
+ permission="zope.Public"
+ />
+
+ <view
+ type="zope.publisher.interfaces.browser.IBrowserRequest"
for="zope.schema.interfaces.IInt"
provides="zope.app.form.interfaces.IInputWidget"
factory=".IntWidget"
Modified: Zope3/trunk/src/zope/app/form/browser/tests/test_registrations.py
===================================================================
--- Zope3/trunk/src/zope/app/form/browser/tests/test_registrations.py 2005-07-29 20:44:06 UTC (rev 37564)
+++ Zope3/trunk/src/zope/app/form/browser/tests/test_registrations.py 2005-07-29 20:46:23 UTC (rev 37565)
@@ -106,12 +106,19 @@
>>> widget = zapi.getMultiAdapter((field, request), IInputWidget)
>>> isinstance(widget, FileWidget)
True
+
+ IASCIILine, IInputWidget -> ASCIIWidget
+
+ >>> field = fields.ASCIILine()
+ >>> widget = zapi.getMultiAdapter((field, request), IInputWidget)
+ >>> isinstance(widget, ASCIIWidget)
+ True
- IASCII, IInputWidget -> BytesAreaWidget
+ IASCII, IInputWidget -> ASCIIAreaWidget
>>> field = fields.ASCII()
>>> widget = zapi.getMultiAdapter((field, request), IInputWidget)
- >>> isinstance(widget, BytesAreaWidget)
+ >>> isinstance(widget, ASCIIAreaWidget)
True
IInt, IInputWidget -> IntWidget
Modified: Zope3/trunk/src/zope/app/form/browser/textwidgets.py
===================================================================
--- Zope3/trunk/src/zope/app/form/browser/textwidgets.py 2005-07-29 20:44:06 UTC (rev 37564)
+++ Zope3/trunk/src/zope/app/form/browser/textwidgets.py 2005-07-29 20:46:23 UTC (rev 37565)
@@ -166,7 +166,6 @@
raise ConversionError(_("Invalid textual data"), v)
return value
-
class BytesWidget(Bytes, TextWidget):
"""Bytes widget.
@@ -203,6 +202,8 @@
Single-line data (string) input
"""
+class ASCIIDisplayWidget(BytesDisplayWidget):
+ """ASCII display widget"""
class URIDisplayWidget(DisplayWidget):
"""URI display widget.
@@ -345,6 +346,22 @@
'Hello\\nworld!'
"""
+class ASCIIAreaWidget(ASCII, TextAreaWidget):
+ """ASCIIArea widget.
+
+ Multi-line string input.
+
+ >>> from zope.publisher.browser import TestRequest
+ >>> from zope.schema import ASCII
+ >>> field = ASCII(__name__='foo', title=u'on')
+ >>> request = TestRequest(form={'field.foo': u'Hello\\r\\nworld!'})
+ >>> widget = ASCIIAreaWidget(field, request)
+ >>> widget.hasInput()
+ True
+ >>> widget.getInputValue()
+ 'Hello\\nworld!'
+ """
+
class PasswordWidget(TextWidget):
"""Password Widget"""
Modified: Zope3/trunk/src/zope/schema/__init__.py
===================================================================
--- Zope3/trunk/src/zope/schema/__init__.py 2005-07-29 20:44:06 UTC (rev 37564)
+++ Zope3/trunk/src/zope/schema/__init__.py 2005-07-29 20:46:23 UTC (rev 37565)
@@ -17,7 +17,7 @@
"""
from zope.schema._field import Field, Container, Iterable, Orderable
from zope.schema._field import MinMaxLen, Choice
-from zope.schema._field import Bytes, ASCII, BytesLine
+from zope.schema._field import Bytes, ASCII, BytesLine, ASCIILine
from zope.schema._field import Text, TextLine, Bool, Int, Float
from zope.schema._field import Tuple, List, Set
from zope.schema._field import Password, Dict, Datetime, Date, Timedelta
Modified: Zope3/trunk/src/zope/schema/_field.py
===================================================================
--- Zope3/trunk/src/zope/schema/_field.py 2005-07-29 20:44:06 UTC (rev 37564)
+++ Zope3/trunk/src/zope/schema/_field.py 2005-07-29 20:46:23 UTC (rev 37565)
@@ -28,7 +28,7 @@
from zope.schema.interfaces import IMinMaxLen, IText, ITextLine
from zope.schema.interfaces import ISourceText
from zope.schema.interfaces import IInterfaceField
-from zope.schema.interfaces import IBytes, IASCII, IBytesLine
+from zope.schema.interfaces import IBytes, IASCII, IBytesLine, IASCIILine
from zope.schema.interfaces import IBool, IInt, IFloat, IDatetime
from zope.schema.interfaces import IChoice, ITuple, IList, ISet, IDict
from zope.schema.interfaces import IPassword, IObject, IDate, ITimedelta
@@ -133,7 +133,15 @@
# TODO: we should probably use a more general definition of newlines
return '\n' not in value
+class ASCIILine(ASCII):
+ __doc__ = IASCIILine.__doc__
+ implements(IASCIILine)
+
+ def constraint(self, value):
+ # TODO: we should probably use a more general definition of newlines
+ return '\n' not in value
+
class Float(Orderable, Field):
__doc__ = IFloat.__doc__
implements(IFloat, IFromUnicode)
Modified: Zope3/trunk/src/zope/schema/interfaces.py
===================================================================
--- Zope3/trunk/src/zope/schema/interfaces.py 2005-07-29 20:44:06 UTC (rev 37564)
+++ Zope3/trunk/src/zope/schema/interfaces.py 2005-07-29 20:46:23 UTC (rev 37565)
@@ -284,6 +284,9 @@
class IBytesLine(IBytes):
u"""Field containing a byte string without newlines."""
+class IASCIILine(IASCII):
+ u"""Field containing a 7-bit ASCII string without newlines."""
+
class IText(IMinMaxLen, IIterable, IField):
u"""Field containing a unicode string."""
More information about the Zope3-Checkins
mailing list