You can subscribe to this list here.
| 2004 |
Jan
|
Feb
|
Mar
(1) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(10) |
Dec
(4) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2005 |
Jan
(1) |
Feb
(8) |
Mar
(8) |
Apr
(4) |
May
(19) |
Jun
(1) |
Jul
(1) |
Aug
(18) |
Sep
(18) |
Oct
(19) |
Nov
(75) |
Dec
(80) |
| 2006 |
Jan
(86) |
Feb
(61) |
Mar
(60) |
Apr
(47) |
May
(39) |
Jun
(16) |
Jul
(30) |
Aug
(13) |
Sep
(13) |
Oct
(21) |
Nov
(1) |
Dec
(10) |
| 2007 |
Jan
(2) |
Feb
(7) |
Mar
(9) |
Apr
(3) |
May
(9) |
Jun
(4) |
Jul
(1) |
Aug
(2) |
Sep
|
Oct
(12) |
Nov
(1) |
Dec
(7) |
| 2008 |
Jan
|
Feb
(2) |
Mar
(14) |
Apr
(9) |
May
(23) |
Jun
(4) |
Jul
|
Aug
(13) |
Sep
(8) |
Oct
(15) |
Nov
(40) |
Dec
(14) |
| 2009 |
Jan
|
Feb
(4) |
Mar
(10) |
Apr
(2) |
May
(2) |
Jun
(1) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2010 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(1) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2011 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(1) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|
From: <sub...@co...> - 2011-05-17 15:59:05
|
Author: ianb Date: Tue May 17 09:58:56 2011 New Revision: 4389 Log: note repo moving Added: FormEncode/trunk/REPO_HAS_MOVED.txt (contents, props changed) Added: FormEncode/trunk/REPO_HAS_MOVED.txt ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ FormEncode/trunk/REPO_HAS_MOVED.txt Tue May 17 09:58:56 2011 (r4389) @@ -0,0 +1,5 @@ +This repository has moved to: + https://bitbucket.org/ianb/formencode + +You can check it out like: + hg clone https://bitbucket.org/ianb/formencode |
|
From: <sub...@co...> - 2010-05-11 20:33:01
|
Author: chrisz
Date: 2010-05-11 14:32:50 -0600 (Tue, 11 May 2010)
New Revision: 4195
Modified:
FormEncode/trunk/formencode/htmlfill_schemabuilder.py
FormEncode/trunk/tests/test_htmlfill.py
Log:
htmlfill_schemabuilder.parse_schema() was broken.
Modified: FormEncode/trunk/formencode/htmlfill_schemabuilder.py
===================================================================
--- FormEncode/trunk/formencode/htmlfill_schemabuilder.py 2010-05-05 18:49:41 UTC (rev 4194)
+++ FormEncode/trunk/formencode/htmlfill_schemabuilder.py 2010-05-11 20:32:50 UTC (rev 4195)
@@ -7,7 +7,7 @@
``Schema`` object.
"""
-import validators, schema, compound
+import validators, schema, compound, htmlfill
__all__ = ['parse_schema', 'SchemaBuilder']
@@ -16,10 +16,10 @@
Given an HTML form, parse out the schema defined in it and return
that schema.
"""
- listener = htmlfill_schemabuilder.SchemaBuilder()
+ listener = SchemaBuilder()
p = htmlfill.FillingParser(
defaults={}, listener=listener)
- p.feed(self.form)
+ p.feed(form)
p.close()
return listener.schema()
@@ -64,23 +64,23 @@
def schema(self):
return self._schema
-
+
def listen_input(self, parser, tag, attrs):
get_attr = parser.get_attr
name = get_attr(attrs, 'name')
if not name:
# @@: should warn if you try to validate unnamed fields
return
- v = compound.All(validators.Identity())
+ v = compound.All(validators.Identity())
add_to_end = None
# for checkboxes, we must set if_missing = False
- if tag.lower() == "input":
+ if tag.lower() == "input":
type_attr = get_attr(attrs, "type").lower().strip()
if type_attr == "submit":
v.validators.append(validators.Bool())
elif type_attr == "checkbox":
- v.validators.append(validators.Wrapper(to_python = force_list))
- elif type_attr == "file":
+ v.validators.append(validators.Wrapper(to_python = force_list))
+ elif type_attr == "file":
add_to_end = validators.FieldStorageUploadConverter()
message = get_attr(attrs, 'form:message')
required = to_bool(get_attr(attrs, 'form:required', 'false'))
@@ -89,8 +89,8 @@
validators.NotEmpty(
messages=get_messages(validators.NotEmpty, message)))
else:
- v.validators[0].if_missing = False
- if add_to_end:
+ v.validators[0].if_missing = False
+ if add_to_end:
v.validators.append(add_to_end)
v_type = get_attr(attrs, 'form:validate', None)
if v_type:
Modified: FormEncode/trunk/tests/test_htmlfill.py
===================================================================
--- FormEncode/trunk/tests/test_htmlfill.py 2010-05-05 18:49:41 UTC (rev 4194)
+++ FormEncode/trunk/tests/test_htmlfill.py 2010-05-11 20:32:50 UTC (rev 4195)
@@ -74,6 +74,7 @@
print expected
assert 0
checker(p, listener.schema())
+ checker(p, htmlfill_schemabuilder.parse_schema(template))
def test_no_trailing_newline():
assert (htmlfill.render('<html><body></body></html>', {}, {})
@@ -88,10 +89,10 @@
assert (htmlfill.render('<input type="submit" value="Japan - 日本 Nihon" />',
{}, {}) ==
u'<input type="submit" value="Japan - 日本 Nihon" />')
-
+
def test_xhtml():
result = htmlfill.render('<form:error name="code"/>', errors={'code': 'an error'})
-
+
def test_trailing_error():
assert (htmlfill.render('<input type="text" name="email">', errors={'email': 'error'},
prefix_error=False)
@@ -131,7 +132,7 @@
def test_unicode():
assert (htmlfill.render(u'<input type="checkbox" name="tags" value="2" />',
- dict(tags=[])) ==
+ dict(tags=[])) ==
'<input type="checkbox" name="tags" value="2" />')
def test_not_force_defaults_text():
@@ -269,7 +270,7 @@
rendered_html = htmlfill.render(html, defaults=dict(),
force_defaults=False)
assert html == rendered_html, rendered_html
-
+
def test_not_force_defaults_select_selected():
html = """
<select name="select-1" class="my_select">
@@ -284,7 +285,7 @@
rendered_html = htmlfill.render(html, defaults={"select-1": "option-1"},
force_defaults=False)
assert html == rendered_html, rendered_html
-
+
def test_not_force_defaults_select_not_selected():
html = """
<select name="select-1" class="my_select">
|
|
From: <sub...@co...> - 2009-06-04 00:50:03
|
Author: ianb Date: 2009-06-03 18:49:59 -0600 (Wed, 03 Jun 2009) New Revision: 3910 Modified: FormEncode/trunk/docs/Validator.txt Log: fix sphinx markup Modified: FormEncode/trunk/docs/Validator.txt =================================================================== --- FormEncode/trunk/docs/Validator.txt 2009-06-03 20:47:24 UTC (rev 3909) +++ FormEncode/trunk/docs/Validator.txt 2009-06-04 00:49:59 UTC (rev 3910) @@ -115,7 +115,7 @@ There's lots of validators. The best way to read about the individual validators available in the ``formencode.validators`` module is to -read about :module:`formencode.validators`. +read about :mod:`formencode.validators`. Compound Validators ------------------- @@ -577,7 +577,7 @@ HTML forms, however, do not produce nested structures -- they produce flat structures with keys (input names) and associated values. -Validator includes the module :module:`formencode.variabledecode`, +Validator includes the module :mod:`formencode.variabledecode`, which allows you to encode nested dictionary and list structures into a flat dictionary. |
|
From: <sub...@co...> - 2009-05-22 19:05:11
|
Author: ianb
Date: 2009-05-22 13:04:57 -0600 (Fri, 22 May 2009)
New Revision: 3906
Modified:
FormEncode/trunk/docs/Validator.txt
Log:
Fix up links to use Sphinx
Modified: FormEncode/trunk/docs/Validator.txt
===================================================================
--- FormEncode/trunk/docs/Validator.txt 2009-05-19 18:49:43 UTC (rev 3905)
+++ FormEncode/trunk/docs/Validator.txt 2009-05-22 19:04:57 UTC (rev 3906)
@@ -148,9 +148,8 @@
... return value
.. note::
- `formencode.FancyValidator
- <class-formencode.api.FancyValidator.html>`__ is the superclass for
- most validators in FormEncode, and it provides a number of useful
+ :class:`formencode.FancyValidator` is the superclass for most
+ validators in FormEncode, and it provides a number of useful
features that most validators can use -- for instance, you can pass
``strip=True`` into any of these validators, and they'll strip
whitespace from the incoming value before any other validation.
@@ -158,11 +157,10 @@
This overrides ``_to_python``: ``formencode.FancyValidator`` adds a
number of extra features, and then calls the private ``_to_python``
method, which is the method you'll typically write. When a validator
-finds an error it raises an exception (`formencode.Invalid
-<class-formencode.api.Invalid.html>`_), with the error message and the
-value and "state" objects. We'll talk about state_ later. Here's the
-other custom validator, that checks passwords against words in the
-standard Unix word file::
+finds an error it raises an exception (:class:`formencode.Invalid`),
+with the error message and the value and "state" objects. We'll talk
+about state_ later. Here's the other custom validator, that checks
+passwords against words in the standard Unix word file::
>>> class SecurePassword(formencode.FancyValidator):
... words_filename = '/usr/share/dict/words'
@@ -199,17 +197,16 @@
Most validators (anything that subclasses
``formencode.FancyValidator``) will take a certain standard set of
-constructor keyword arguments. See `FancyValidator
-<class-formencode.api.FancyValidator.html>`__ for more -- here we use
+constructor keyword arguments. See
+:class:`formencode.api.FancyValidator` for more -- here we use
``not_empty=True``.
-Another notable validator is `All
-<class-formencode.compound.All.html>`_ -- this is a *compound
-validator* -- that is, it's a validator that takes validators as
-input. Schemas are one example; in this case ``All`` takes a list of
-validators and applies each of them in turn. `Any
-<class-formencode.compound.Any.html>`_ is its compliment, that uses
-the first passing validator in its list.
+Another notable validator is :class:`formencode.compound.All` -- this
+is a *compound validator* -- that is, it's a validator that takes
+validators as input. Schemas are one example; in this case ``All``
+takes a list of validators and applies each of them in turn.
+:class:`formencode.compound.Any` is its compliment, that uses the
+first passing validator in its list.
.. _pre_validators:
.. _chained_validators:
@@ -231,9 +228,9 @@
email_confirm error keys, which is likely the desired behavior
for web forms.
-Since a `Schema <class-formencode.schema.Schema.html>`_ is just
-another kind of validator, you can nest these indefinitely, validating
-dictionaries of dictionaries.
+Since a :class:`formencode.schema.Schema` is just another kind of
+validator, you can nest these indefinitely, validating dictionaries of
+dictionaries.
.. _SimpleFormValidator:
@@ -270,11 +267,11 @@
.. _ForEach:
-You can also validate lists of items using `ForEach
-<class-formencode.foreach.ForEach.html>`__. For example, let's say we
-have a form where someone can edit a list of book titles. Each title
-has an associated book ID, so we can match up the new title and the
-book it is for::
+You can also validate lists of items using
+:class:`formencode.foreach.ForEach`. For example, let's say we have a
+form where someone can edit a list of book titles. Each title has an
+associated book ID, so we can match up the new title and the book it
+is for::
>>> class BookSchema(formencode.Schema):
... id = validators.Int()
@@ -372,8 +369,8 @@
.. _FancyValidator:
There are several options that most validators support (including your
-own validators, if you subclass from `FancyValidator
-<class-formencode.api.FancyValidator.html>`__):
+own validators, if you subclass from
+:class:`formencode.api.FancyValidator`):
``if_empty``:
If set, then this value will be returned if the input evaluates
@@ -425,10 +422,9 @@
just put it in the state object as an attribute, then look for that
attribute in your validator.
-Also, during compound validation (a `Schema
-<class-formencode.schema.Schema.html>`_ or `ForEach
-<class-formencode.foreach.ForEach.html>`__) the state (if not None)
-will have more instance variables added to it. During a ``Schema``
+Also, during compound validation (a :class:`formencode.schema.Schema`
+or :class:`formencode.foreach.ForEach`) the state (if not None) will
+have more instance variables added to it. During a ``Schema``
(dictionary) validation the instance variable ``key`` and
``full_dict`` will be added -- ``key`` is the current key (i.e.,
validator name), and ``full_dict`` is the rest of the values being
@@ -438,9 +434,8 @@
Invalid Exceptions
------------------
-Besides the string error message, `Invalid
-<class-formencode.api.Invalid.html>`_ exceptions have a few other
-instance variables:
+Besides the string error message, :class:`formencode.api.Invalid`
+exceptions have a few other instance variables:
``value``:
The input to the validator that failed.
@@ -558,7 +553,7 @@
Then test, and send the PO and MO files to g....@gr....
See also `the Python internationalization documents
-<http://docs.python.org/lib/node738.html>`_.
+<http://docs.python.org/library/gettext.html>`_.
Optionally you can also add a test of your language to
``tests/test_i18n.py``. An Example of a language test::
|
|
From: <sub...@co...> - 2009-05-19 18:49:51
|
Author: ianb Date: 2009-05-19 12:49:43 -0600 (Tue, 19 May 2009) New Revision: 3905 Modified: FormEncode/trunk/formencode/i18n/el/LC_MESSAGES/FormEncode.po Log: updates to the greek translation from zepolen Modified: FormEncode/trunk/formencode/i18n/el/LC_MESSAGES/FormEncode.po =================================================================== --- FormEncode/trunk/formencode/i18n/el/LC_MESSAGES/FormEncode.po 2009-05-18 17:39:09 UTC (rev 3904) +++ FormEncode/trunk/formencode/i18n/el/LC_MESSAGES/FormEncode.po 2009-05-19 18:49:43 UTC (rev 3905) @@ -43,11 +43,11 @@ #: formencode/national.py:34 msgid "Britain" -msgstr "" +msgstr "Βρετανία" #: formencode/national.py:35 msgid "Great Britain" -msgstr "" +msgstr "Μεγάλη Βρετανία" #: formencode/national.py:36 msgid "Cote de Ivoire" @@ -56,7 +56,7 @@ #: formencode/national.py:137 #, python-format msgid "%d digits" -msgstr "" +msgstr "%d ψηφία" #: formencode/national.py:158 #, python-format @@ -79,15 +79,15 @@ #: formencode/national.py:288 msgid "Please enter a valid postal code (for format see BS 7666)" -msgstr "" +msgstr "Εισαγετε ενα σωστό ταχυδρομικό κώδικα (δείτε το BS 7666)" #: formencode/national.py:329 msgid "That country is not listed in ISO 3166" -msgstr "" +msgstr "Αυτή η χώρα δέν είναι στο ISO 3166" #: formencode/national.py:382 msgid "Given postal code does not match the country's format." -msgstr "" +msgstr "Ο ταχυδρομικός κωδικας δεν είναι σωστός για την χώρα." #: formencode/national.py:472 msgid "Please enter a state code" @@ -110,29 +110,28 @@ "###-###-####, προαιρετικά με \"ext.####\"" #: formencode/national.py:635 -#, fuzzy msgid "Please enter a number, with area code, in the form +##-###-#######." msgstr "" "Παρακαλούμε εισάγετε έναν αριθμό, με τον κωδικό περιοχής, στη μορφή " -"###-###-####, προαιρετικά με \"ext.####\"" +"+##-###-#######." #: formencode/national.py:713 msgid "That language is not listed in ISO 639" -msgstr "" +msgstr "Αυτή η γλώσσα δέν είναι καταχωρημένη στο ISO 639" #: formencode/schema.py:61 #, python-format msgid "The input field %(name)s was not expected." -msgstr "" +msgstr "Το πεδίο %(name)s δεν επιτρέπεται εδώ." #: formencode/schema.py:62 msgid "Missing value" -msgstr "" +msgstr "Λείπει πεδίο" #: formencode/schema.py:63 -#, fuzzy, python-format +#, python-format msgid "The input must be dict-like (not a %(type)s: %(value)r)" -msgstr "Η είσοδος πρέπει να είναι τύπου συμβολοσειράς (όχι %(type)s: %(value)r)" +msgstr "Η τιμή πρέπει να είναι τύπου λεξικού (όχι %(type)s: %(value)r)" #: formencode/validators.py:172 #, python-format @@ -244,14 +243,14 @@ msgstr "Η ημερομηνία πρέπει να είναι στο μέλλον" #: formencode/validators.py:934 -#, fuzzy, python-format +#, python-format msgid "Please enter a number that is %(min)s or greater" -msgstr "Παρακαλούμε εισάγετε έναν αριθμό για το χρόνο" +msgstr "Παρακαλούμε εισάγετε έναν αριθμό που είναι %(min)s η μεγαλύτερο" #: formencode/validators.py:935 -#, fuzzy, python-format +#, python-format msgid "Please enter a number that is %(max)s or smaller" -msgstr "Παρακαλούμε εισάγετε έναν αριθμό για το χρόνο" +msgstr "Παρακαλούμε εισάγετε έναν αριθμό που είναι %(max)s η μικρότερο" #: formencode/validators.py:974 msgid "Please enter an integer value" @@ -340,7 +339,7 @@ #: formencode/validators.py:1467 #, python-format msgid "You must provide a full domain name (like %(domain)s.com)" -msgstr "" +msgstr "Εισάγετε πλήρης domain (π.χ. %(domain)s.com)" #: formencode/validators.py:1603 msgid "" @@ -350,7 +349,7 @@ #: formencode/validators.py:1604 msgid "Dots and dashes may not be repeated consecutively" -msgstr "" +msgstr "Απαγορεύεται να υπάρχουν τελίες και παύλες στην σειρά" #: formencode/validators.py:1605 #, python-format @@ -367,9 +366,9 @@ msgstr "" #: formencode/validators.py:1609 -#, fuzzy, python-format +#, python-format msgid "The XRI must be a string (not a %(type)s: %(value)r)" -msgstr "Η είσοδος πρέπει να είναι τύπου συμβολοσειράς (όχι %(type)s: %(value)r)" +msgstr "Το XRI πρέπει να είναι τύπου συμβολοσειράς (όχι %(type)s: %(value)r)" #: formencode/validators.py:1610 #, python-format @@ -414,9 +413,8 @@ msgstr "Παρακαλούμε εισάγετε έναν αριθμό για το χρόνο" #: formencode/validators.py:1942 -#, fuzzy msgid "Please enter a four-digit year after 1899" -msgstr "Παρακαλούμε εισάγετε ένα χρόνο με τέσσερα ψηφία" +msgstr "Παρακαλούμε εισάγετε ένα χρόνο με τέσσερα ψηφία μετά το 1899" #: formencode/validators.py:2129 msgid "You must indicate AM or PM" @@ -479,14 +477,14 @@ msgid "" "A MAC address must contain 12 digits and A-F; the value you gave has " "%(length)s characters" -msgstr "" +msgstr "Μια διεύθηνση MAC πρέπει να περιέχει 12 ψηφία και A-F; η τιμή που βάλατε ήταν %(length)s χαρακτήρες" #: formencode/validators.py:2548 #, python-format msgid "" "MAC addresses may only contain 0-9 and A-F (and optionally :), not " "%(char)r" -msgstr "" +msgstr "Διευθύνσεις MAC μπορούν μόνο να περιέχουν 0-9 και A-F (και προαιρετικά :), οχί %(char)r" #: formencode/validators.py:2680 #, python-format @@ -499,7 +497,7 @@ #: formencode/validators.py:2682 msgid "Fields should be a dictionary" -msgstr "" +msgstr "Τα πεδια πρέπει να είναι λεξικό" #: formencode/validators.py:2759 msgid "Please enter only the number, no other characters" @@ -516,7 +514,7 @@ #: formencode/validators.py:2762 #, python-format msgid "The field %(key)s is missing" -msgstr "" +msgstr "Το πεδίο %(key)s λείπει" #: formencode/validators.py:2881 msgid "Please enter numbers only for month and year" @@ -528,7 +526,7 @@ #: formencode/validators.py:2951 msgid "Please enter numbers only for credit card security code" -msgstr "" +msgstr "Παρακαλώ εισάγετε νούμερο μονο για των κωδικό της πιστωτικής κάρτας" "Παρακαλούμε εισάγετε μόνο αριθμούς για τον κωδικό ασφάλειας της " "πιστωτικής κάρτας" |
|
From: <sub...@co...> - 2009-04-17 20:48:38
|
Author: ianb Date: 2009-04-17 14:48:21 -0600 (Fri, 17 Apr 2009) New Revision: 3859 Modified: FormEncode/trunk/docs/Design.txt FormEncode/trunk/docs/ToDo.txt FormEncode/trunk/docs/Validator.txt FormEncode/trunk/docs/htmlfill.txt Log: Fixed a number of links in the documentation Modified: FormEncode/trunk/docs/Design.txt =================================================================== --- FormEncode/trunk/docs/Design.txt 2009-04-17 17:12:08 UTC (rev 3858) +++ FormEncode/trunk/docs/Design.txt 2009-04-17 20:48:21 UTC (rev 3859) @@ -24,15 +24,12 @@ nothing is done until everything validates, you can use this without transactions. -FormEncode generally works on primitive types (though you could extend -it to deal with your own types if you wish; `formencode.sqlschema -<module-formencode.sqlschema.html>`_ is an example of this). These -are things like strings, lists, dictionaries, integers, etc. This -fits in with look-before-you-leap; often your domain objects won't -exist until after you apply the user's request, so it's necessary to -work on an early form of the data. Also, FormEncode doesn't know -anything about your domain objects or classes; it's just easier to -keep it this way. +FormEncode generally works on primitive types. These are things like +strings, lists, dictionaries, integers, etc. This fits in with +look-before-you-leap; often your domain objects won't exist until +after you apply the user's request, so it's necessary to work on an +early form of the data. Also, FormEncode doesn't know anything about +your domain objects or classes; it's just easier to keep it this way. Validation only operates on a single "value" at a time. This is Python, collections are easy, and collections are themselves a single Modified: FormEncode/trunk/docs/ToDo.txt =================================================================== --- FormEncode/trunk/docs/ToDo.txt 2009-04-17 17:12:08 UTC (rev 3858) +++ FormEncode/trunk/docs/ToDo.txt 2009-04-17 20:48:21 UTC (rev 3859) @@ -33,12 +33,6 @@ * Make ``doctest_xml_compare`` work with wildcards/ellipses. Maybe with non-XHTML. -* Maybe include `wareweb.packing - <http://pythonpaste.org/wareweb/module-wareweb.packing.html>`_, - which is kind like like one-way validation for really small forms. - A compliment/alternative to `variabledecode - <module-formencode.variabledecode.html>`_. - * Some more ways to build validation. Validation from docstrings or method signatures. Modified: FormEncode/trunk/docs/Validator.txt =================================================================== --- FormEncode/trunk/docs/Validator.txt 2009-04-17 17:12:08 UTC (rev 3858) +++ FormEncode/trunk/docs/Validator.txt 2009-04-17 20:48:21 UTC (rev 3859) @@ -115,8 +115,7 @@ There's lots of validators. The best way to read about the individual validators available in the ``formencode.validators`` module is to -read the `validators generated documentation -<module-formencode.validators.html#classes>`_. +read about :module:`formencode.validators`. Compound Validators ------------------- @@ -504,13 +503,13 @@ When a failed validation occurs FormEncode tries to output the error message in the appropriate language. For this it uses the standard -`gettext <http://python.org/doc/current/lib/module-gettext.html>`_ -mechanism of python. To translate the message in the appropirate -message FormEncode has to find a gettext function that translates the -string. The language to be translated into and the used domain is -determined by the found gettext function. To serve a standard -translation mechanism and to enable custom translations it looks in -the following order to find a gettext (``_``) function: +`gettext <http://docs.python.org/library/gettext.html>`_ mechanism of +python. To translate the message in the appropirate message FormEncode +has to find a gettext function that translates the string. The +language to be translated into and the used domain is determined by +the found gettext function. To serve a standard translation mechanism +and to enable custom translations it looks in the following order to +find a gettext (``_``) function: 1. method of the ``state`` object @@ -577,15 +576,15 @@ HTTP/HTML Form Input -------------------- -The validation expects nested data structures; specifically `Schema -<class-formencode.schema.Schema.html>`_ and `ForEach -<class-formencode.foreach.ForEach.html>`__ deal with these structures -well. HTML forms, however, do not produce nested structures -- they -produce flat structures with keys (input names) and associated values. +The validation expects nested data structures; specifically +:class:`formencode.schema.Schema` and +:class:`formencode.foreach.ForEach` deal with these structures well. +HTML forms, however, do not produce nested structures -- they produce +flat structures with keys (input names) and associated values. -Validator includes the module `variabledecode -<module-formencode.variabledecode.html>`, which allows you to encode -nested dictionary and list structures into a flat dictionary. +Validator includes the module :module:`formencode.variabledecode`, +which allows you to encode nested dictionary and list structures into +a flat dictionary. To do this it uses keys with ``"."`` for nested dictionaries, and ``"-int"`` for (ordered) lists. So something like: @@ -626,10 +625,9 @@ with ``'-int'``, where they are ordered by the integer (the integers are used for sorting, missing numbers in a sequence are ignored). -`NestedVariables -<class-formencode.variabledecode.NestedVariables.html>`_ is a -validator that decodes and encodes dictionaries using this algorithm. -You can use it with a Schema's `pre_validators`_ attribute. +:class:`formencode.variabledecode.NestedVariables` is a validator that +decodes and encodes dictionaries using this algorithm. You can use it +with a Schema's `pre_validators`_ attribute. Of course, in the example we use the data is rather eclectic -- for instance, Tim Smith doesn't have his name separated into first and Modified: FormEncode/trunk/docs/htmlfill.txt =================================================================== --- FormEncode/trunk/docs/htmlfill.txt 2009-04-17 17:12:08 UTC (rev 3858) +++ FormEncode/trunk/docs/htmlfill.txt 2009-04-17 20:48:21 UTC (rev 3859) @@ -13,11 +13,11 @@ Introduction ============ -`htmlfill <module-formencode.htmlfill.html>`_ is a library to fill out -forms, both with default values and error messages. It's like a -template library, but more limited, and it can be used with the output -from other templates. It has no prerequesites, and can be used -without any other parts of FormEncode. +:mod:`formencode.htmlfill` is a library to fill out forms, both with default +values and error messages. It's like a template library, but more +limited, and it can be used with the output from other templates. It +has no prerequesites, and can be used without any other parts of +FormEncode. Usage ===== @@ -36,8 +36,7 @@ return the form to the user with the values they entered, in addition to errors. -See `formencode.htmlfill.render for more -<modules/htmlfill.html#formencode.htmlfill.render>`_ for more. +See :func:`formencode.htmlfill.render` for more. Errors ------ @@ -99,5 +98,5 @@ it, without reformatting it too much. If HTMLParser_ chokes on the code, so will htmlfill. -.. _HTMLParser: http://python.org/doc/current/lib/module-HTMLParser.html +.. _HTMLParser: http://docs.python.org/library/htmlparser.html |
|
From: <sub...@co...> - 2009-04-07 04:09:01
|
Author: ianb Date: 2009-04-06 22:08:56 -0600 (Mon, 06 Apr 2009) New Revision: 3846 Modified: FormEncode/trunk/formencode/fieldstorage.py FormEncode/trunk/formencode/validators.py Log: Remove distracting LGPL headers Modified: FormEncode/trunk/formencode/fieldstorage.py =================================================================== --- FormEncode/trunk/formencode/fieldstorage.py 2009-04-07 00:28:51 UTC (rev 3845) +++ FormEncode/trunk/formencode/fieldstorage.py 2009-04-07 04:08:56 UTC (rev 3846) @@ -1,32 +1,13 @@ ## FormEncode, a Form processor ## Copyright (C) 2003, Ian Bicking <ia...@co...> -## -## This library is free software; you can redistribute it and/or -## modify it under the terms of the GNU Lesser General Public -## License as published by the Free Software Foundation; either -## version 2.1 of the License, or (at your option) any later version. -## -## This library is distributed in the hope that it will be useful, -## but WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -## Lesser General Public License for more details. -## -## You should have received a copy of the GNU Lesser General Public -## License along with this library; if not, write to the Free Software -## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -## -## NOTE: In the context of the Python environment, I interpret "dynamic -## linking" as importing -- thus the LGPL applies to the contents of -## the modules, but make no requirements on code importing these -## modules. """ Wrapper class for use with cgi.FieldStorage types for file uploads -""" - -import cgi - -def convert_fieldstorage(fs): - if fs.filename: - return fs - else: - return None +""" + +import cgi + +def convert_fieldstorage(fs): + if fs.filename: + return fs + else: + return None Modified: FormEncode/trunk/formencode/validators.py =================================================================== --- FormEncode/trunk/formencode/validators.py 2009-04-07 00:28:51 UTC (rev 3845) +++ FormEncode/trunk/formencode/validators.py 2009-04-07 04:08:56 UTC (rev 3846) @@ -1,24 +1,5 @@ ## FormEncode, a Form processor ## Copyright (C) 2003, Ian Bicking <ia...@co...> -## -## This library is free software; you can redistribute it and/or -## modify it under the terms of the GNU Lesser General Public -## License as published by the Free Software Foundation; either -## version 2.1 of the License, or (at your option) any later version. -## -## This library is distributed in the hope that it will be useful, -## but WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -## Lesser General Public License for more details. -## -## You should have received a copy of the GNU Lesser General Public -## License along with this library; if not, write to the Free Software -## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -## -## NOTE: In the context of the Python environment, I interpret "dynamic -## linking" as importing -- thus the LGPL applies to the contents of -## the modules, but make no requirements on code importing these -## modules. """ Validator/Converters for use with FormEncode. """ |
|
From: <sub...@co...> - 2009-03-13 15:58:07
|
Author: ianb Date: 2009-03-13 09:58:01 -0600 (Fri, 13 Mar 2009) New Revision: 3813 Modified: FormEncode/trunk/docs/news.txt FormEncode/trunk/formencode/compound.py Log: Don't have Any handle empty values on its own Modified: FormEncode/trunk/docs/news.txt =================================================================== --- FormEncode/trunk/docs/news.txt 2009-03-12 22:04:53 UTC (rev 3812) +++ FormEncode/trunk/docs/news.txt 2009-03-13 15:58:01 UTC (rev 3813) @@ -12,6 +12,10 @@ * Fixes `#2666139 DateValidator bug happening only in March under Windows in Germany :) <http://sourceforge.net/tracker/index.php?func=detail&aid=2666139&group_id=91231&atid=596418>`_ +* Don't let :class:`formencode.compound.Any` shortcut validation when + it gets an empty value (this same change had already been made to + :class:`formencode.compound.All`). + * Really updated German translation 1.2.2 Modified: FormEncode/trunk/formencode/compound.py =================================================================== --- FormEncode/trunk/formencode/compound.py 2009-03-12 22:04:53 UTC (rev 3812) +++ FormEncode/trunk/formencode/compound.py 2009-03-13 15:58:01 UTC (rev 3813) @@ -94,6 +94,10 @@ return not_empty not_empty = property(not_empty__get) + def is_empty(self, value): + # sub-validators should handle emptiness. + return False + class All(CompoundValidator): """ |
|
From: <sub...@co...> - 2009-03-12 20:19:06
|
Author: chrisz Date: 2009-03-12 14:18:59 -0600 (Thu, 12 Mar 2009) New Revision: 3811 Modified: FormEncode/trunk/docs/news.txt FormEncode/trunk/formencode/validators.py FormEncode/trunk/tests/test_validators.py Log: Slightly simplified the r3806 patch; added tests and documentation. Modified: FormEncode/trunk/docs/news.txt =================================================================== --- FormEncode/trunk/docs/news.txt 2009-03-12 18:22:16 UTC (rev 3810) +++ FormEncode/trunk/docs/news.txt 2009-03-12 20:18:59 UTC (rev 3811) @@ -3,13 +3,24 @@ .. contents:: +svn trunk +--------- + +* Allowed :class:`formencode.validators.UnicodeString` to use different + encoding of input and output, or no encoding/decoding at all. + +* Fixes `#2666139 DateValidator bug happening only in March under Windows in Germany :) + <http://sourceforge.net/tracker/index.php?func=detail&aid=2666139&group_id=91231&atid=596418>`_ + +* Really updated German translation + 1.2.2 ----- * Added keyword argument ``force_defaults`` to :func:`formencode.htmlfill.render`; when this is True (the default) this will uncheck checkboxes, unselect select boxes, etc., when a - value is missing from the default dictionary. + value is missing from the default dictionary. * Updated German translation @@ -50,7 +61,7 @@ * :class:`formencode.validators.Number` works with ``inf`` float values (before it would raise a OverflowError). - + * The ``tw`` locale has been renamed to the more standard ``zh_TW``. * Added Japanese and Turkish translations. @@ -63,7 +74,7 @@ --- * Fixed the ``is_empty()`` method in - :class:`formencode.validators.FieldStorageUploadConverter`; + :class:`formencode.validators.FieldStorageUploadConverter`; previously it returned the opposite of the intended result. * Added a parameter to ``htmlfill.render()``: ``prefix_error``. If @@ -129,7 +140,7 @@ chained validators get run even when there are previous errors (to detect all the errors). -* While something like ``Int.to_python()`` worked, other methods like +* While something like ``Int.to_python()`` worked, other methods like ``Int.message(...)`` didn't work. Now it does. * Added Italian, Finnish, and Norwegian translations. Modified: FormEncode/trunk/formencode/validators.py =================================================================== --- FormEncode/trunk/formencode/validators.py 2009-03-12 18:22:16 UTC (rev 3810) +++ FormEncode/trunk/formencode/validators.py 2009-03-12 20:18:59 UTC (rev 3811) @@ -1135,7 +1135,10 @@ the String class. In addition to the String arguments, an encoding argument is also - accepted. By default the encoding will be utf-8. + accepted. By default the encoding will be utf-8. You can overwrite + this using the encoding parameter. You can also set inputEncoding + and outputEncoding differently. An inputEncoding of None means + "do not decode", an outputEncoding of None means "do not encode". All converted strings are returned as Unicode strings. @@ -1156,18 +1159,12 @@ 'badEncoding' : _("Invalid data or incorrect encoding"), } - def __init__(self, inputEncoding=NoDefault, outputEncoding=NoDefault, **kw): + def __init__(self, **kw): String.__init__(self, **kw) - if inputEncoding is NoDefault: - if self.inputEncoding is NoDefault: - self.inputEncoding = self.encoding - else: - self.inputEncoding = inputEncoding - if outputEncoding is NoDefault: - if self.outputEncoding is NoDefault: - self.outputEncoding = self.encoding - else: - self.outputEncoding = outputEncoding + if self.inputEncoding is NoDefault: + self.inputEncoding = self.encoding + if self.outputEncoding is NoDefault: + self.outputEncoding = self.encoding def _to_python(self, value, state): if not value: Modified: FormEncode/trunk/tests/test_validators.py =================================================================== --- FormEncode/trunk/tests/test_validators.py 2009-03-12 18:22:16 UTC (rev 3810) +++ FormEncode/trunk/tests/test_validators.py 2009-03-12 20:18:59 UTC (rev 3811) @@ -53,7 +53,41 @@ un = UnicodeString() assert un.to_python(12) == u'12' assert type(un.to_python(12)) is unicode + assert un.from_python(12) == '12' + assert type(un.from_python(12)) is str + +def test_unicode_encoding(): + uv = UnicodeString() + us = u'käse' + u7s, u8s = us.encode('utf-7'), us.encode('utf-8') + assert uv.to_python(u8s) == us + assert type(uv.to_python(u8s)) is unicode + assert uv.from_python(us) == u8s + assert type(uv.from_python(us)) is str + uv = UnicodeString(encoding='utf-7') + assert uv.to_python(u7s) == us + assert type(uv.to_python(u7s)) is unicode + assert uv.from_python(us) == u7s + assert type(uv.from_python(us)) is str + uv = UnicodeString(inputEncoding='utf-7') + assert uv.to_python(u7s) == us + assert type(uv.to_python(u7s)) is unicode + uv = UnicodeString(outputEncoding='utf-7') + assert uv.from_python(us) == u7s + assert type(uv.from_python(us)) is str + uv = UnicodeString(inputEncoding=None) + assert uv.to_python(us) == us + assert type(uv.to_python(us)) is unicode + assert uv.from_python(us) == u8s + assert type(uv.from_python(us)) is str + uv = UnicodeString(outputEncoding=None) + assert uv.to_python(u8s) == us + assert type(uv.to_python(u8s)) is unicode + assert uv.from_python(us) == us + assert type(uv.from_python(us)) is unicode + + def test_unicode_empty(): iv = UnicodeString() for input in [None, "", u""]: @@ -137,7 +171,7 @@ class TestXRIValidator(unittest.TestCase): """Generic tests for the XRI validator""" - + def test_creation_valid_params(self): """The creation of an XRI validator with valid parameters must succeed""" @@ -146,33 +180,33 @@ XRI(True, "i-number") XRI(False, "i-name") XRI(False, "i-number") - + def test_creation_invalid_xri(self): """Only "i-name" and "i-number" are valid XRIs""" self.assertRaises(AssertionError, XRI, True, 'i-something') - + def test_valid_simple_individual_iname_without_type(self): """XRIs must start with either an equals sign or an at sign""" validator = XRI(True, "i-name") self.assertRaises(Invalid, validator.validate_python, 'Gustavo') - + def test_valid_iname_with_schema(self): """XRIs may have their schema in the beggining""" validator = XRI() self.assertEqual(validator.to_python('xri://=Gustavo'), 'xri://=Gustavo') - + def test_schema_is_added_if_asked(self): """The schema must be added to an XRI if explicitly asked""" validator = XRI(True) self.assertEqual(validator.to_python('=Gustavo'), 'xri://=Gustavo') - + def test_schema_not_added_if_not_asked(self): """The schema must not be added to an XRI unless explicitly asked""" validator = XRI() self.assertEqual(validator.to_python('=Gustavo'), '=Gustavo') - + def test_spaces_are_trimmed(self): """Spaces at the beggining or end of the XRI are removed""" validator = XRI() @@ -181,90 +215,90 @@ class TestINameValidator(unittest.TestCase): """Tests for the XRI i-names validator""" - + def setUp(self): self.validator = XRI(xri_type="i-name") - + def test_valid_global_individual_iname(self): """Global & valid individual i-names must pass validation""" self.validator.validate_python('=Gustavo') - + def test_valid_global_organizational_iname(self): """Global & valid organizational i-names must pass validation""" self.validator.validate_python('@Canonical') - + def test_invalid_iname(self): """Non-string i-names are rejected""" self.assertRaises(Invalid, self.validator.validate_python, None) - + def test_exclamation_in_inames(self): """Exclamation marks at the beggining of XRIs is something specific to i-numbers and must be rejected in i-names""" self.assertRaises(Invalid, self.validator.validate_python, "!!1000!de21.4536.2cb2.8074") - + def test_repeated_characters(self): """Dots and dashes must not be consecutively repeated in i-names""" self.assertRaises(Invalid, self.validator.validate_python, "=Gustavo--Narea") self.assertRaises(Invalid, self.validator.validate_python, "=Gustavo..Narea") - + def test_punctuation_marks_at_beggining(self): """Punctuation marks at the beggining of i-names are forbidden""" self.assertRaises(Invalid, self.validator.validate_python, "=.Gustavo") self.assertRaises(Invalid, self.validator.validate_python, "=-Gustavo.Narea") - + def test_numerals_at_beggining(self): """Numerals at the beggining of i-names are forbidden""" self.assertRaises(Invalid, self.validator.validate_python, "=1Gustavo") - + def test_non_english_inames(self): """i-names with non-English characters are valid""" self.validator.validate_python(u'=Gustavo.Narea.García') self.validator.validate_python(u'@名前.例') - + def test_inames_plus_paths(self): """i-names with paths are valid but not supported""" self.assertRaises(Invalid, self.validator.validate_python, "=Gustavo/(+email)") - + def test_communities(self): """i-names may have so-called 'communities'""" self.validator.validate_python(u'=María*Yolanda*Liliana*Gustavo') self.validator.validate_python(u'=Gustavo*Andreina') self.validator.validate_python(u'@IBM*Lenovo') - - + + class TestINumberValidator(unittest.TestCase): """Tests for the XRI i-number validator""" - + def setUp(self): self.validator = XRI(xri_type="i-number") - + def test_valid_global_personal_inumber(self): """Global & valid personal i-numbers must pass validation""" self.validator.validate_python('=!1000.a1b2.93d2.8c73') - + def test_valid_global_organizational_inumber(self): """Global & valid organizational i-numbers must pass validation""" self.validator.validate_python('@!1000.a1b2.93d2.8c73') - + def test_valid_global_network_inumber(self): """Global & valid network i-numbers must pass validation""" self.validator.validate_python('!!1000') - + def test_valid_community_personal_inumbers(self): """Community & valid personal i-numbers must pass validation""" self.validator.validate_python('=!1000.a1b2.93d2.8c73!3ae2!1490') - + def test_valid_community_organizational_inumber(self): """Community & valid organizational i-numbers must pass validation""" self.validator.validate_python('@!1000.9554.fabd.129c!2847.df3c') - + def test_valid_community_network_inumber(self): """Community & valid network i-numbers must pass validation""" self.validator.validate_python('!!1000!de21.4536.2cb2.8074') @@ -272,25 +306,25 @@ class TestOpenIdValidator(unittest.TestCase): """Tests for the OpenId validator""" - + def setUp(self): self.validator = OpenId(add_schema=False) - + def test_url(self): self.assertEqual(self.validator.to_python('http://example.org'), 'http://example.org') - + def test_iname(self): self.assertEqual(self.validator.to_python('=Gustavo'), '=Gustavo') - + def test_inumber(self): self.assertEqual(self.validator.to_python('!!1000'), '!!1000') - + def test_email(self): """Email addresses are not valid OpenIds!""" self.assertRaises(Invalid, self.validator.to_python, "wa...@bu...") - + def test_prepending_schema(self): validator = OpenId(add_schema=True) self.assertEqual(validator.to_python("example.org"), |
|
From: <sub...@co...> - 2009-03-12 17:26:25
|
Author: chrisz
Date: 2009-03-12 11:26:20 -0600 (Thu, 12 Mar 2009)
New Revision: 3806
Modified:
FormEncode/trunk/formencode/validators.py
Log:
Added specific default values for input and output encoding to UnicodeString on the class level.
Modified: FormEncode/trunk/formencode/validators.py
===================================================================
--- FormEncode/trunk/formencode/validators.py 2009-03-12 16:59:49 UTC (rev 3805)
+++ FormEncode/trunk/formencode/validators.py 2009-03-12 17:26:20 UTC (rev 3806)
@@ -1150,6 +1150,8 @@
"""
encoding = 'utf-8'
+ inputEncoding = NoDefault
+ outputEncoding = NoDefault
messages = {
'badEncoding' : _("Invalid data or incorrect encoding"),
}
@@ -1157,11 +1159,13 @@
def __init__(self, inputEncoding=NoDefault, outputEncoding=NoDefault, **kw):
String.__init__(self, **kw)
if inputEncoding is NoDefault:
- self.inputEncoding = self.encoding
+ if self.inputEncoding is NoDefault:
+ self.inputEncoding = self.encoding
else:
self.inputEncoding = inputEncoding
if outputEncoding is NoDefault:
- self.outputEncoding = self.encoding
+ if self.outputEncoding is NoDefault:
+ self.outputEncoding = self.encoding
else:
self.outputEncoding = outputEncoding
|
|
From: <sub...@co...> - 2009-03-12 16:59:54
|
Author: chrisz
Date: 2009-03-12 10:59:49 -0600 (Thu, 12 Mar 2009)
New Revision: 3805
Modified:
FormEncode/trunk/formencode/validators.py
Log:
Allow None (with the meaning "do not decode/encode" as input or output decoding for UnicodeString. This is useful if you're sending output to a templating engine which usually expect unicode objects instead of encoded strings.
Modified: FormEncode/trunk/formencode/validators.py
===================================================================
--- FormEncode/trunk/formencode/validators.py 2009-03-09 18:15:44 UTC (rev 3804)
+++ FormEncode/trunk/formencode/validators.py 2009-03-12 16:59:49 UTC (rev 3805)
@@ -1154,10 +1154,16 @@
'badEncoding' : _("Invalid data or incorrect encoding"),
}
- def __init__(self, inputEncoding=None, outputEncoding=None, **kw):
+ def __init__(self, inputEncoding=NoDefault, outputEncoding=NoDefault, **kw):
String.__init__(self, **kw)
- self.inputEncoding = inputEncoding or self.encoding
- self.outputEncoding = outputEncoding or self.encoding
+ if inputEncoding is NoDefault:
+ self.inputEncoding = self.encoding
+ else:
+ self.inputEncoding = inputEncoding
+ if outputEncoding is NoDefault:
+ self.outputEncoding = self.encoding
+ else:
+ self.outputEncoding = outputEncoding
def _to_python(self, value, state):
if not value:
@@ -1170,12 +1176,15 @@
return value
else:
value = str(value)
- try:
- return unicode(value, self.inputEncoding)
- except UnicodeDecodeError:
- raise Invalid(self.message('badEncoding', state), value, state)
- except TypeError:
- raise Invalid(self.message('badType', state, type=type(value), value=value), value, state)
+ if self.inputEncoding:
+ try:
+ value = unicode(value, self.inputEncoding)
+ except UnicodeDecodeError:
+ raise Invalid(self.message('badEncoding', state), value, state)
+ except TypeError:
+ raise Invalid(self.message('badType', state, type=type(value),
+ value=value), value, state)
+ return value
def _from_python(self, value, state):
if not isinstance(value, unicode):
@@ -1183,7 +1192,7 @@
value = unicode(value)
else:
value = str(value)
- if isinstance(value, unicode):
+ if self.outputEncoding and isinstance(value, unicode):
value = value.encode(self.outputEncoding)
return value
@@ -1534,16 +1543,16 @@
self.message('status', state, status=res.status),
state, url)
-
+
class XRI(FancyValidator):
r"""
Validator for XRIs.
-
+
It supports both i-names and i-numbers, of the first version of the XRI
standard.
-
+
::
-
+
>>> inames = XRI(xri_type="i-name")
>>> inames.to_python(" =John.Smith ")
'=John.Smith'
@@ -1573,9 +1582,9 @@
'!!1000!de21.4536.2cb2.8074'
>>> inumbers.to_python("@!1000.9554.fabd.129c!2847.df3c")
'@!1000.9554.fabd.129c!2847.df3c'
-
+
"""
-
+
iname_valid_pattern = re.compile(r"""
^
[\w]+ # A global alphanumeric i-name
@@ -1583,11 +1592,11 @@
(\*[\w]+(\.[\w]+)*)* # A community i-name
$
""", re.VERBOSE|re.UNICODE)
-
-
+
+
iname_invalid_start = re.compile(r"^[\d\.-]", re.UNICODE)
"""@cvar: These characters must not be at the beggining of the i-name"""
-
+
inumber_pattern = re.compile(r"""
^
(
@@ -1599,7 +1608,7 @@
(![\dA-F]{1,4}(\.[\dA-F]{1,4}){0,3})* # Zero or more sub i-numbers
$
""", re.VERBOSE|re.IGNORECASE)
-
+
messages = {
'noType': _("The type of i-name is not defined; it may be either individual or organizational"),
'repeatedChar': _("Dots and dashes may not be repeated consecutively"),
@@ -1610,24 +1619,24 @@
'badType': _("The XRI must be a string (not a %(type)s: %(value)r)"),
'badXri': _('"%(xri_type)s" is not a valid type of XRI')
}
-
+
def __init__(self, add_xri=False, xri_type="i-name", **kwargs):
"""Create an XRI validator.
-
+
@param add_xri: Should the schema be added if not present? Officially
it's optional.
@type add_xri: C{bool}
@param xri_type: What type of XRI should be validated? Possible values:
C{i-name} or C{i-number}.
@type xri_type: C{str}
-
+
"""
self.add_xri = add_xri
assert xri_type in ('i-name', 'i-number'), \
('xri_type must be "i-name" or "i-number"')
self.xri_type = xri_type
super(XRI, self).__init__(**kwargs)
-
+
def _to_python(self, value, state):
"""Prepend the 'xri://' schema if necessary and then remove trailing
spaces"""
@@ -1635,35 +1644,35 @@
if self.add_xri and not value.startswith("xri://"):
value = "xri://" + value
return value
-
+
def validate_python(self, value, state=None):
"""Validate an XRI
-
+
@raise Invalid: If at least one of the following conditions in met:
- C{value} is not a string.
- The XRI is not a personal, organizational or network one.
- The relevant validator (i-name or i-number) considers the XRI
is not valid.
-
+
"""
if not (isinstance(value, str) or isinstance(value, unicode)):
raise Invalid(self.message("badType", state, type=str(type(value)),
value=value),
value, state)
-
+
# Let's remove the schema, if any
if value.startswith("xri://"):
value = value[6:]
-
+
if not value[0] in ('@', '=') and not (self.xri_type == "i-number" \
and value[0] == '!'):
raise Invalid(self.message("noType", state), value, state)
-
+
if self.xri_type == "i-name":
self._validate_iname(value, state)
else:
self._validate_inumber(value, state)
-
+
def _validate_iname(self, iname, state):
"""Validate an i-name"""
# The type is not required here:
@@ -1675,7 +1684,7 @@
if not self.iname_valid_pattern.match(iname) or "_" in iname:
raise Invalid(self.message("badIname", state, iname=iname), iname,
state)
-
+
def _validate_inumber(self, inumber, state):
"""Validate an i-number"""
if not self.__class__.inumber_pattern.match(inumber):
@@ -1687,7 +1696,7 @@
class OpenId(FancyValidator):
r"""
OpenId validator.
-
+
::
>>> v = OpenId(add_schema=True)
>>> v.to_python(' example.net ')
@@ -1705,24 +1714,24 @@
Traceback (most recent call last):
...
Invalid: "lo...@me..." is not a valid OpenId (it is neither an URL nor an XRI)
-
+
"""
-
+
messages = {
'badId': _('"%(id)s" is not a valid OpenId (it is neither an URL nor an XRI)')
}
-
+
def __init__(self, add_schema=False, **kwargs):
"""Create an OpenId validator.
-
+
@param add_schema: Should the schema be added if not present?
@type add_schema: C{bool}
-
+
"""
self.url_validator = URL(add_http=add_schema)
self.iname_validator = XRI(add_schema, xri_type="i-name")
self.inumber_validator = XRI(add_schema, xri_type="i-number")
-
+
def _to_python(self, value, state):
value = value.strip()
try:
@@ -1737,7 +1746,7 @@
pass
# It's not an OpenId!
raise Invalid(self.message("badId", state, id=value), value, state)
-
+
def validate_python(self, value, state):
self._to_python(value, state)
|
|
From: <sub...@co...> - 2009-03-05 23:37:07
|
Author: chrisz Date: 2009-03-05 16:36:56 -0700 (Thu, 05 Mar 2009) New Revision: 3802 Modified: FormEncode/trunk/formencode/i18n/de/LC_MESSAGES/FormEncode.mo FormEncode/trunk/formencode/i18n/de/LC_MESSAGES/FormEncode.po Log: Update the German translations. Modified: FormEncode/trunk/formencode/i18n/de/LC_MESSAGES/FormEncode.mo =================================================================== (Binary files differ) Modified: FormEncode/trunk/formencode/i18n/de/LC_MESSAGES/FormEncode.po =================================================================== --- FormEncode/trunk/formencode/i18n/de/LC_MESSAGES/FormEncode.po 2009-03-05 23:03:14 UTC (rev 3801) +++ FormEncode/trunk/formencode/i18n/de/LC_MESSAGES/FormEncode.po 2009-03-05 23:36:56 UTC (rev 3802) @@ -1,23 +1,24 @@ # German strings for FormEncode # Copyright (C) 2006 Gregor Horvath, licence: LGPL V2.0 # Gregor Horvath <gh...@gr...>, 2006. -# Updated by Christoph Zwerschke <ci...@on...>, 2008. +# Updated by Christoph Zwerschke <ci...@on...>, 2009. # msgid "" msgstr "" "Project-Id-Version: FormEncode 1.0.1\n" "Report-Msgid-Bugs-To: EMAIL@ADDRESS\n" "POT-Creation-Date: 2008-03-29 12:00+0100\n" -"PO-Revision-Date: 2008-12-19 16:50-0800\n" +"PO-Revision-Date: 2009-02-24 12:00+0100\n" "Last-Translator: Christoph Zwerschke <ci...@on...>\n" "Language-Team: Gregor Horvath <gh...@gr...>\n" "Plural-Forms: nplurals=2; plural=(n != 1)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=utf-8\n" "Content-Transfer-Encoding: 8bit\n" -"Generated-By: Babel 1.0dev-r458\n" +"Generated-By: Babel 0.9.3\n" -#: formencode/api.py:388 formencode/validators.py:447 +#: formencode/api.py:388 +#: formencode/validators.py:447 msgid "Please enter a value" msgstr "Bitte einen Wert eingeben" @@ -32,63 +33,63 @@ #: formencode/national.py:27 msgid "Belarus" -msgstr "" +msgstr "Weißrussland" #: formencode/national.py:28 msgid "Montenegro" -msgstr "" +msgstr "Montenegro" #: formencode/national.py:29 msgid "Tasmania" -msgstr "" +msgstr "Tasmanien" #: formencode/national.py:34 msgid "Britain" -msgstr "" +msgstr "Britannien" #: formencode/national.py:35 msgid "Great Britain" -msgstr "" +msgstr "Großbritannien" #: formencode/national.py:36 msgid "Cote de Ivoire" -msgstr "" +msgstr "Elfenbeinküste" #: formencode/national.py:137 #, python-format msgid "%d digits" -msgstr "" +msgstr "%d Ziffern" #: formencode/national.py:158 #, python-format -#| msgid "Please enter a zip code (%s)" msgid "Please enter a zip code (%%s)" msgstr "Bitte eine Postleitzahl eingeben (%%s)" -#: formencode/national.py:218 formencode/national.py:253 +#: formencode/national.py:218 +#: formencode/national.py:253 #, python-format msgid "Please enter a zip code (%s)" msgstr "Bitte eine Postleitzahl eingeben (%s)" #: formencode/national.py:218 msgid "LnnnnLLL" -msgstr "" +msgstr "BzzzzBBB" #: formencode/national.py:253 msgid "LnL nLn" -msgstr "" +msgstr "BzB zBz" #: formencode/national.py:288 msgid "Please enter a valid postal code (for format see BS 7666)" -msgstr "" +msgstr "Bitte geben Sie eine gültige Postleitzahl ein (Format gemäß BS 7666)" #: formencode/national.py:329 msgid "That country is not listed in ISO 3166" -msgstr "" +msgstr "Dieses Land ist nicht unter ISO 3166 gelistet" #: formencode/national.py:382 msgid "Given postal code does not match the country's format." -msgstr "" +msgstr "Die eingegebene Postleitzahl ist nicht im landesspezifischen Format." #: formencode/national.py:472 msgid "Please enter a state code" @@ -103,12 +104,8 @@ msgstr "Das ist kein gültiges Landeskürzel" #: formencode/national.py:528 -msgid "" -"Please enter a number, with area code, in the form ###-###-####, " -"optionally with \"ext.####\"" -msgstr "" -"Bitte geben Sie eine Nummer mit Vorwahl in der Form ###-###-#### ein, " -"oder mit \"ext.####\"" +msgid "Please enter a number, with area code, in the form ###-###-####, optionally with \"ext.####\"" +msgstr "Bitte geben Sie eine Nummer mit Vorwahl in der Form ###-###-#### ein, oder mit \"ext.####\"" #: formencode/national.py:635 msgid "Please enter a number, with area code, in the form +##-###-#######." @@ -116,7 +113,7 @@ #: formencode/national.py:713 msgid "That language is not listed in ISO 639" -msgstr "" +msgstr "Diese Sprache ist nicht unter ISO 639 gelistet" #: formencode/schema.py:61 #, python-format @@ -155,9 +152,10 @@ #: formencode/validators.py:356 #, python-format msgid "Enter a value less than %(maxLength)i characters long" -msgstr "Geben Sie einen Wert kürzer als %(maxLength)i Zeichen ein" +msgstr "Geben Sie einen Wert mit höchstens %(maxLength)i Zeichen ein" -#: formencode/validators.py:357 formencode/validators.py:413 +#: formencode/validators.py:357 +#: formencode/validators.py:413 msgid "Invalid value (value with length expected)" msgstr "Ungültiger Wert (Wert mit Länge erwartet)" @@ -202,12 +200,8 @@ #: formencode/validators.py:684 #, python-format -msgid "" -"Nothing in my dictionary goes by the value %(value)s. Choose one of: " -"%(items)s" -msgstr "" -"Mein Wörterbuch enthält nicht den Wert: %(value)s. Wählen Sie einen der " -"folgenden Wert: %(items)s" +msgid "Nothing in my dictionary goes by the value %(value)s. Choose one of: %(items)s" +msgstr "Meine Zuordnungsliste enthält nicht den Wert %(value)s. Wählen Sie einen der folgenden Werte: %(items)s" #: formencode/validators.py:745 msgid "Must be an integer index" @@ -230,7 +224,7 @@ #: formencode/validators.py:823 #, python-format msgid "Date must be before %(date)s" -msgstr "Datum muß vor dem %(date)s liegen" +msgstr "Datum muss vor dem %(date)s liegen" #: formencode/validators.py:825 #, python-format @@ -242,14 +236,14 @@ msgstr "Das Datum muss in der Zukunft liegen" #: formencode/validators.py:934 -#, fuzzy, python-format +#, python-format msgid "Please enter a number that is %(min)s or greater" -msgstr "Bitte eine Jahreszahl eingeben" +msgstr "Bitte geben Sie eine Zahl ein, die größer oder gleich %(min)s ist" #: formencode/validators.py:935 -#, fuzzy, python-format +#, python-format msgid "Please enter a number that is %(max)s or smaller" -msgstr "Bitte eine Jahreszahl eingeben" +msgstr "Bitte geben Sie eine Zahl ein, die kleiner oder gleich %(max)s ist" #: formencode/validators.py:974 msgid "Please enter an integer value" @@ -262,12 +256,12 @@ #: formencode/validators.py:1079 #, python-format msgid "Enter a value less than %(max)i characters long" -msgstr "Bitte einen Wert kürzer als %(max)i Zeichen eingeben" +msgstr "Bitte einen Wert mit weniger als %(max)i Zeichen eingeben" #: formencode/validators.py:1080 #, python-format msgid "Enter a value %(min)i characters long or more" -msgstr "Bitte einen Wert mit %(min)i oder mehr Zeichen eingeben" +msgstr "Bitte einen Wert mit mindestens %(min)i Zeichen eingeben" #: formencode/validators.py:1153 msgid "Invalid data or incorrect encoding" @@ -283,37 +277,24 @@ #: formencode/validators.py:1321 #, python-format -msgid "" -"The username portion of the email address is invalid (the portion before " -"the @: %(username)s)" -msgstr "" -"Der Benutzername in der E-Mail-Adresse is ungültig (der Teil vor dem @: " -"%(username)s)" +msgid "The username portion of the email address is invalid (the portion before the @: %(username)s)" +msgstr "Der Benutzername in der E-Mail-Adresse is ungültig (der Teil vor dem @: %(username)s)" -#: formencode/validators.py:1322 formencode/validators.py:1464 +#: formencode/validators.py:1322 +#: formencode/validators.py:1464 #, python-format msgid "An error occured when trying to connect to the server: %(error)s" -msgstr "" -"Beim Verbindungsversuch mit dem Server ist ein Fehler aufgetreten: " -"%(error)s" +msgstr "Beim Verbindungsversuch mit dem Server ist ein Fehler aufgetreten: %(error)s" #: formencode/validators.py:1323 #, python-format -msgid "" -"The domain portion of the email address is invalid (the portion after the" -" @: %(domain)s)" -msgstr "" -"Der Domainname in der E-Mail-Adresse ist ungültig (der Teil nach dem @: " -"%(domain)s)" +msgid "The domain portion of the email address is invalid (the portion after the @: %(domain)s)" +msgstr "Der Domainname in der E-Mail-Adresse ist ungültig (der Teil nach dem @: %(domain)s)" #: formencode/validators.py:1324 #, python-format -msgid "" -"The domain of the email address does not exist (the portion after the @: " -"%(domain)s)" -msgstr "" -"Die Domain in der E-Mail-Adresse existiert nicht (der Teil nach dem @: " -"%(domain)s)" +msgid "The domain of the email address does not exist (the portion after the @: %(domain)s)" +msgstr "Die Domain in der E-Mail-Adresse existiert nicht (der Teil nach dem @: %(domain)s)" #: formencode/validators.py:1461 msgid "You must start your URL with http://, https://, etc" @@ -340,48 +321,47 @@ #: formencode/validators.py:1467 #, python-format msgid "You must provide a full domain name (like %(domain)s.com)" -msgstr "" +msgstr "Sie müssen einen vollständigen Domainnamen angeben (wie %(domain)s.com)" #: formencode/validators.py:1603 -msgid "" -"The type of i-name is not defined; it may be either individual or " -"organizational" -msgstr "" +msgid "The type of i-name is not defined; it may be either individual or organizational" +msgstr "Der Typ des I-Namens (Person oder Organisation) ist undefiniert" #: formencode/validators.py:1604 msgid "Dots and dashes may not be repeated consecutively" -msgstr "" +msgstr "Punkte und Bindestriche dürfen nicht aufeinander folgen" #: formencode/validators.py:1605 #, python-format msgid "\"%(iname)s\" is an invalid i-name" -msgstr "" +msgstr "\"%(iname)s\" ist ein ungültiger I-Name" #: formencode/validators.py:1606 msgid "i-names may not start with numbers nor punctuation marks" -msgstr "" +msgstr "I-Namen dürfen nicht mit Zahlen oder Satzzeichen beginnen" #: formencode/validators.py:1608 #, python-format msgid "\"%(inumber)s\" is an invalid i-number" -msgstr "" +msgstr "\"%(inumber)s\" ist eine ungültige I-Nummer" #: formencode/validators.py:1609 -#, fuzzy, python-format +#, python-format msgid "The XRI must be a string (not a %(type)s: %(value)r)" -msgstr "Die Eingabe muss eine Zeichenfolge sein (nicht ein %(type)s: %(value)r)" +msgstr "Die XRI muss eine Zeichenfolge sein (nicht ein %(type)s: %(value)r)" #: formencode/validators.py:1610 #, python-format msgid "\"%(xri_type)s\" is not a valid type of XRI" -msgstr "" +msgstr "\"%(xri_type)s\" ist kein gültiger XRI-Typ" #: formencode/validators.py:1711 #, python-format msgid "\"%(id)s\" is not a valid OpenId (it is neither an URL nor an XRI)" -msgstr "" +msgstr "\"%(id)s\" ist eine ungültige OpenId (weder URL noch XRI)" -#: formencode/validators.py:1935 formencode/validators.py:1943 +#: formencode/validators.py:1935 +#: formencode/validators.py:1943 #, python-format msgid "Please enter the date in the form %(format)s" msgstr "Bitte geben Sie das Datum in der Form %(format)s ein" @@ -475,21 +455,13 @@ #: formencode/validators.py:2547 #, python-format -msgid "" -"A MAC address must contain 12 digits and A-F; the value you gave has " -"%(length)s characters" -msgstr "" -"Eine MAC-Adresse muss 12 Ziffern und A-F enthalten; Ihre Eingabe hat " -"%(length)s Zeichen" +msgid "A MAC address must contain 12 digits and A-F; the value you gave has %(length)s characters" +msgstr "Eine MAC-Adresse muss 12 Ziffern und A-F enthalten; Ihre Eingabe hat %(length)s Zeichen" #: formencode/validators.py:2548 #, python-format -msgid "" -"MAC addresses may only contain 0-9 and A-F (and optionally :), not " -"%(char)r" -msgstr "" -"MAC-Adressen dürfen nur 0-9 und A-F (und Doppelpunkte) enthalten, nicht " -"%(char)r" +msgid "MAC addresses may only contain 0-9 and A-F (and optionally :), not %(char)r" +msgstr "MAC-Adressen dürfen nur 0-9 und A-F (und Doppelpunkte) enthalten, nicht %(char)r" #: formencode/validators.py:2680 #, python-format @@ -502,7 +474,7 @@ #: formencode/validators.py:2682 msgid "Fields should be a dictionary" -msgstr "" +msgstr "Felder sollten Dictionaries sein" #: formencode/validators.py:2759 msgid "Please enter only the number, no other characters" @@ -519,7 +491,7 @@ #: formencode/validators.py:2762 #, python-format msgid "The field %(key)s is missing" -msgstr "" +msgstr "Das Feld %(key)s fehlt" #: formencode/validators.py:2881 msgid "Please enter numbers only for month and year" |
|
From: <sub...@co...> - 2009-03-05 23:03:20
|
Author: chrisz
Date: 2009-03-05 16:03:14 -0700 (Thu, 05 Mar 2009)
New Revision: 3801
Modified:
FormEncode/trunk/formencode/validators.py
Log:
Fix for bug #2666139: On a German Win XP system, DateValidator breaks in March when the German locale is activated, because the month name contains a non-ascii character and DateValidator tries to decode it, wrongly assuming the system is using utf-8, while Windows is using cp1252.
Modified: FormEncode/trunk/formencode/validators.py
===================================================================
--- FormEncode/trunk/formencode/validators.py 2009-03-05 17:53:16 UTC (rev 3800)
+++ FormEncode/trunk/formencode/validators.py 2009-03-05 23:03:14 UTC (rev 3801)
@@ -23,6 +23,7 @@
Validator/Converters for use with FormEncode.
"""
+import locale
import warnings
import re
DateTime = None
@@ -829,8 +830,8 @@
def validate_python(self, value, state):
date_format = self.message('date_format', state)
if isinstance(date_format, unicode):
- # strftime doesn't like unicode
- encoding = 'utf8'
+ # strftime uses the locale encoding, not Unicode
+ encoding = locale.getlocale(locale.LC_TIME)[1] or 'utf-8'
date_format = date_format.encode(encoding)
else:
encoding = None
|
|
From: <sub...@co...> - 2009-03-05 17:53:25
|
Author: ianb Date: 2009-03-05 10:53:16 -0700 (Thu, 05 Mar 2009) New Revision: 3800 Modified: FormEncode/trunk/setup.py Log: Auto-update of version strings Modified: FormEncode/trunk/setup.py =================================================================== --- FormEncode/trunk/setup.py 2009-03-05 17:53:13 UTC (rev 3799) +++ FormEncode/trunk/setup.py 2009-03-05 17:53:16 UTC (rev 3800) @@ -1,7 +1,7 @@ import sys from setuptools import setup -version = '1.2.2' +version = '1.2.3' tests_require = ['nose'] if sys.version < '2.5': |
|
From: <sub...@co...> - 2009-03-05 17:53:18
|
Author: ianb Date: 2009-03-05 10:53:13 -0700 (Thu, 05 Mar 2009) New Revision: 3799 Modified: FormEncode/tags/1.2.2/setup.cfg Log: Auto-update of version strings Modified: FormEncode/tags/1.2.2/setup.cfg =================================================================== --- FormEncode/tags/1.2.2/setup.cfg 2009-03-05 17:52:56 UTC (rev 3798) +++ FormEncode/tags/1.2.2/setup.cfg 2009-03-05 17:53:13 UTC (rev 3799) @@ -1,67 +1,62 @@ +[init_catalog] +domain = FormEncode +output_dir = formencode/i18n +input_file = formencode/i18n/FormEncode.pot + [global] command_packages = buildutils.pudge_command, buildutils.publish_command -[egg_info] -tag_build = dev -tag_svn_revision = true +[nosetests] +detailed-errors = 1 +[publish] +doc-dest = scp://ianbicking@shell.sf.net/home/groups/f/fo/formencode/htdocs/ +doc-dir = docs/html + +[update_catalog] +domain = FormEncode +previous = true +output_dir = formencode/i18n +input_file = formencode/i18n/FormEncode.pot + [pudge] -theme = pythonpaste.org -docs = docs/index.txt docs/Validator.txt docs/ToDo.txt - docs/news.txt docs/htmlfill.txt docs/Design.txt - docs/community.txt docs/download.txt - docs/history.txt docs/i18n.txt -doc_base = docs/ +organization = FormEncode +title = FormEncode dest = docs/html +docs = docs/index.txt docs/Validator.txt docs/ToDo.txt + docs/news.txt docs/htmlfill.txt docs/Design.txt + docs/community.txt docs/download.txt + docs/history.txt docs/i18n.txt +settings = normal_link_color=#083 + visited_color=#038 + hover_color=#dfd + body_outer_bg_color=#173 + body_border_color=#0f0 + nav_container_color=#7d9 + nav_button_color=#073 + nav_border_color=#0f5 + doctitle_color=#009900 + no_about=true + link1=/Validator.html Documentation modules = formencode -exclude_modules = formencode.fields formencode.formgen - formencode.sqlformgen formencode.sqlschema -title = FormEncode +doc_base = docs/ +theme = pythonpaste.org mailing_list_url = http://formencode.org/community.html -organization = FormEncode -settings = normal_link_color=#083 - visited_color=#038 - hover_color=#dfd - body_outer_bg_color=#173 - body_border_color=#0f0 - nav_container_color=#7d9 - nav_button_color=#073 - nav_border_color=#0f5 - doctitle_color=#009900 +exclude_modules = formencode.fields formencode.formgen + formencode.sqlformgen formencode.sqlschema - no_about=true - link1=/Validator.html Documentation - -[publish] -doc-dir = docs/html -doc-dest = scp://ianbicking@shell.sf.net/home/groups/f/fo/formencode/htdocs/ - -[aliases] -distribute = register sdist bdist_egg upload pudge publish - -[nosetests] -detailed-errors = 1 - -# Babel configuration [compile_catalog] -domain = FormEncode directory = formencode/i18n +domain = FormEncode statistics = true [extract_messages] -add_comments = TRANSLATORS: -output_file = formencode/i18n/FormEncode.pot charset = utf-8 -msgid_bugs_address = for...@li... +output_file = formencode/i18n/FormEncode.pot width = 80 +msgid_bugs_address = for...@li... +add_comments = TRANSLATORS: -[init_catalog] -domain = FormEncode -input_file = formencode/i18n/FormEncode.pot -output_dir = formencode/i18n +[aliases] +distribute = register sdist bdist_egg upload pudge publish -[update_catalog] -domain = FormEncode -input_file = formencode/i18n/FormEncode.pot -output_dir = formencode/i18n -previous = true |
|
From: <sub...@co...> - 2009-03-05 17:53:00
|
Author: ianb Date: 2009-03-05 10:52:56 -0700 (Thu, 05 Mar 2009) New Revision: 3798 Added: FormEncode/tags/1.2.2/ Log: Tagging 1.2.2 version Copied: FormEncode/tags/1.2.2 (from rev 3797, FormEncode/trunk) |
|
From: <sub...@co...> - 2009-03-05 17:52:43
|
Author: ianb Date: 2009-03-05 10:52:32 -0700 (Thu, 05 Mar 2009) New Revision: 3797 Modified: FormEncode/trunk/docs/conf.py FormEncode/trunk/docs/news.txt Log: update news for release Modified: FormEncode/trunk/docs/conf.py =================================================================== --- FormEncode/trunk/docs/conf.py 2009-03-04 18:28:14 UTC (rev 3796) +++ FormEncode/trunk/docs/conf.py 2009-03-05 17:52:32 UTC (rev 3797) @@ -40,9 +40,9 @@ # other places throughout the built documents. # # The short X.Y version. -version = '1.2.1' +version = '1.2.2' # The full version, including alpha/beta/rc tags. -release = '1.2.1' +release = '1.2.2' # There are two options for replacing |today|: either, you set today to some # non-false value, then it is used: Modified: FormEncode/trunk/docs/news.txt =================================================================== --- FormEncode/trunk/docs/news.txt 2009-03-04 18:28:14 UTC (rev 3796) +++ FormEncode/trunk/docs/news.txt 2009-03-05 17:52:32 UTC (rev 3797) @@ -3,14 +3,16 @@ .. contents:: -svn trunk ---------- +1.2.2 +----- * Added keyword argument ``force_defaults`` to :func:`formencode.htmlfill.render`; when this is True (the default) this will uncheck checkboxes, unselect select boxes, etc., when a value is missing from the default dictionary. +* Updated German translation + 1.2.1 ----- |
|
From: <sub...@co...> - 2009-02-19 19:13:35
|
Author: jab Date: 2009-02-19 12:13:24 -0700 (Thu, 19 Feb 2009) New Revision: 3788 Modified: FormEncode/trunk/formencode/htmlfill.py FormEncode/trunk/tests/test_htmlfill.py Log: apply patches from https://sourceforge.net/tracker/index.php?func=detail&aid=2616879&group_id=91231&atid=596416 : [ 2616879 ] explicit empty value in text and password fields thanks Marius Gedminas Modified: FormEncode/trunk/formencode/htmlfill.py =================================================================== --- FormEncode/trunk/formencode/htmlfill.py 2009-02-19 18:18:50 UTC (rev 3787) +++ FormEncode/trunk/formencode/htmlfill.py 2009-02-19 19:13:24 UTC (rev 3788) @@ -401,7 +401,7 @@ elif t == 'file': pass # don't skip next elif t == 'password': - if not self.force_defaults: + if value is None and not self.force_defaults: value = value or self.get_attr(attrs, 'value', '') self.set_attr(attrs, 'value', value) self.write_tag('input', attrs, startend) Modified: FormEncode/trunk/tests/test_htmlfill.py =================================================================== --- FormEncode/trunk/tests/test_htmlfill.py 2009-02-19 18:18:50 UTC (rev 3787) +++ FormEncode/trunk/tests/test_htmlfill.py 2009-02-19 19:13:24 UTC (rev 3788) @@ -147,6 +147,13 @@ force_defaults=False) assert expected_html == rendered_html, rendered_html +def test_not_force_defaults_text_explicit_empty_value(): + html = """<input type="text" name="text-1" class="my_text" value="i like this text" />""" + expected_html = """<input type="text" name="text-1" class="my_text" value="" />""" + rendered_html = htmlfill.render(html, defaults={"text-1": ""}, + force_defaults=False) + assert expected_html == rendered_html, rendered_html + def test_force_defaults_text(): html = """<input type="text" name="text-1" class="my_text" value="i like this text" />""" expected_html = """<input type="text" name="text-1" class="my_text" value="" />""" @@ -186,6 +193,13 @@ force_defaults=False) assert expected_html == rendered_html, rendered_html +def test_not_force_defaults_password_explicit_empty_value(): + html = """<input type="password" name="password-1" class="my_password" value="i like this password" />""" + expected_html = """<input type="password" name="password-1" class="my_password" value="" />""" + rendered_html = htmlfill.render(html, defaults={"password-1": ""}, + force_defaults=False) + assert expected_html == rendered_html, rendered_html + def test_force_defaults_password(): html = """<input type="password" name="password-1" class="my_password" value="i like this password" />""" expected_html = """<input type="password" name="password-1" class="my_password" value="" />""" |
|
From: <sub...@co...> - 2009-02-19 18:19:02
|
Author: jab Date: 2009-02-19 11:18:50 -0700 (Thu, 19 Feb 2009) New Revision: 3787 Modified: FormEncode/trunk/formencode/htmlfill.py FormEncode/trunk/tests/test_htmlfill.py Log: apply patches from http://sourceforge.net/tracker2/?func=detail&aid=2616831&group_id=91231&atid=596416 to make htmlfill.render(..., defaults={}, force_defaults=True) behave consistently for text, password, and hidden inputs when passing (values should be cleared). includes now-passing tests. Modified: FormEncode/trunk/formencode/htmlfill.py =================================================================== --- FormEncode/trunk/formencode/htmlfill.py 2009-02-19 17:00:56 UTC (rev 3786) +++ FormEncode/trunk/formencode/htmlfill.py 2009-02-19 18:18:50 UTC (rev 3787) @@ -367,7 +367,7 @@ and self.errors.get(self.get_attr(attrs, 'name'))): self.add_class(attrs, self.error_class) if t in ('text', 'hidden'): - if value is None: + if value is None and not self.force_defaults: value = self.get_attr(attrs, 'value', '') self.set_attr(attrs, 'value', value) self.write_tag('input', attrs, startend) @@ -401,8 +401,9 @@ elif t == 'file': pass # don't skip next elif t == 'password': - self.set_attr(attrs, 'value', value or - self.get_attr(attrs, 'value', '')) + if not self.force_defaults: + value = value or self.get_attr(attrs, 'value', '') + self.set_attr(attrs, 'value', value) self.write_tag('input', attrs, startend) self.skip_next = True self.add_key(name) Modified: FormEncode/trunk/tests/test_htmlfill.py =================================================================== --- FormEncode/trunk/tests/test_htmlfill.py 2009-02-19 17:00:56 UTC (rev 3786) +++ FormEncode/trunk/tests/test_htmlfill.py 2009-02-19 18:18:50 UTC (rev 3787) @@ -134,6 +134,25 @@ dict(tags=[])) == '<input type="checkbox" name="tags" value="2" />') +def test_not_force_defaults_text(): + html = """<input type="text" name="text-1" class="my_text" value="i like this text" />""" + rendered_html = htmlfill.render(html, defaults=dict(), + force_defaults=False) + assert html == rendered_html, rendered_html + +def test_not_force_defaults_text_value(): + html = """<input type="text" name="text-1" class="my_text" value="i like this text" />""" + expected_html = """<input type="text" name="text-1" class="my_text" value="this text is better" />""" + rendered_html = htmlfill.render(html, defaults={"text-1": "this text is better"}, + force_defaults=False) + assert expected_html == rendered_html, rendered_html + +def test_force_defaults_text(): + html = """<input type="text" name="text-1" class="my_text" value="i like this text" />""" + expected_html = """<input type="text" name="text-1" class="my_text" value="" />""" + rendered_html = htmlfill.render(html, defaults=dict()) + assert expected_html == rendered_html, rendered_html + def test_not_force_defaults_textarea(): html = """<textarea name="textarea-1" class="my_textarea">i like this text</textarea>""" rendered_html = htmlfill.render(html, defaults=dict(), @@ -154,6 +173,25 @@ rendered_html = htmlfill.render(html, defaults=dict()) assert expected_html == rendered_html, rendered_html +def test_not_force_defaults_password(): + html = """<input type="password" name="password-1" class="my_password" value="i like this password" />""" + rendered_html = htmlfill.render(html, defaults=dict(), + force_defaults=False) + assert html == rendered_html, rendered_html + +def test_not_force_defaults_password_value(): + html = """<input type="password" name="password-1" class="my_password" value="i like this password" />""" + expected_html = """<input type="password" name="password-1" class="my_password" value="this password is better" />""" + rendered_html = htmlfill.render(html, defaults={"password-1": "this password is better"}, + force_defaults=False) + assert expected_html == rendered_html, rendered_html + +def test_force_defaults_password(): + html = """<input type="password" name="password-1" class="my_password" value="i like this password" />""" + expected_html = """<input type="password" name="password-1" class="my_password" value="" />""" + rendered_html = htmlfill.render(html, defaults=dict()) + assert expected_html == rendered_html, rendered_html + def test_not_force_defaults_checkbox(): html = """<input type="checkbox" name="checkbox-1" class="my_checkbox" checked="checked" value="cb">""" rendered_html = htmlfill.render(html, defaults=dict(), |
|
From: <sub...@co...> - 2009-02-19 17:01:02
|
Author: jab Date: 2009-02-19 10:00:56 -0700 (Thu, 19 Feb 2009) New Revision: 3786 Modified: FormEncode/trunk/tests/test_htmlfill.py Log: apply patches from http://sourceforge.net/tracker2/?func=detail&aid=2616805&group_id=91231&atid=596416 to fix test failures and keep test names consistent. thanks Marius Gedminas (mgedmin) Modified: FormEncode/trunk/tests/test_htmlfill.py =================================================================== --- FormEncode/trunk/tests/test_htmlfill.py 2009-02-19 15:08:48 UTC (rev 3785) +++ FormEncode/trunk/tests/test_htmlfill.py 2009-02-19 17:00:56 UTC (rev 3786) @@ -134,91 +134,91 @@ dict(tags=[])) == '<input type="checkbox" name="tags" value="2" />') -def test_defaults_not_form_submission_textarea(): +def test_not_force_defaults_textarea(): html = """<textarea name="textarea-1" class="my_textarea">i like this text</textarea>""" rendered_html = htmlfill.render(html, defaults=dict(), - defaults_as_form_submission=False) + force_defaults=False) assert html == rendered_html, rendered_html -def test_defaults_not_form_submission_textarea_value(): +def test_not_force_defaults_textarea_value(): html = """<textarea name="textarea-1" class="my_textarea">i like this text</textarea>""" expected_html = """<textarea name="textarea-1" class="my_textarea">this text is better</textarea>""" rendered_html = htmlfill.render(html, defaults={"textarea-1": "this text is better"}, - defaults_as_form_submission=False) + force_defaults=False) assert expected_html == rendered_html, rendered_html -def test_defaults_as_form_submission_textarea(): +def test_force_defaults_textarea(): html = """<textarea name="textarea-1" class="my_textarea">i like this text</textarea>""" expected_html = \ """<textarea name="textarea-1" class="my_textarea"></textarea>""" rendered_html = htmlfill.render(html, defaults=dict()) assert expected_html == rendered_html, rendered_html -def test_defaults_not_form_submission_checkbox(): +def test_not_force_defaults_checkbox(): html = """<input type="checkbox" name="checkbox-1" class="my_checkbox" checked="checked" value="cb">""" rendered_html = htmlfill.render(html, defaults=dict(), - defaults_as_form_submission=False) + force_defaults=False) assert html == rendered_html, rendered_html -def test_defaults_as_form_submission_checkbox(): +def test_force_defaults_checkbox(): html = """<input type="checkbox" name="checkbox-1" class="my_checkbox" checked="checked" value="cb">""" expected_html = \ """<input type="checkbox" name="checkbox-1" class="my_checkbox" value="cb">""" rendered_html = htmlfill.render(html, defaults=dict()) assert expected_html == rendered_html, rendered_html -def test_defaults_not_form_submission_checkbox_default_unchecked(): +def test_not_force_defaults_checkbox_default_unchecked(): html = """<input type="checkbox" name="checkbox-1" class="my_checkbox" checked="checked" value="cb">""" expected_html = \ """<input type="checkbox" name="checkbox-1" class="my_checkbox" value="cb">""" rendered_html = htmlfill.render(html, defaults={"checkbox-1": False}) assert expected_html == rendered_html, rendered_html -def test_defaults_not_form_submission_checkbox_default_checked(): +def test_not_force_defaults_checkbox_default_checked(): html = """<input type="checkbox" name="checkbox-1" class="my_checkbox" value="cb">""" expected_html = \ """<input type="checkbox" name="checkbox-1" class="my_checkbox" value="cb" checked="checked">""" rendered_html = htmlfill.render(html, defaults={"checkbox-1": "cb"}, - defaults_as_form_submission=False) + force_defaults=False) assert expected_html == rendered_html, rendered_html -def test_defaults_not_form_submission_radio(): +def test_not_force_defaults_radio(): html = """<input type="radio" name="radio-1" class="my_radio" checked="checked" value="cb">""" rendered_html = htmlfill.render(html, defaults=dict(), - defaults_as_form_submission=False) + force_defaults=False) assert html == rendered_html, rendered_html -def test_defaults_not_form_submission_radio_unchecked(): +def test_not_force_defaults_radio_unchecked(): html = """<input type="radio" name="radio-1" class="my_radio" checked="checked" value="cb">""" expected_html = """<input type="radio" name="radio-1" class="my_radio" value="cb">""" rendered_html = htmlfill.render(html, defaults={"radio-1": "ba"}, - defaults_as_form_submission=False) + force_defaults=False) assert expected_html == rendered_html, rendered_html -def test_defaults_not_form_submission_radio_checked(): +def test_not_force_defaults_radio_checked(): html = """<input type="radio" name="radio-1" class="my_radio" value="cb">""" expected_html = """<input type="radio" name="radio-1" class="my_radio" value="cb" checked="checked">""" rendered_html = htmlfill.render(html, defaults={"radio-1": "cb"}, - defaults_as_form_submission=False) + force_defaults=False) assert expected_html == rendered_html, rendered_html -def test_defaults_as_form_submission_radio(): +def test_force_defaults_radio(): html = """<input type="radio" name="radio-1" class="my_radio" checked="checked" value="cb">""" expected_html = """<input type="radio" name="radio-1" class="my_radio" value="cb">""" rendered_html = htmlfill.render(html, defaults=dict()) assert expected_html == rendered_html, rendered_html -def test_defaults_not_form_submission_select(): +def test_not_force_defaults_select(): html = """ <select name="select-1" class="my_select"> <option value="option-1" selected="selected">this is option-1</option> </select> """ rendered_html = htmlfill.render(html, defaults=dict(), - defaults_as_form_submission=False) + force_defaults=False) assert html == rendered_html, rendered_html -def test_defaults_not_form_submission_select_selected(): +def test_not_force_defaults_select_selected(): html = """ <select name="select-1" class="my_select"> <option value="option-1">this is option-1</option> @@ -230,10 +230,10 @@ </select> """ rendered_html = htmlfill.render(html, defaults={"select-1": "option-1"}, - defaults_as_form_submission=False) + force_defaults=False) assert html == rendered_html, rendered_html -def test_defaults_not_form_submission_select_not_selected(): +def test_not_force_defaults_select_not_selected(): html = """ <select name="select-1" class="my_select"> <option value="option-1" selected="selected">this is option-1</option> @@ -245,10 +245,10 @@ </select> """ rendered_html = htmlfill.render(html, defaults={"select-1": "option-2"}, - defaults_as_form_submission=False) + force_defaults=False) assert html == rendered_html, rendered_html -def test_defaults_as_form_submission_select(): +def test_force_defaults_select(): html = """ <select name="select-1" class="my_select"> <option value="option-1" selected="selected">this is option-1</option> |
|
From: <sub...@co...> - 2009-02-11 19:16:21
|
Author: ianb
Date: 2009-02-11 12:16:15 -0700 (Wed, 11 Feb 2009)
New Revision: 3784
Modified:
FormEncode/trunk/docs/htmlfill.txt
FormEncode/trunk/docs/news.txt
FormEncode/trunk/formencode/htmlfill.py
FormEncode/trunk/tests/test_htmlfill.py
Log:
Add force_defaults argument to htmlfill.render, which will uncheck checkboxes and other controls when a value is missing from the defaults. From desmaj
Modified: FormEncode/trunk/docs/htmlfill.txt
===================================================================
--- FormEncode/trunk/docs/htmlfill.txt 2009-02-06 13:56:26 UTC (rev 3783)
+++ FormEncode/trunk/docs/htmlfill.txt 2009-02-11 19:16:15 UTC (rev 3784)
@@ -37,7 +37,7 @@
to errors.
See `formencode.htmlfill.render for more
-<module-formencode.htmlfill.html#render>`_ for more.
+<modules/htmlfill.html#formencode.htmlfill.render>`_ for more.
Errors
------
Modified: FormEncode/trunk/docs/news.txt
===================================================================
--- FormEncode/trunk/docs/news.txt 2009-02-06 13:56:26 UTC (rev 3783)
+++ FormEncode/trunk/docs/news.txt 2009-02-11 19:16:15 UTC (rev 3784)
@@ -3,6 +3,14 @@
.. contents::
+svn trunk
+---------
+
+* Added keyword argument ``force_defaults`` to
+ :func:`formencode.htmlfill.render`; when this is True (the default)
+ this will uncheck checkboxes, unselect select boxes, etc., when a
+ value is missing from the default dictionary.
+
1.2.1
-----
Modified: FormEncode/trunk/formencode/htmlfill.py
===================================================================
--- FormEncode/trunk/formencode/htmlfill.py 2009-02-06 13:56:26 UTC (rev 3783)
+++ FormEncode/trunk/formencode/htmlfill.py 2009-02-11 19:16:15 UTC (rev 3784)
@@ -15,7 +15,8 @@
error_formatters=None, add_attributes=None,
auto_insert_errors=True, auto_error_formatter=None,
text_as_default=False, listener=None, encoding=None,
- error_class='error', prefix_error=True):
+ error_class='error', prefix_error=True,
+ force_defaults=True):
"""
Render the ``form`` (which should be a string) given the defaults
and errors. Defaults are the values that go in the input fields
@@ -59,6 +60,13 @@
``prefix_error`` specifies if the HTML created by auto_error_formatter is
put before the input control (default) or after the control.
+
+ ``force_defaults`` specifies if a field default is not given in
+ the ``defaults`` dictionary then the control associated with the
+ field should be set as an unsuccessful control. So checkboxes will
+ be cleared, radio and select controls will have no value selected,
+ and textareas will be emptied. This defaults to ``True``, which is
+ appropriate the defaults are the result of a form submission.
"""
if defaults is None:
defaults = {}
@@ -74,6 +82,7 @@
listener=listener, encoding=encoding,
prefix_error=prefix_error,
error_class=error_class,
+ force_defaults=force_defaults,
)
p.feed(form)
p.close()
@@ -175,13 +184,15 @@
error_formatters=None, error_class='error',
add_attributes=None, listener=None,
auto_error_formatter=None,
- text_as_default=False, encoding=None, prefix_error=True):
+ text_as_default=False, encoding=None, prefix_error=True,
+ force_defaults=True):
RewritingParser.__init__(self)
self.source = None
self.lines = None
self.source_pos = None
self.defaults = defaults
self.in_textarea = None
+ self.skip_textarea = False
self.last_textarea_name = None
self.in_select = None
self.skip_next = False
@@ -204,7 +215,8 @@
self.text_as_default = text_as_default
self.encoding = encoding
self.prefix_error = prefix_error
-
+ self.force_defaults = force_defaults
+
def str_compare(self, str1, str2):
"""
Compare the two objects as strings (coercing to strings if necessary).
@@ -262,7 +274,7 @@
self._text = self._get_text()
def skip_output(self):
- return self.in_textarea or self.skip_error
+ return (self.in_textarea and self.skip_textarea) or self.skip_error
def add_key(self, key):
self.used_keys[key] = 1
@@ -362,7 +374,10 @@
self.skip_next = True
self.add_key(name)
elif t == 'checkbox':
- selected = False
+ if self.force_defaults:
+ selected = False
+ else:
+ selected = self.get_attr(attrs, 'checked')
if not self.get_attr(attrs, 'value'):
selected = value
elif self.selected_multiple(value,
@@ -378,7 +393,7 @@
elif t == 'radio':
if self.str_compare(value, self.get_attr(attrs, 'value', '')):
self.set_attr(attrs, 'checked', 'checked')
- else:
+ elif self.force_defaults or name in self.defaults:
self.del_attr(attrs, 'checked')
self.write_tag('input', attrs, startend)
self.skip_next = True
@@ -421,15 +436,21 @@
if (self.error_class
and self.errors.get(name)):
self.add_class(attrs, self.error_class)
- self.write_tag('textarea', attrs)
value = self.defaults.get(name, '')
- self.write_text(html_quote(value))
- self.write_text('</textarea>')
+ if value or self.force_defaults:
+ self.write_tag('textarea', attrs)
+ self.write_text(html_quote(value))
+ self.write_text('</textarea>')
+ self.skip_textarea = True
self.in_textarea = True
self.last_textarea_name = name
self.add_key(name)
def handle_end_textarea(self):
+ if self.skip_textarea:
+ self.skip_textarea = False
+ else:
+ self.write_text('</textarea>')
self.in_textarea = False
self.skip_next = True
if not self.prefix_error:
@@ -461,13 +482,13 @@
% self.getpos())
if self.in_select != False:
default = self.defaults.get(self.in_select, '')
-
- if self.selected_multiple(self.defaults.get(self.in_select, ''),
- self.get_attr(attrs, 'value', '')):
- self.set_attr(attrs, 'selected', 'selected')
- self.add_key(self.in_select)
- else:
- self.del_attr(attrs, 'selected')
+ if self.force_defaults:
+ if self.selected_multiple(self.defaults.get(self.in_select, ''),
+ self.get_attr(attrs, 'value', '')):
+ self.set_attr(attrs, 'selected', 'selected')
+ self.add_key(self.in_select)
+ else:
+ self.del_attr(attrs, 'selected')
self.write_tag('option', attrs)
self.skip_next = True
Modified: FormEncode/trunk/tests/test_htmlfill.py
===================================================================
--- FormEncode/trunk/tests/test_htmlfill.py 2009-02-06 13:56:26 UTC (rev 3783)
+++ FormEncode/trunk/tests/test_htmlfill.py 2009-02-11 19:16:15 UTC (rev 3784)
@@ -133,3 +133,132 @@
assert (htmlfill.render(u'<input type="checkbox" name="tags" value="2" />',
dict(tags=[])) ==
'<input type="checkbox" name="tags" value="2" />')
+
+def test_defaults_not_form_submission_textarea():
+ html = """<textarea name="textarea-1" class="my_textarea">i like this text</textarea>"""
+ rendered_html = htmlfill.render(html, defaults=dict(),
+ defaults_as_form_submission=False)
+ assert html == rendered_html, rendered_html
+
+def test_defaults_not_form_submission_textarea_value():
+ html = """<textarea name="textarea-1" class="my_textarea">i like this text</textarea>"""
+ expected_html = """<textarea name="textarea-1" class="my_textarea">this text is better</textarea>"""
+ rendered_html = htmlfill.render(html, defaults={"textarea-1": "this text is better"},
+ defaults_as_form_submission=False)
+ assert expected_html == rendered_html, rendered_html
+
+def test_defaults_as_form_submission_textarea():
+ html = """<textarea name="textarea-1" class="my_textarea">i like this text</textarea>"""
+ expected_html = \
+ """<textarea name="textarea-1" class="my_textarea"></textarea>"""
+ rendered_html = htmlfill.render(html, defaults=dict())
+ assert expected_html == rendered_html, rendered_html
+
+def test_defaults_not_form_submission_checkbox():
+ html = """<input type="checkbox" name="checkbox-1" class="my_checkbox" checked="checked" value="cb">"""
+ rendered_html = htmlfill.render(html, defaults=dict(),
+ defaults_as_form_submission=False)
+ assert html == rendered_html, rendered_html
+
+def test_defaults_as_form_submission_checkbox():
+ html = """<input type="checkbox" name="checkbox-1" class="my_checkbox" checked="checked" value="cb">"""
+ expected_html = \
+ """<input type="checkbox" name="checkbox-1" class="my_checkbox" value="cb">"""
+ rendered_html = htmlfill.render(html, defaults=dict())
+ assert expected_html == rendered_html, rendered_html
+
+def test_defaults_not_form_submission_checkbox_default_unchecked():
+ html = """<input type="checkbox" name="checkbox-1" class="my_checkbox" checked="checked" value="cb">"""
+ expected_html = \
+ """<input type="checkbox" name="checkbox-1" class="my_checkbox" value="cb">"""
+ rendered_html = htmlfill.render(html, defaults={"checkbox-1": False})
+ assert expected_html == rendered_html, rendered_html
+
+def test_defaults_not_form_submission_checkbox_default_checked():
+ html = """<input type="checkbox" name="checkbox-1" class="my_checkbox" value="cb">"""
+ expected_html = \
+ """<input type="checkbox" name="checkbox-1" class="my_checkbox" value="cb" checked="checked">"""
+ rendered_html = htmlfill.render(html, defaults={"checkbox-1": "cb"},
+ defaults_as_form_submission=False)
+ assert expected_html == rendered_html, rendered_html
+
+def test_defaults_not_form_submission_radio():
+ html = """<input type="radio" name="radio-1" class="my_radio" checked="checked" value="cb">"""
+ rendered_html = htmlfill.render(html, defaults=dict(),
+ defaults_as_form_submission=False)
+ assert html == rendered_html, rendered_html
+
+def test_defaults_not_form_submission_radio_unchecked():
+ html = """<input type="radio" name="radio-1" class="my_radio" checked="checked" value="cb">"""
+ expected_html = """<input type="radio" name="radio-1" class="my_radio" value="cb">"""
+ rendered_html = htmlfill.render(html, defaults={"radio-1": "ba"},
+ defaults_as_form_submission=False)
+ assert expected_html == rendered_html, rendered_html
+
+def test_defaults_not_form_submission_radio_checked():
+ html = """<input type="radio" name="radio-1" class="my_radio" value="cb">"""
+ expected_html = """<input type="radio" name="radio-1" class="my_radio" value="cb" checked="checked">"""
+ rendered_html = htmlfill.render(html, defaults={"radio-1": "cb"},
+ defaults_as_form_submission=False)
+ assert expected_html == rendered_html, rendered_html
+
+def test_defaults_as_form_submission_radio():
+ html = """<input type="radio" name="radio-1" class="my_radio" checked="checked" value="cb">"""
+ expected_html = """<input type="radio" name="radio-1" class="my_radio" value="cb">"""
+ rendered_html = htmlfill.render(html, defaults=dict())
+ assert expected_html == rendered_html, rendered_html
+
+def test_defaults_not_form_submission_select():
+ html = """
+<select name="select-1" class="my_select">
+ <option value="option-1" selected="selected">this is option-1</option>
+</select>
+"""
+ rendered_html = htmlfill.render(html, defaults=dict(),
+ defaults_as_form_submission=False)
+ assert html == rendered_html, rendered_html
+
+def test_defaults_not_form_submission_select_selected():
+ html = """
+<select name="select-1" class="my_select">
+ <option value="option-1">this is option-1</option>
+</select>
+"""
+ expected_html = """
+<select name="select-1" class="my_select">
+ <option value="option-1" selected="selected">this is option-1</option>
+</select>
+"""
+ rendered_html = htmlfill.render(html, defaults={"select-1": "option-1"},
+ defaults_as_form_submission=False)
+ assert html == rendered_html, rendered_html
+
+def test_defaults_not_form_submission_select_not_selected():
+ html = """
+<select name="select-1" class="my_select">
+ <option value="option-1" selected="selected">this is option-1</option>
+</select>
+"""
+ expected_html = """
+<select name="select-1" class="my_select">
+ <option value="option-1">this is option-1</option>
+</select>
+"""
+ rendered_html = htmlfill.render(html, defaults={"select-1": "option-2"},
+ defaults_as_form_submission=False)
+ assert html == rendered_html, rendered_html
+
+def test_defaults_as_form_submission_select():
+ html = """
+<select name="select-1" class="my_select">
+ <option value="option-1" selected="selected">this is option-1</option>
+</select>
+"""
+ expected_html = """
+<select name="select-1" class="my_select">
+ <option value="option-1">this is option-1</option>
+</select>
+"""
+ rendered_html = htmlfill.render(html, defaults=dict())
+ assert expected_html == rendered_html, rendered_html
+
|
|
From: <sub...@co...> - 2008-12-20 22:02:44
|
Author: ianb Date: 2008-12-20 15:02:40 -0700 (Sat, 20 Dec 2008) New Revision: 3749 Modified: FormEncode/trunk/setup.py Log: Auto-update of version strings Modified: FormEncode/trunk/setup.py =================================================================== --- FormEncode/trunk/setup.py 2008-12-20 22:02:31 UTC (rev 3748) +++ FormEncode/trunk/setup.py 2008-12-20 22:02:40 UTC (rev 3749) @@ -1,7 +1,7 @@ import sys from setuptools import setup -version = '1.2.1' +version = '1.2.2' tests_require = ['nose'] if sys.version < '2.5': |
|
From: <sub...@co...> - 2008-12-20 22:02:38
|
Author: ianb Date: 2008-12-20 15:02:31 -0700 (Sat, 20 Dec 2008) New Revision: 3748 Modified: FormEncode/tags/1.2.1/setup.cfg Log: Auto-update of version strings Modified: FormEncode/tags/1.2.1/setup.cfg =================================================================== --- FormEncode/tags/1.2.1/setup.cfg 2008-12-20 22:01:54 UTC (rev 3747) +++ FormEncode/tags/1.2.1/setup.cfg 2008-12-20 22:02:31 UTC (rev 3748) @@ -1,67 +1,62 @@ +[init_catalog] +domain = FormEncode +output_dir = formencode/i18n +input_file = formencode/i18n/FormEncode.pot + [global] command_packages = buildutils.pudge_command, buildutils.publish_command -[egg_info] -tag_build = dev -tag_svn_revision = true +[nosetests] +detailed-errors = 1 +[publish] +doc-dest = scp://ianbicking@shell.sf.net/home/groups/f/fo/formencode/htdocs/ +doc-dir = docs/html + +[update_catalog] +domain = FormEncode +previous = true +output_dir = formencode/i18n +input_file = formencode/i18n/FormEncode.pot + [pudge] -theme = pythonpaste.org -docs = docs/index.txt docs/Validator.txt docs/ToDo.txt - docs/news.txt docs/htmlfill.txt docs/Design.txt - docs/community.txt docs/download.txt - docs/history.txt docs/i18n.txt -doc_base = docs/ +organization = FormEncode +title = FormEncode dest = docs/html +docs = docs/index.txt docs/Validator.txt docs/ToDo.txt + docs/news.txt docs/htmlfill.txt docs/Design.txt + docs/community.txt docs/download.txt + docs/history.txt docs/i18n.txt +settings = normal_link_color=#083 + visited_color=#038 + hover_color=#dfd + body_outer_bg_color=#173 + body_border_color=#0f0 + nav_container_color=#7d9 + nav_button_color=#073 + nav_border_color=#0f5 + doctitle_color=#009900 + no_about=true + link1=/Validator.html Documentation modules = formencode -exclude_modules = formencode.fields formencode.formgen - formencode.sqlformgen formencode.sqlschema -title = FormEncode +doc_base = docs/ +theme = pythonpaste.org mailing_list_url = http://formencode.org/community.html -organization = FormEncode -settings = normal_link_color=#083 - visited_color=#038 - hover_color=#dfd - body_outer_bg_color=#173 - body_border_color=#0f0 - nav_container_color=#7d9 - nav_button_color=#073 - nav_border_color=#0f5 - doctitle_color=#009900 +exclude_modules = formencode.fields formencode.formgen + formencode.sqlformgen formencode.sqlschema - no_about=true - link1=/Validator.html Documentation - -[publish] -doc-dir = docs/html -doc-dest = scp://ianbicking@shell.sf.net/home/groups/f/fo/formencode/htdocs/ - -[aliases] -distribute = register sdist bdist_egg upload pudge publish - -[nosetests] -detailed-errors = 1 - -# Babel configuration [compile_catalog] -domain = FormEncode directory = formencode/i18n +domain = FormEncode statistics = true [extract_messages] -add_comments = TRANSLATORS: -output_file = formencode/i18n/FormEncode.pot charset = utf-8 -msgid_bugs_address = for...@li... +output_file = formencode/i18n/FormEncode.pot width = 80 +msgid_bugs_address = for...@li... +add_comments = TRANSLATORS: -[init_catalog] -domain = FormEncode -input_file = formencode/i18n/FormEncode.pot -output_dir = formencode/i18n +[aliases] +distribute = register sdist bdist_egg upload pudge publish -[update_catalog] -domain = FormEncode -input_file = formencode/i18n/FormEncode.pot -output_dir = formencode/i18n -previous = true |
|
From: <sub...@co...> - 2008-12-20 22:01:59
|
Author: ianb Date: 2008-12-20 15:01:54 -0700 (Sat, 20 Dec 2008) New Revision: 3747 Added: FormEncode/tags/1.2.1/ Log: Tagging 1.2.1 version Copied: FormEncode/tags/1.2.1 (from rev 3746, FormEncode/trunk) |
|
From: <sub...@co...> - 2008-12-20 22:01:25
|
Author: ianb Date: 2008-12-20 15:01:19 -0700 (Sat, 20 Dec 2008) New Revision: 3746 Modified: FormEncode/trunk/docs/conf.py FormEncode/trunk/docs/news.txt Log: update version for release Modified: FormEncode/trunk/docs/conf.py =================================================================== --- FormEncode/trunk/docs/conf.py 2008-12-20 01:02:12 UTC (rev 3745) +++ FormEncode/trunk/docs/conf.py 2008-12-20 22:01:19 UTC (rev 3746) @@ -40,9 +40,9 @@ # other places throughout the built documents. # # The short X.Y version. -version = '1.2' +version = '1.2.1' # The full version, including alpha/beta/rc tags. -release = '1.2' +release = '1.2.1' # There are two options for replacing |today|: either, you set today to some # non-false value, then it is used: Modified: FormEncode/trunk/docs/news.txt =================================================================== --- FormEncode/trunk/docs/news.txt 2008-12-20 01:02:12 UTC (rev 3745) +++ FormEncode/trunk/docs/news.txt 2008-12-20 22:01:19 UTC (rev 3746) @@ -3,8 +3,8 @@ .. contents:: -svn trunk ---------- +1.2.1 +----- * Be more careful about ``unicode(Invalid(...))``, to make sure it always returns unicode. |