i'm working on web application in python using cherrypy. have form on page meant editing user profile, default values of things filled in when load page. uses jinja2 templating, whether you're editing or creating profile, variable gets passed page telling so.
<form method="post"> <span class="left"> <span id="prof-art" class="prof-art" style="background-image: url( {{ '/assets/profile-art/'+(prof.prof_id|string)+'.jpg' if prof.prof_id else '/static/img/new-user.jpg' }} );"></span> <span class="prof-name"><input type="text" name="name" placeholder="name" autocomplete="off" {{ 'value="'+prof.name+'"' if prof.name }}></span> <span class="prof-loc"><input type="text" name="loc" placeholder="location" autocomplete="off" {{ 'value="'+prof.location+'"' if prof.location }}></span> <span class="prof-url">example.com/u/<input type="text" name="url" autocomplete="off" {{ 'value="'+prof.url+'"' if prof.url }}></span> <span class="prof-bio"><textarea name="bio" placeholder="add description of here. markdown supported." autocomplete="off">{{ prof.bio or '' }}</textarea></span> <span class="prof-img"><input type="file" name="img" id="imginp"></span> </span> <button type="submit" class="blue-btn prof-save"> {% if editing %}<i class="fa fa-wrench"></i> update {% else %}<i class="fa fa-plus-square"></i> create {% endif %}</button> </form> when submitted, code process data gave , either save or create it, depending on if you're editing or creating profile.
however, none of that's important, httperror happens before code processed.
traceback (most recent call last): file "/library/python/2.7/site-packages/cherrypy/_cprequest.py", line 670, in respond response.body = self.handler() file "/library/python/2.7/site-packages/cherrypy/lib/encoding.py", line 217, in __call__ self.body = self.oldhandler(*args, **kwargs) file "/library/python/2.7/site-packages/cherrypy/_cpdispatch.py", line 67, in __call__ raise sys.exc_info()[1] httperror: (400, 'multiple values parameters: url') what's this? why url field doing this? if remove value tag template this. can't find can causing - there's 1 url field in form, why think there 2? seems has happening when it's submitted, because nothing in cherrypy server runs before error pops up.
update: wrote quick python web server prints out data in request send it. changing action attribute server's address able inspect post variables passed along form. turns out may not html form's fault, cherrypy's.
post variables: {'url': 'dfghdfgdf', 'loc': 'fghjdfg', 'name': 'dfghdfgdf', 'btc': '', 'bio': 'srffghmn+dfghdfgh'}
the problem setting positional argument on method , sending value on form.
for see form not specify action url, use current one. guess doing this:
class root: @cherrypy.expose def u(self, url='', mode='', *args, **post): pass and submitting form while on url: /u/something, something duplicating meaning of url parameter, given positional on signature , passed argument on form submission.
Comments
Post a Comment