Skip to content

Commit

Permalink
Merging trunk r109921 through r114037
Browse files Browse the repository at this point in the history
  • Loading branch information
gotcha committed Jul 1, 2010
2 parents d6c75b6 + 46c40e0 commit 8ab5f62
Show file tree
Hide file tree
Showing 15 changed files with 85 additions and 67 deletions.
3 changes: 2 additions & 1 deletion AUTHOR.txt
Expand Up @@ -10,13 +10,14 @@ Christopher Combelles
Dan Korostelev
Daniel Nouri
Darryl Cousins
David Glick
Herman Himmelbauer
Jacob Holm
Laurent Mignon
Malthe Borch
Marius Gedminas
Martijn Faassen
Martin Aspeli
Michael Howitz
Michael Kerrin
Paul Carduner
Martin Aspeli
18 changes: 17 additions & 1 deletion CHANGES.txt
Expand Up @@ -2,7 +2,23 @@
CHANGES
=======

2.3.3 (unreleased)
2.3.5 (unreleased)
------------------

- Bug: Radio widget was not treating value as a list in hidden mode.


2.3.4 (2010-05-17)
------------------

- Bugfix: applyChanges should not try to compare old and new values if the old
value can not be accessed.

- Fix DictionaryField to conform to the IDataManager spec: get() should raise
an exception if no value can be found.


2.3.3 (2010-04-20)
------------------

- The last discriminator of the 'message' IValue adapter used in the
Expand Down
1 change: 1 addition & 0 deletions COPYRIGHT.txt
@@ -0,0 +1 @@
Zope Foundation and Contributors
74 changes: 32 additions & 42 deletions LICENSE.txt
@@ -1,54 +1,44 @@
Zope Public License (ZPL) Version 2.1
-------------------------------------

A copyright notice accompanies this license document that
identifies the copyright holders.
A copyright notice accompanies this license document that identifies the
copyright holders.

This license has been certified as open source. It has also
been designated as GPL compatible by the Free Software
Foundation (FSF).
This license has been certified as open source. It has also been designated as
GPL compatible by the Free Software Foundation (FSF).

Redistribution and use in source and binary forms, with or
without modification, are permitted provided that the
following conditions are met:
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

1. Redistributions in source code must retain the
accompanying copyright notice, this list of conditions,
and the following disclaimer.
1. Redistributions in source code must retain the accompanying copyright
notice, this list of conditions, and the following disclaimer.

2. Redistributions in binary form must reproduce the accompanying
copyright notice, this list of conditions, and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
2. Redistributions in binary form must reproduce the accompanying copyright
notice, this list of conditions, and the following disclaimer in the
documentation and/or other materials provided with the distribution.

3. Names of the copyright holders must not be used to
endorse or promote products derived from this software
without prior written permission from the copyright
holders.
3. Names of the copyright holders must not be used to endorse or promote
products derived from this software without prior written permission from the
copyright holders.

4. The right to distribute this software or to use it for
any purpose does not give you the right to use
Servicemarks (sm) or Trademarks (tm) of the copyright
holders. Use of them is covered by separate agreement
with the copyright holders.
4. The right to distribute this software or to use it for any purpose does not
give you the right to use Servicemarks (sm) or Trademarks (tm) of the
copyright
holders. Use of them is covered by separate agreement with the copyright
holders.

5. If any files are modified, you must cause the modified
files to carry prominent notices stating that you changed
the files and the date of any change.
5. If any files are modified, you must cause the modified files to carry
prominent notices stating that you changed the files and the date of any
change.

Disclaimer

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS``
AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT
NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
NO EVENT SHALL THE COPYRIGHT HOLDERS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
DAMAGE.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY EXPRESSED
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2 changes: 1 addition & 1 deletion bootstrap.py
@@ -1,6 +1,6 @@
##############################################################################
#
# Copyright (c) 2007 Zope Corporation and Contributors.
# Copyright (c) 2007 Zope Foundation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Expand Up @@ -45,7 +45,7 @@ def read(*rnames):

setup (
name='z3c.form',
version = '2.3.3dev',
version = '2.3.5dev',
author = "Stephan Richter, Roger Ineichen and the Zope Community",
author_email = "zope-dev@zope.org",
description = "An advanced form and widget framework for Zope 3",
Expand Down
4 changes: 2 additions & 2 deletions src/z3c/form/browser/radio.txt
Expand Up @@ -115,8 +115,8 @@ Check HIDDEN_MODE:
... (zope.interface.Interface, IDefaultBrowserLayer, None, None, None),
... IPageTemplate, name='hidden')

>>> widget.value = 'true'
>>> widget.value = ['true']
>>> widget.mode = interfaces.HIDDEN_MODE
>>> print widget.render()
<input id="widget-id" name="widget.name" value="true" class="hidden-widget" type="hidden" />
<input id="widget-id-0" name="widget.name:list" value="true" class="hidden-widget" type="hidden" />

21 changes: 12 additions & 9 deletions src/z3c/form/browser/radio_hidden.pt
@@ -1,13 +1,16 @@
<div xmlns="http://www.w3.org/1999/xhtml"
xmlns:tal="http://xml.zope.org/namespaces/tal"
tal:omit-tag="">
<input id="" name="" value="" class="hidden-widget" title=""
tabindex="" accesskey=""
type="hidden"
tal:attributes="id view/id;
name view/name;
title view/title;
tabindex view/tabindex;
accesskey view/accesskey;
value view/value" />
<tal:block tal:repeat="item view/items">
<input id="" name="" value="" class="hidden-widget" title=""
tabindex="" accesskey=""
type="hidden"
tal:condition="item/checked"
tal:attributes="id item/id;
name item/name;
title view/title;
tabindex view/tabindex;
accesskey view/accesskey;
value item/value" />
</tal:block>
</div>
7 changes: 3 additions & 4 deletions src/z3c/form/converter.py
Expand Up @@ -114,7 +114,7 @@ def toFieldValue(self, value):
return self.field.missing_value
try:
return self.formatter.parse(value)
except zope.i18n.format.NumberParseError, err:
except zope.i18n.format.NumberParseError:
raise FormatterValidationError(self.errorMessage, value)

class IntegerDataConverter(NumberDataConverter):
Expand Down Expand Up @@ -265,7 +265,7 @@ def toWidgetValue(self, value):
terms = widget.updateTerms()
try:
return [terms.getTerm(value).token]
except LookupError, err:
except LookupError:
# Swallow lookup errors, in case the options changed.
return []

Expand All @@ -274,7 +274,7 @@ def toFieldValue(self, value):
widget = self.widget
if not len(value) or value[0] == widget.noValueToken:
return self.field.missing_value
terms = widget.updateTerms()
widget.updateTerms()
return widget.terms.getValue(value[0])


Expand Down Expand Up @@ -326,7 +326,6 @@ def toWidgetValue(self, value):

def toFieldValue(self, value):
"""See interfaces.IDataConverter"""
widget = self.widget
collectionType = self.field._type
if isinstance(collectionType, tuple):
collectionType = collectionType[-1]
Expand Down
6 changes: 5 additions & 1 deletion src/z3c/form/datamanager.py
Expand Up @@ -28,6 +28,7 @@

from z3c.form import interfaces

_marker = []

class DataManager(object):
"""Data manager base class."""
Expand Down Expand Up @@ -117,7 +118,10 @@ def __init__(self, data, field):

def get(self):
"""See z3c.form.interfaces.IDataManager"""
return self.data.get(self.field.__name__, self.field.missing_value)
value = self.data.get(self.field.__name__, _marker)
if value is _marker:
raise AttributeError
return value

def query(self, default=interfaces.NO_VALUE):
"""See z3c.form.interfaces.IDataManager"""
Expand Down
3 changes: 3 additions & 0 deletions src/z3c/form/datamanager.txt
Expand Up @@ -283,6 +283,9 @@ The datamanager can really only deal with dictionaries and mapping types:
Let's now access the name:

>>> nameDm.get()
Traceback (most recent call last):
...
AttributeError

>>> nameDm.query()
<NO_VALUE>
Expand Down
1 change: 0 additions & 1 deletion src/z3c/form/field.py
Expand Up @@ -161,7 +161,6 @@ def omit(self, *names, **kwargs):
assert len(kwargs) == 0
if prefix:
names = [util.expandPrefix(prefix) + name for name in names]
fields = [field for field in self.values()]
return self.__class__(
*[field for name, field in self.items()
if not ((name in names and interface is None) or
Expand Down
6 changes: 4 additions & 2 deletions src/z3c/form/form.py
Expand Up @@ -44,9 +44,11 @@ def applyChanges(form, content, data):
dm = zope.component.getMultiAdapter(
(content, field.field), interfaces.IDataManager)
# Only update the data, if it is different
# Or we can not get the original value, in which case we can not check
# Or it is an Object, in case we'll never know
if (dm.get() != data[name]
or zope.schema.interfaces.IObject.providedBy(field.field)):
if (not dm.canAccess() or
dm.get() != data[name] or
zope.schema.interfaces.IObject.providedBy(field.field)):
dm.set(data[name])
# Record the change using information required later
changes.setdefault(dm.field.interface, []).append(name)
Expand Down
2 changes: 1 addition & 1 deletion src/z3c/form/locales/z3c.form.pot
@@ -1,6 +1,6 @@
##############################################################################
#
# Copyright (c) 2003-2004 Zope Corporation and Contributors.
# Copyright (c) 2003-2004 Zope Foundation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
Expand Down
2 changes: 1 addition & 1 deletion src/z3c/form/object.py
Expand Up @@ -229,7 +229,7 @@ def applyValue(self, widget, value=interfaces.NO_VALUE):
interfaces.IValidator).validate(value)

widget.value = converter.toWidgetValue(value)
except (zope.schema.ValidationError, ValueError), error:
except (zope.schema.ValidationError, ValueError):
# on exception, setup the widget error message
# set the wrong value as value
# the widget itself ought to cry about the error
Expand Down

0 comments on commit 8ab5f62

Please sign in to comment.