Ok I wrote this function and I just called it at the end of
processBody() in _cphttptools.py, it supports infinite
depth, I can now
have:
<form action="save"
method="post">
<input type="data[1][name]"
value="sergio">
<input type="data[1][email]"
value="my email.com">
</form>
...
def save(self, data):
return data
it will return the string representation of the dictionary
"data"
{'1': {'name': 'sergio', 'email': 'my emai.com'}}
This is the method, I've already done some basic tests:
def update_params(self):
for paramkey in self.params.keys():
try:
openbrace = paramkey.index('[')
except Exception,e:
return
key = paramkey[0:openbrace]
if not self.params.has_key(key):
self.params[key] = {}
current = self.params[key]
while True:
closebrace = paramkey.index(']',
openbrace)
key = paramkey[openbrace+1:closebrace]
try:
openbrace = paramkey.index('[',
closebrace)
except Exception,e:
current[key] = self.params[paramkey]
del self.params[paramkey]
break
if not current.has_key(key):
current[key] = {}
current = current[key]
X-Google-Language: ENGLISH,ASCII-7-bit
Received: by 10.11.53.63 with SMTP id b63mr104829cwa;
Sun, 21 May 2006 10:38:46 -0700 (PDT)
X-Google-Token: iUsTSAwAAAD-zXV7gKUUKGOn8e_-NozF
Received: from 201.114.40.175 by
j33g2000cwa.googlegroups.com with HTTP;
Sun, 21 May 2006 17:38:45 +0000 (UTC)
From: "Sheco" <sergioduran gmail.com>
To: "cherrypy-users" <cherrypy-users googlegroups.com>
Subject: Re: Parsing Request.params
Date: Sun, 21 May 2006 17:38:45 -0000
Message-ID: <1148233125.997170.306340 j33g2000cwa.googlegroups.com>
In-Reply-To: <1148199700.518937.151230 j33g2000cwa.googlegroups.com>
References: <1148199700.518937.151230 j33g2000cwa.googlegroups.com>
User-Agent: G2/0.2
X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1;
en-US; rv:1.8.0.2) Gecko/20060308
Firefox/1.5.0.2,gzip(gfe),gzip(gfe)
Mime-Version: 1.0
Content-Type: text/plain
Ok I wrote this function and I just called it at the end of
processBody() in _cphttptools.py, it supports infinite
depth, I can now
have:
<form action="save"
method="post">
<input type="data[1][name]"
value="sergio">
<input type="data[1][email]"
value="my email.com">
</form>
...
def save(self, data):
return data
it will return the string representation of the dictionary
"data"
{'1': {'name': 'sergio', 'email': 'my emai.com'}}
This is the method, I've already done some basic tests:
def update_params(self):
for paramkey in self.params.keys():
try:
openbrace = paramkey.index('[')
except Exception,e:
return
key = paramkey[0:openbrace]
if not self.params.has_key(key):
self.params[key] = {}
current = self.params[key]
while True:
closebrace = paramkey.index(']',
openbrace)
key = paramkey[openbrace+1:closebrace]
try:
openbrace = paramkey.index('[',
closebrace)
except Exception,e:
current[key] = self.params[paramkey]
del self.params[paramkey]
break
if not current.has_key(key):
current[key] = {}
current = current[key]
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "cherrypy-users" group.
To post to this group, send email to cherrypy-users googlegroups.com
To unsubscribe from this group, send email to
cherrypy-users-unsubscribe googlegroups.com
For more options, visit this group at http://
groups.google.com/group/cherrypy-users
-~----------~----~----~----~------~----~------~--~---
|