Hello,
I have a weird problem with turbogears and formencode. I have the
following code:
class Tracker:
@expose(template="wotomae.templates.tracker_about",
format="xhtml-strict")
@validate(validators={'tracker': checks.CheckTrackerExists()})
def default(self, tracker=None, action=None, tg_errors=None,
group='status', **kw):
# Actions on the selected tracker
if action and hasattr(self, action):
if action == 'members' or is_admin(tracker.shortName):
return getattr(self, action)(tracker, **kw)
[...]
@expose(template="wotomae.templates.tracker_mass_bug",
format="xhtml-strict")
def mass_bug(self, tracker, **kw):
if not kw:
return dict(tracker=tracker,
shortName=tracker.shortName)
[...]
return serveFile(filename, "application/x-download",
"attachment")
And the corresponding template:
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:py="http://purl.org/kid/ns#"
py:extends="'master.kid'">
[...]
<body>
<form action="/tracker/${tracker.shortName}/mass_bug" method="post"
py:if="packages">
<span py:for="package in packages">
<input type="checkbox" checked="checked" name="${package.info.name}" />
${package.info.name}<br />
</span>
<br />
<input type="submit" value="Generate the package list" />
</form>
</body>
</html>
The name attribut of the input tag can be something for instance:
gnome-menus or gnome. However, when the name is equal to something with
a dash, it doesn't work at all :
2006-08-16 04:09:21,961 cherrypy.msg INFO HTTP: Traceback (most recent
call last):
File "/var/lib/python-support/python2.4/cherrypy/_cphttptools.py", line 103,
in _run
applyFilters('before_main')
File "/var/lib/python-support/python2.4/cherrypy/filters/__init__.py", line
151, in applyFilters
method()
File "/var/lib/python-support/python2.4/turbogears/startup.py", line 137, in
before_main
cherrypy.request.params = \
File "/usr/lib/python2.4/site-packages/formencode/api.py", line 316, in
to_python
value = tp(value, state)
File "/usr/lib/python2.4/site-packages/formencode/variabledecode.py", line
141, in _to_python
return variable_decode(value)
File "/usr/lib/python2.4/site-packages/formencode/variabledecode.py", line
49, in variable_decode
new_keys.append(int(index))
ValueError: invalid literal for int(): gnome
Request Headers:
REFERER: http://localhost:8080/tracker/python23/mass_bug
Content-Length: 3629
ACCEPT-CHARSET: ISO-8859-1,utf-8;q=0.7,*;q=0.7
USER-AGENT: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.0.6)
Gecko/20060728 Firefox/1.5.0.6 (Debian-1.5.dfsg+1.5.0.6-1)
CONNECTION: keep-alive
COOKIE: session_id=d1b537d7a890c402cac5669ee60a0fa38a8f5cf5
CONTENT-LENGTH: 3629
HOST: localhost:8080
CONTENT-TYPE: application/x-www-form-urlencoded
ACCEPT:
text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
Remote-Addr: 192.168.0.41
ACCEPT-LANGUAGE: fr-fr,en-us;q=0.7,en;q=0.3
Content-Type: application/x-www-form-urlencoded
Remote-Host: 192.168.0.41
ACCEPT-ENCODING: gzip,deflate
KEEP-ALIVE: 300
192.168.0.41 - - "POST /tracker/python23/mass_bug HTTP/1.1" 500 1600
"http://localhost:8080/tracker/python23/mass_bug" "Mozilla/5.0 (X11; U;
Linux i686; en-US; rv:1.8.0.6) Gecko/20060728 Firefox/1.5.0.6
(Debian-1.5.dfsg+1.5.0.6-1)"
I wonder why the variable_decode function is called. By modifying the
third parameter of variable_decode to anything else than a dash, it
works obviously perfectly. Any idea for making a dash working?
Regards,
Arnaud Fontaine
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"TurboGears" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/turbogears
-~----------~----~----~----~------~----~------~--~---