You can subscribe to this list here.
| 2004 |
Jan
|
Feb
(1) |
Mar
(1) |
Apr
(1) |
May
(6) |
Jun
(1) |
Jul
(1) |
Aug
|
Sep
|
Oct
(8) |
Nov
(9) |
Dec
|
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2005 |
Jan
(1) |
Feb
|
Mar
(2) |
Apr
(13) |
May
(34) |
Jun
(7) |
Jul
(6) |
Aug
(1) |
Sep
(23) |
Oct
(37) |
Nov
(41) |
Dec
(39) |
| 2006 |
Jan
(19) |
Feb
(1) |
Mar
(5) |
Apr
(9) |
May
(3) |
Jun
(8) |
Jul
(6) |
Aug
(12) |
Sep
(15) |
Oct
(26) |
Nov
(7) |
Dec
(11) |
| 2007 |
Jan
(12) |
Feb
(6) |
Mar
(13) |
Apr
(14) |
May
(12) |
Jun
(8) |
Jul
(3) |
Aug
|
Sep
(4) |
Oct
(19) |
Nov
(9) |
Dec
|
| 2008 |
Jan
(14) |
Feb
(3) |
Mar
(11) |
Apr
(6) |
May
(18) |
Jun
(15) |
Jul
(1) |
Aug
(23) |
Sep
(18) |
Oct
(39) |
Nov
(11) |
Dec
(16) |
| 2009 |
Jan
(8) |
Feb
(9) |
Mar
(33) |
Apr
(16) |
May
(5) |
Jun
(3) |
Jul
(2) |
Aug
(2) |
Sep
(1) |
Oct
(6) |
Nov
(11) |
Dec
(2) |
| 2010 |
Jan
(2) |
Feb
(4) |
Mar
|
Apr
|
May
(2) |
Jun
(3) |
Jul
(2) |
Aug
|
Sep
(3) |
Oct
|
Nov
|
Dec
|
| 2011 |
Jan
(1) |
Feb
|
Mar
(4) |
Apr
|
May
|
Jun
|
Jul
(10) |
Aug
(36) |
Sep
(8) |
Oct
(1) |
Nov
|
Dec
(10) |
| 2012 |
Jan
(3) |
Feb
(5) |
Mar
(4) |
Apr
|
May
|
Jun
|
Jul
(15) |
Aug
|
Sep
(9) |
Oct
|
Nov
|
Dec
(1) |
| 2013 |
Jan
(3) |
Feb
(1) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(1) |
Dec
(10) |
| 2014 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(1) |
Sep
(1) |
Oct
|
Nov
|
Dec
(4) |
| 2015 |
Jan
|
Feb
(2) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(2) |
Oct
(1) |
Nov
(2) |
Dec
|
| 2018 |
Jan
(1) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2020 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(1) |
Sep
|
Oct
|
Nov
|
Dec
|
|
From: Ian B. <ia...@co...> - 2005-05-25 15:31:00
|
Applied in r803
Jason Culverhouse wrote:
> Ian,
> Here is a patch for htmlfill.py to properly propagate "startend" for all
> xhtml input tags. This was already being done for the the ('text',
> 'hidden', 'submit', 'reset', 'button') types but not the other types.
>
> Note also included is the change to default formatter that I posted
> earlier.
>
> Thanks,
> Jason
>
> Index: formencode/htmlfill.py
> ===================================================================
> --- formencode/htmlfill.py (revision 778)
> +++ formencode/htmlfill.py (working copy)
> @@ -2,7 +2,7 @@
> import cgi
>
> def default_formatter(error):
> - return '<span class="error-message">%s</span><br />\n' %
> cgi.escape(error)
> + return '<span class="error-message">%s</span>' % cgi.escape(error)
>
> def none_formatter(error):
> return error
> @@ -206,7 +206,7 @@
> self.set_attr(attrs, 'checked', 'checked')
> else:
> self.del_attr(attrs, 'checked')
> - self.write_tag('input', attrs)
> + self.write_tag('input', attrs, startend)
> self.skip_next = True
> self.add_key(name)
> elif t == 'radio':
> @@ -214,7 +214,7 @@
> self.set_attr(attrs, 'checked', 'checked')
> else:
> self.del_attr(attrs, 'checked')
> - self.write_tag('input', attrs)
> + self.write_tag('input', attrs, startend)
> self.skip_next = True
> self.add_key(name)
> elif t == 'file':
> @@ -222,7 +222,7 @@
> elif t == 'password':
> self.set_attr(attrs, 'value', value or
> self.get_attr(attrs, 'value', ''))
> - self.write_tag('input', attrs)
> + self.write_tag('input', attrs, startend)
> self.skip_next = True
> self.add_key(name)
> else:
|
|
From: Ian B. <ia...@co...> - 2005-05-25 15:24:56
|
Thanks; applied in r799
Justin Azoff wrote:
> As far as I can tell, this is needed to make checkboxes work sanely.
>
> class Bool(FancyValidator):
>
> """
> Always Valid, returns True or False based on the value
>
> Examples::
>
> >>> Bool.to_python(0)
> False
> >>> Bool.to_python(1)
> True
> >>> Bool.to_python('')
> False
> >>> Bool.to_python(None)
> False
> """
>
> if_missing = False
>
> def _to_python(self, value, state):
> return bool(value)
> _from_python = _to_python
|
|
From: Ian B. <ia...@co...> - 2005-05-25 15:23:27
|
Thanks, applied in r798
Jason Culverhouse wrote:
> The URL validator doesn't return a value from the to_python method when
> validation is successful.
> This patch also contains the patch that I proposed for the default
> phoneformat error message.
> Jason
>
> Index: formencode/validators.py
> ===================================================================
> --- formencode/validators.py (revision 796)
> +++ formencode/validators.py (working copy)
> @@ -918,6 +918,8 @@
> if self.check_exists and (value.startswith('http://')
> or value.startswith('https://')):
> self._check_url_exists(value, state)
> +
> + return value
>
> def _check_url_exists(self, url, state):
> global httplib, urlparse
> @@ -1012,7 +1014,7 @@
> _phoneRE = re.compile(r'^\s*(?:1-)?(\d\d\d)[\- \.]?(\d\d\d)[\-
> \.]?(\d\d\d\d)(?:\s*ext\.?\s*(\d+))?\s*$', re.I)
>
> messages = {
> - 'phoneFormat': 'Please enter a number, with area code, in the
> form ###-###-####, optionally with "ext.####"',
> + 'phoneFormat': 'Please enter a number, with area code, in the
> form ###-###-####, optionally with "ext.####"',
> }
>
> def _to_python(self, value, state):
|
|
From: Jason C. <ja...@me...> - 2005-05-23 22:08:18
|
The URL validator doesn't return a value from the to_python method when
validation is successful.
This patch also contains the patch that I proposed for the default
phoneformat error message.
Jason
Index: formencode/validators.py
===================================================================
--- formencode/validators.py (revision 796)
+++ formencode/validators.py (working copy)
@@ -918,6 +918,8 @@
if self.check_exists and (value.startswith('http://')
or value.startswith('https://')):
self._check_url_exists(value, state)
+
+ return value
def _check_url_exists(self, url, state):
global httplib, urlparse
@@ -1012,7 +1014,7 @@
_phoneRE = re.compile(r'^\s*(?:1-)?(\d\d\d)[\- \.]?(\d\d\d)[\-
\.]?(\d\d\d\d)(?:\s*ext\.?\s*(\d+))?\s*$', re.I)
messages = {
- 'phoneFormat': 'Please enter a number, with area code, in the
form ###-###-####, optionally with "ext.####"',
+ 'phoneFormat': 'Please enter a number, with area code, in the
form ###-###-####, optionally with "ext.####"',
}
def _to_python(self, value, state):
|
|
From: michelts <mic...@gm...> - 2005-05-20 16:52:56
|
Hi guys, What is the proper way to use from_python and the filling parser (from htmlfill)? I have a validator that validates a list of ints and convert it to a list of sqlobject classes (a mutiple join), the from_python attribute converts the multiple join to a list of integers as string (I try manually and this list makes the itens selected on the form). Does the filling parser make use of the from_python method? thanks --=20 Michel Thadeu Sabchuk Curitiba - Brasil |
|
From: Ben B. <be...@gr...> - 2005-05-19 19:56:50
|
I'm having some problems with formencode operating on a multi-part form
returned by a CGI, vs that returned by mod_python. In mod_python, the dict
in a multi-part form that contains a File upload looks like this:
{'city': 'Petaluma', 'photograph': Field('photograph', ''), 'firstName':
'Ben', 'title': 'stuff', 'middleName': '', 'lastName': 'Bangert',
'enableCache': 'True', 'philosophy': '', 'state': 'CA', 'token': 'habba',
'specialties': '', 'expertise': '', 'submitButton': 'Submit', 'education':
'', 'company': '', 'email': 'be...@gr...', 'biography': ''}
(The photograph field is the file upload)
This works just fine with the form schema, however when switching over to
using Fast CGI (thus the form is parsed with the cgi module), the same
request dict looks like this:
{'city': FieldStorage('city', None, 'Petaluma'), 'photograph':
FieldStorage('photograph', '', ''), 'firstName': FieldStorage('firstName',
None, 'Ben'), 'title': FieldStorage('title', None, ''), 'middleName':
FieldStorage('middleName', None, ''), 'lastName': FieldStorage('lastName',
None, 'Bangert'), 'enableCache': FieldStorage('enableCache', None, 'True'),
'philosophy': FieldStorage('philosophy', None, ''), 'token':
FieldStorage('token', None, 'habba'), 'email': FieldStorage('email', None,
'be...@gr...'), 'state': FieldStorage('state', None, 'CA'),
'specialties': FieldStorage('specialties', None, ''), 'expertise':
FieldStorage('expertise', None, ''), 'submitButton':
FieldStorage('submitButton', None, 'Submit'), 'education':
FieldStorage('education', None, ''), 'company': FieldStorage('company',
None, ''), 'biography': FieldStorage('biography', None, '')}
The error this generates during validation is:
Error:
Error: not indexable
File:
/usr/local/lib/python2.3/cgi.py line 594
Context:
591: def keys(self):
592: """Dictionary style keys() method."""
593: if self.list is None:
594: raise TypeError, "not indexable"
595: keys = []
596: for item in self.list:
597: if item.name not in keys: keys.append(item.name)
Traceback:
/usr/local/lib/python2.3/cgi.py:594
/usr/local/lib/python2.3/cgi.py:618
/usr/local/lib/python2.3/site-packages/formencode/api.py:198
/usr/local/lib/python2.3/site-packages/formencode/api.py:223
/usr/local/lib/python2.3/site-packages/formencode/schema.py:118
/usr/local/lib/python2.3/site-packages/formencode/api.py:207
/usr/local/lib/python2.3/site-packages/formencode/api.py:223
/usr/local/lib/python2.3/site-packages/formencode/htmlform.py:67
This is caused during the form.validate(request_args) call.
Is anyone else using formencode with multi-part forms and the CGI module? Is
there some quick way to fix this, or is a patch to formencode required to
test the dict values for FieldStorage instances?
I've noticed the dict is flat with the CGI module if its not a multi-part
encoded form, its only the multi-part bit which seems to dump the values
into FieldStorage instances.
Thanks,
Ben
|
|
From: Ian B. <ia...@co...> - 2005-05-19 15:23:46
|
Thomas Weholt wrote:
> On the sqlobject-homepage you're mentioning "Increase hooks with
> FormEncode (unreleased) validation and form generation package, so
> SQLObject classes (read: schemas) can be published for editing more
> directly and easily. " in your plans for sqlobject 0.6. Do you have any
> example code, no matter how unfinished it may be, I could look at? I'm
> doing sort of the same right now, generating html-forms, but I'm basing
> those forms directly on SQLObject-classes. I've read something on the
> formencode page that this wasn't your way of doing it, but if you could
> give me some pointers on what you're doing to link formencode and
> sqlobject together I could decide to go on or stop my current project (
> the form-generation thing that is ).
I haven't really had any time to dedicate to SQLObject lately, and only
a little to FormEncode. Ultimately I want to be able to add arbitrary
attributes to SQLObject columns, which would be most of the hooks
SQLObject would need. But of course you can get *almost* the same thing
right now with a naming convention:
class Address(SQLObject):
street = StringCol()
street_validator = NotEmpty()
street_widget = TextInput(width='100%')
postalCode = StringCol()
postalCode_validator = PostalCode(notEmpty=True)
postalCode_widget = TextInput(width='5em')
And so on. The *Input fields are mostly up to you -- formencode.formgen
is a start, but is missing some important things.
Then another piece of code separate from your class can go through
Address._SO_columnDict, read the column names, and pull out the
validators and widgets.
> Keep up the good work!! :-) SQLObject rocks !! I'm porting my an old
> project from twisted + custom code to SQLObject/CherryPy/CheetahTemplate
> and it looks like I'm able to cut 70-80% of the old code and most of
> this is because SQLObject and CherryPy makes everything so easy. Thanks !
I'm glad they've worked well for you!
--
Ian Bicking / ia...@co... / http://blog.ianbicking.org
|
|
From: Justin A. <JA...@ua...> - 2005-05-19 14:30:28
|
As far as I can tell, this is needed to make checkboxes work sanely.
class Bool(FancyValidator):
"""
Always Valid, returns True or False based on the value
Examples::
>>> Bool.to_python(0)
False
>>> Bool.to_python(1)
True
>>> Bool.to_python('')
False
>>> Bool.to_python(None)
False
"""
if_missing = False
def _to_python(self, value, state):
return bool(value)
_from_python = _to_python
CC replies :-)
--
-- Justin Azoff
-- Network Performance Analyst
|
|
From: Ben B. <be...@gr...> - 2005-05-18 22:55:06
|
On 5/18/05 2:07 PM, "Ian Bicking" <ia...@co...> wrote:
> That would be fine. I don't know why it's not working for you, but if
> you want to twiddle with it and include that too, that'd be good. I
> haven't really used htmlform, I just put it in as a thought experiment,
> so it doesn't have any tests or whatnot.
I found out why it wasn't working.... When I had switched to using the svn,
I didn't switch my import statement to use formencode rather than validator.
So I was still using the old formencode package. Once I switched, errors did
return the unpacked errors properly.
I noticed there's one minor bug(?) in the svn, as well as a pretty major one
in htmlform that you might not have noticed if your site-packages/validator/
directory is still hanging around.
Here's the patch for htmlform.py that fixes it (I also included the patch to
the render method):
Index: formencode/htmlform.py
===================================================================
--- formencode/htmlform.py (revision 792)
+++ formencode/htmlform.py (working copy)
@@ -25,7 +25,7 @@
import htmlfill
import htmlfill_schemabuilder
-from validator import Invalid
+from api import Invalid
class HTMLForm(object):
@@ -53,10 +53,10 @@
p.close()
return listener.schema()
- def render(self, defaults={}, errors={}):
+ def render(self, defaults={}, errors={}, use_all_keys=False):
p = htmlfill.FillingParser(
defaults=defaults, errors=errors,
- use_all_keys=True)
+ use_all_keys=use_all_keys)
p.feed(self.form)
p.close()
return p.text()
And here's a patch to htmlfill which skips image input types (typically used
as submit buttons):
Index: formencode/htmlfill.py
===================================================================
--- formencode/htmlfill.py (revision 792)
+++ formencode/htmlfill.py (working copy)
@@ -225,6 +225,8 @@
self.write_tag('input', attrs)
self.skip_next = True
self.add_key(name)
+ elif t == 'image':
+ pass
else:
assert 0, "I don't know about this kind of <input>: %s (pos:
%s)" \
% (t, self.getpos())
Thanks,
Ben
|
|
From: Ian B. <ia...@co...> - 2005-05-18 21:08:21
|
Ben Bangert wrote: > On 5/18/05 1:48 PM, "Ian Bicking" <ia...@co...> wrote: > > >>Revision 792? >> >> def validate(self, request_dict, state=None): >> schema = self.schema >> try: >> result = schema.to_python(request_dict, state=state) >> return result, None >> except Invalid, e: >> return None, e.unpack_errors() > > > Yep, am now using 792. Still seems to be returning a dictionary of the > Invalid instances. > > On a side-note, I would recommend either changing htmlform's render function > to allow an argument to tweak the use_all_keys, or defaulting it to false > like how FillingParser defaults to False for that. That's actually the only > reason I'm calling FillingParser directly rather than using render as in the > doc examples. > > I'd be happy to submit a patch for this if that's the preferred way to make > a suggestion. That would be fine. I don't know why it's not working for you, but if you want to twiddle with it and include that too, that'd be good. I haven't really used htmlform, I just put it in as a thought experiment, so it doesn't have any tests or whatnot. -- Ian Bicking / ia...@co... / http://blog.ianbicking.org |
|
From: Ben B. <be...@gr...> - 2005-05-18 21:03:57
|
On 5/18/05 1:48 PM, "Ian Bicking" <ia...@co...> wrote: > Revision 792? > > def validate(self, request_dict, state=None): > schema = self.schema > try: > result = schema.to_python(request_dict, state=state) > return result, None > except Invalid, e: > return None, e.unpack_errors() Yep, am now using 792. Still seems to be returning a dictionary of the Invalid instances. On a side-note, I would recommend either changing htmlform's render function to allow an argument to tweak the use_all_keys, or defaulting it to false like how FillingParser defaults to False for that. That's actually the only reason I'm calling FillingParser directly rather than using render as in the doc examples. I'd be happy to submit a patch for this if that's the preferred way to make a suggestion. Thanks, Ben |
|
From: Ian B. <ia...@co...> - 2005-05-18 20:48:53
|
Ben Bangert wrote:
> On 5/18/05 1:32 PM, "Ian Bicking" <ia...@co...> wrote:
>
>
>>Ben Bangert wrote:
>>
>>>I currently check for errors on the form like this:
>>> form = htmlform.HTMLForm(html,formschemas.BillShipPage())
>>> errors = {}
>>> form_result, errors = form.validate(self.ARGS)
>>>
>>>I then pass the errors that returns into the htmlfill. Html in the above is
>>>a form snippet. What is the recommended way to obtain the errors dict passed
>>>into htmlfill?
>>
>>I was returning the wrong thing in htmlform -- should be fixed in svn now.
>
>
> I just ran svn up and saw the htmlform update, however it doesn't seem to
> have changed it. Should I be using something other than form.validate to
> pull that flat dict of error strings out?
>
> In the meantime this did get my form running:
> newerrors = {}
> for key, val in errors.iteritems():
> newerrors[key] = val.unpack_errors()
> parser = htmlfill.FillingParser(defaults = self.ARGS, errors =
> newerrors)
Revision 792?
def validate(self, request_dict, state=None):
schema = self.schema
try:
result = schema.to_python(request_dict, state=state)
return result, None
except Invalid, e:
return None, e.unpack_errors()
--
Ian Bicking / ia...@co... / http://blog.ianbicking.org
|
|
From: Ben B. <be...@gr...> - 2005-05-18 20:43:04
|
On 5/18/05 1:32 PM, "Ian Bicking" <ia...@co...> wrote:
> Ben Bangert wrote:
>> I currently check for errors on the form like this:
>> form = htmlform.HTMLForm(html,formschemas.BillShipPage())
>> errors = {}
>> form_result, errors = form.validate(self.ARGS)
>>
>> I then pass the errors that returns into the htmlfill. Html in the above is
>> a form snippet. What is the recommended way to obtain the errors dict passed
>> into htmlfill?
>
> I was returning the wrong thing in htmlform -- should be fixed in svn now.
I just ran svn up and saw the htmlform update, however it doesn't seem to
have changed it. Should I be using something other than form.validate to
pull that flat dict of error strings out?
In the meantime this did get my form running:
newerrors = {}
for key, val in errors.iteritems():
newerrors[key] = val.unpack_errors()
parser = htmlfill.FillingParser(defaults = self.ARGS, errors =
newerrors)
- Ben
|
|
From: Ian B. <ia...@co...> - 2005-05-18 20:33:52
|
Ben Bangert wrote:
> I currently check for errors on the form like this:
> form = htmlform.HTMLForm(html,formschemas.BillShipPage())
> errors = {}
> form_result, errors = form.validate(self.ARGS)
>
> I then pass the errors that returns into the htmlfill. Html in the above is
> a form snippet. What is the recommended way to obtain the errors dict passed
> into htmlfill?
I was returning the wrong thing in htmlform -- should be fixed in svn now.
--
Ian Bicking / ia...@co... / http://blog.ianbicking.org
|
|
From: Ben B. <be...@gr...> - 2005-05-18 20:23:34
|
On 5/18/05 1:16 PM, "Ian Bicking" <ia...@co...> wrote:
> Well, I'm not really sure what's happening, except that the default
> formatter is trying to take an Invalid instance and format it as HTML;
> the errors that are passed into htmlfill should be a flat dictionary of
> strings. The .unpack_errors() method on Invalid instances will give you
> that dictionary (though it might not be flat -- you might have to run it
> through variabledecode.variable_decode first if you are using compound
> forms).
>
> The code that matters in this case is whatever is invoking htmlfill.
Ah ha. Here's what the errors dict looks like that I pass into htmlfill:
'city': <validator.api.Invalid instance at 0x98ba82c>, 'address1':
<validator.api.Invalid instance at 0x98ba80c>, 'telephone':
<validator.api.Invalid instance at 0x98ba90c>, 'zipcode':
<validator.api.Invalid instance at 0x98ba40c>, 'lname':
<validator.api.Invalid instance at 0x98ba4ec>, 'state':
<validator.api.Invalid instance at 0x98ba56c>, 'fname':
<validator.api.Invalid instance at 0x98baf6c>, 'country':
<validator.api.Invalid instance at 0x98ba72c>, 'login':
<validator.api.Invalid instance at 0x98bae4c>, 'password':
<validator.api.Invalid instance at 0x98baa8c>, 'email':
<validator.api.Invalid instance at 0x98ba62c>}
I had assumed that I could pass that in since that's what htmlform.HTMLForm
had returned to me. I'm a little confused now how I should be setting up the
form.
I currently check for errors on the form like this:
form = htmlform.HTMLForm(html,formschemas.BillShipPage())
errors = {}
form_result, errors = form.validate(self.ARGS)
I then pass the errors that returns into the htmlfill. Html in the above is
a form snippet. What is the recommended way to obtain the errors dict passed
into htmlfill?
Thanks,
Ben
|
|
From: Ian B. <ia...@co...> - 2005-05-18 20:17:29
|
Ben Bangert wrote: > On 5/18/05 1:03 PM, "Ian Bicking" <ia...@co...> wrote: > > >>Ben Bangert wrote: >> >>>I've been trying to use htmlfill with the default errors, but have been >>>unable to get it to work. It works fine when I use the <form:iferror >>>name="..."></form:iferror> and turn off the formatters. >>> >>>However, when I use: >>><form:error name="..."> >>> >>>I get the following error: >>>Error: >>>Error: Invalid instance has no attribute 'replace' >> >>I suspect you have to use exc.unpack_errors() to get the strings out of >>the exception. > > > I'm not sure what you mean. When I use the form:iferror and completely turn > off the default_formatters in the FillingParser, it works fine. When I do > what I mentioned, the FillingParser dies with the message I listed. > > Am I using the <form:error> bit incorrectly, or if you need more information > to help how can I get that? Well, I'm not really sure what's happening, except that the default formatter is trying to take an Invalid instance and format it as HTML; the errors that are passed into htmlfill should be a flat dictionary of strings. The .unpack_errors() method on Invalid instances will give you that dictionary (though it might not be flat -- you might have to run it through variabledecode.variable_decode first if you are using compound forms). The code that matters in this case is whatever is invoking htmlfill. -- Ian Bicking / ia...@co... / http://blog.ianbicking.org |
|
From: Ben B. <be...@gr...> - 2005-05-18 20:10:13
|
On 5/18/05 1:03 PM, "Ian Bicking" <ia...@co...> wrote: > Ben Bangert wrote: >> I've been trying to use htmlfill with the default errors, but have been >> unable to get it to work. It works fine when I use the <form:iferror >> name="..."></form:iferror> and turn off the formatters. >> >> However, when I use: >> <form:error name="..."> >> >> I get the following error: >> Error: >> Error: Invalid instance has no attribute 'replace' > > I suspect you have to use exc.unpack_errors() to get the strings out of > the exception. I'm not sure what you mean. When I use the form:iferror and completely turn off the default_formatters in the FillingParser, it works fine. When I do what I mentioned, the FillingParser dies with the message I listed. Am I using the <form:error> bit incorrectly, or if you need more information to help how can I get that? Thanks, Ben |
|
From: Ian B. <ia...@co...> - 2005-05-18 20:04:50
|
Ben Bangert wrote: > I've been trying to use htmlfill with the default errors, but have been > unable to get it to work. It works fine when I use the <form:iferror > name="..."></form:iferror> and turn off the formatters. > > However, when I use: > <form:error name="..."> > > I get the following error: > Error: > Error: Invalid instance has no attribute 'replace' I suspect you have to use exc.unpack_errors() to get the strings out of the exception. -- Ian Bicking / ia...@co... / http://blog.ianbicking.org |
|
From: Ben B. <be...@gr...> - 2005-05-18 19:55:53
|
I've been trying to use htmlfill with the default errors, but have been
unable to get it to work. It works fine when I use the <form:iferror
name="..."></form:iferror> and turn off the formatters.
However, when I use:
<form:error name="...">
I get the following error:
Error:
Error: Invalid instance has no attribute 'replace'
File:
/usr/local/lib/python2.3/cgi.py line 1033
Context:
1030:
1031: def escape(s, quote=None):
1032: """Replace special characters '&', '<' and '>' by SGML entities."""
1033: s = s.replace("&", "&") # Must be done first!
1034: s = s.replace("<", "<")
1035: s = s.replace(">", ">")
1036: if quote:
Traceback:
/usr/local/lib/python2.3/cgi.py:1033
/usr/local/lib/python2.3/site-packages/validator/htmlfill.py:5
/usr/local/lib/python2.3/site-packages/validator/htmlfill.py:173
/usr/local/lib/python2.3/site-packages/validator/htmlfill.py:118
/usr/local/lib/python2.3/HTMLParser.py:281
/usr/local/lib/python2.3/HTMLParser.py:148
/usr/local/lib/python2.3/HTMLParser.py:108
/usr/local/lib/python2.3/site-packages/validator/htmlfill.py:79
Here's a snippet from my form:
<td><fieldset class="inputfields">
<p>
<label for="login">Choose your Login *</label>
<input name="login" type="text" id="login" title="Login" />
<form:error name="login">
</p>
<p>
Is that the proper usage?
Thanks,
Ben
|
|
From: Jason C. <ja...@me...> - 2005-05-10 18:09:30
|
Ian,
Here is a patch for htmlfill.py to properly propagate "startend" for all
xhtml input tags. This was already being done for the the ('text',
'hidden', 'submit', 'reset', 'button') types but not the other types.
Note also included is the change to default formatter that I posted earlier.
Thanks,
Jason
Index: formencode/htmlfill.py
===================================================================
--- formencode/htmlfill.py (revision 778)
+++ formencode/htmlfill.py (working copy)
@@ -2,7 +2,7 @@
import cgi
def default_formatter(error):
- return '<span class="error-message">%s</span><br />\n' %
cgi.escape(error)
+ return '<span class="error-message">%s</span>' % cgi.escape(error)
def none_formatter(error):
return error
@@ -206,7 +206,7 @@
self.set_attr(attrs, 'checked', 'checked')
else:
self.del_attr(attrs, 'checked')
- self.write_tag('input', attrs)
+ self.write_tag('input', attrs, startend)
self.skip_next = True
self.add_key(name)
elif t == 'radio':
@@ -214,7 +214,7 @@
self.set_attr(attrs, 'checked', 'checked')
else:
self.del_attr(attrs, 'checked')
- self.write_tag('input', attrs)
+ self.write_tag('input', attrs, startend)
self.skip_next = True
self.add_key(name)
elif t == 'file':
@@ -222,7 +222,7 @@
elif t == 'password':
self.set_attr(attrs, 'value', value or
self.get_attr(attrs, 'value', ''))
- self.write_tag('input', attrs)
+ self.write_tag('input', attrs, startend)
self.skip_next = True
self.add_key(name)
else:
|
|
From: Jason C. <ja...@me...> - 2005-05-06 19:12:28
|
Ian,
In validators.PhoneNumber the error message is entity encoded ( "
). This causes it to be the only error message that doesn't work
correctly with the default_formatter. I think that you should "unescape"
the error message.
Also, any reason why the default_formatter shouldn't just be:
def default_formatter(error):
return '<span class="error-message">%s</span>' % cgi.escape(error, 1)
where you always just "" the quotes" and drop the <br/> ?
Thanks,
Jason
-- patch --
Index: formencode/validators.py
===================================================================
--- formencode/validators.py (revision 776)
+++ formencode/validators.py (working copy)
@@ -1012,7 +1012,7 @@
_phoneRE = re.compile(r'^\s*(?:1-)?(\d\d\d)[\- \.]?(\d\d\d)[\-
\.]?(\d\d\d\d)(?:\s*ext\.?\s*(\d+))?\s*$', re.I)
messages = {
- 'phoneFormat': 'Please enter a number, with area code, in the
form ###-###-####, optionally with "ext.####"',
+ 'phoneFormat': 'Please enter a number, with area code, in the
form ###-###-####, optionally with <q>ext.####</q>',
}
def _to_python(self, value, state):
Index: formencode/htmlfill.py
===================================================================
--- formencode/htmlfill.py (revision 776)
+++ formencode/htmlfill.py (working copy)
@@ -2,7 +2,7 @@
import cgi
def default_formatter(error):
- return '<span class="error-message">%s</span><br />\n' %
cgi.escape(error)
+ return '<span class="error-message">%s</span>' % cgi.escape(error)
def none_formatter(error):
return error
|
|
From: Ian B. <ia...@co...> - 2005-05-04 02:50:32
|
Thanks; applied in r764 Jason Culverhouse wrote: > Ian, > Attached is a patch for the latest svn copy of formencode to make the > chained validators and patial Schema validation work. > Jason > |
|
From: Jason C. <ja...@me...> - 2005-05-04 00:44:23
|
Ian,
Attached is a patch for the latest svn copy of formencode to make the
chained validators and patial Schema validation work.
Jason
Patch for Index: formencode/schema.py
===================================================================
--- formencode/schema.py (revision 763)
+++ formencode/schema.py (working copy)
@@ -139,7 +139,7 @@
error_dict=errors)
for validator in self.chained_validators:
- new = to_python(validator, new, state)
+ new = validator.to_python(new, state)
return new
@@ -155,7 +155,7 @@
for validator in chained:
__traceback_info__ = 'for_python chained_validator %s
(finished %s)' % (validator, ', '.join(map(repr, finished)) or 'none')
finished.append(validator)
- value_dict = from_python(validator, value_dict, state)
+ value_dict = validator.from_python(value_dict, state)
new = {}
errors = {}
unused = self.fields.keys()
Index: formencode/validators.py
===================================================================
--- formencode/validators.py (revision 763)
+++ formencode/validators.py (working copy)
@@ -1459,7 +1459,7 @@
def validate_partial(self, field_dict, state):
for name in self.field_names:
- if not dict.has_key(name):
+ if not field_dict.has_key(name):
return
self.validate_python(field_dict, state)
|
|
From: Ian B. <ia...@co...> - 2005-05-03 02:31:33
|
I'm realizing there's really not that much work that needs to be done for a release, so I'm going to get ready to do that. Any feedback on what should go into that? I still have a few things I have to look at -- Michel's FEComponent, and Scott's XHTML patches to htmlfill. And actually, as I think about it, maybe FEComponent should go on svn.w4py.org alongside the other Webware components? I'm also considering leaving some stuff out of the release. Specifically formgen, interfaces.py, and htmlgen. And maybe htmlform. I don't plan to document them or make them "complete" anyway, so they are probably only distracting. I kind of like the idea of making a release selective anyway. This might frustrate people as form generation seems natural and important, but is missing from FormEncode. OTOH, I'm also happy to include anybody else's form generator if it's straight-forward and stable. Or refer to it in the docs if it is distributed separately. Documentation-wise I plan to fill out Design.txt, a ToDo.txt that outlines the steps to 1.0 (which I hope to get to quickly; it'd be my first project ever to reach 1.0 ;), and... well, I guess that's about it. Can anybody think of anything else? -- Ian Bicking / ia...@co... / http://blog.ianbicking.org |
|
From: Luke O. <lu...@me...> - 2005-04-29 03:44:57
|
Quoting Ian Bicking <ia...@co...>:
> No, because it gets confusing. How do you repeat fields? There's lots
> of options, tables, <br>, etc. To do it generally you need a templating
> language, and htmlfill isn't a templating language.
>
> The idea is for you to generate the HTML yourself using your templating
> language of choice (or Python), and then hand the generated output to
> htmlfill. formgen is the beginning of a Python-based generator, but
> it's quite incomplete (at least for using with htmlfill and other
> stuff). I think it's reasonable to write custom code for your form
> generation as well, it's all very tied to aesthetics.
I was going to make a post to the subway list, but I'll ask here first:
what is
the state of form generation in FE/Subway? I didn't really feel comfortable
with the htmlview mix with validator, but are you considering any approach for
bringing the generation portions of FFK to FE? The full form layout stuff was
never very useful (as you know :), but from a templating perspective I like
having an object/dict of fields (and compound/repeating fields) and just
writing form.fieldName to output an input field or a select field or a complex
custom widget. Following on FFK's partial abilities:
form.firstName # possibly combining error & html ?
form.firstName.error
form.firstName.html
form.firstName.description) # never really used this
for entry in form.phoneNumbers.repeats:
# maybe just form.phoneNumbers, and .repeats to determine if it is
repeating
entry # or entry.error, entry.html, etc
form.aCompound.aSubField
form.aCompound.anotherField
for row in form.aCompoundRepeater.repeats:
row.aSubField
row.anotherField
All within the templating language of choice, but handling the repetitive html
of input tags etc. Options for rendering these fields is another sticky matter
- I extended FFK's options for compound repeating fields, where we might have
rows of data but on one row a field would be static, on another one we might
have additional buttons unhidden depending on the state of the data in each
row. I really don't like having that sort of decision occuring in the
template, in my mind it should be determined when we are building the data
structure to be populated. From FFK, defaults are fed to htmlfill, options are
fed to formgen, but ops/defaults are probably created in tandem in the
controller. Then, following your post on form library architecture, htmlfill
populates the output of formgen and the combination is served to the user.
Of course, without htmlview the form schema becomes a 1-to-1 correlate to the
validator schema, and in my usual case of forms reflecting a (partial)
SQLObject, that's three different objects referring to the same set of field
names. But I can live with that barring some way of decoupling these three
areas but inferring from one another - I had hoped adaptation would facilitate
these transformations, something like nevow's IRenderer concept but providing
a way to define custom introspectible structures like outlined above. But it
also seemed unwieldy, so I'm open to an alternate approach.
I'm willing and able to put a decent amount of time towards creating/expanding
this library, just wondering what current status and thoughts are.
- Luke
|