I forgot to write error:

<type 'exceptions.UnicodeDecodeError'> at /

'ascii' codec can't decode byte 0xd0 in position 0: ordinal not in range(128)

Python /usr/local/lib/python2.6/dist-packages/web/form.py in render, line 43

On 30 April 2010 15:04, melandory <[email protected]> wrote:
>
> Hi. I have problem in unicode in forms.
>
> This code:
> myform = form.Form(
>    form.Textbox(u'Фамилия'))
>
> Produce Traceback:
>
> # /usr/local/lib/python2.6/dist-packages/web/form.py in render
>
>  36. out += '<table>\n'
>  37.
>  38. for i in self.inputs:
>  39. html = i.pre + i.render() + self.rendernote(i.note) + i.post
>  40. if i.is_hidden():
>  41. out += ' <tr style="display: none;"><th></th><td>%s</td></tr>\n'
> % (html)
>  42. else:
>
>  43. out += ' <tr><th><label for="%s">%s</label></th><td>%s</td></tr>
> \n' % (i.id, net.websafe(i.description), html) ...
>
>  44. out += "</table>"
>  45. return out
>  46.
>  47. def render_css(self):
>  48. out = []
>  49. out.append(self.rendernote(self.note))
>
> ▶ Local vars
> Variable        Value
> html
> '<input type="text"
> id="\xd0\xa0\xc2\xa4\xd0\xa0\xc2\xb0\xd0\xa0\xd1\x98\xd0\xa0\xd1\x91\xd0\xa0\xc2\xbb
> \xd0\xa0\xd1\x91\xd0\xa1\xd0\x8f"
> name="\xd0\xa0\xc2\xa4\xd0\xa0\xc2\xb0\xd0\xa0\xd1\x98\xd0\xa0\xd1\x91\xd0\xa0\xc2\xbb
> \xd0\xa0\xd1\x91\xd0\xa1\xd0\x8f"/>'
> i
> <web.form.Textbox object at 0x998352c>
> out
> '<table>\n'
> self
> <web.form.Form instance at 0x998346c>
> # templates/formtest.html in __template__
>
>   0. $def with (form)
>   1.
>   2. <form name="main" method="post">
>   3. $if not form.valid: <p class="error">Try again, AmeriCAN:</p>
>   4. $:form.render()
>
>   5. <input type="submit" /> </form> ...
>
>   6.
>
> ▶ Local vars
> Variable        Value
> form
> <web.form.Form instance at 0x998346c>
> # /usr/local/lib/python2.6/dist-packages/web/template.py in
> _join_output
>
>  779. out = self.t(*a, **kw)
>  780. return self._join_output(out)
>  781.
>  782. def _join_output(self, out):
>  783. d = TemplateResult()
>  784. data = []
>  785.
>
>  786. for name, value in out: ...
>
>  787. if name:
>  788. d[name] = value
>  789. else:
>  790. data.append(value)
>  791.
>  792. d.__body__ = u"".join(data)
>
> ▶ Local vars
> Variable        Value
> d
> <TemplateResult: {}>
> data
> [u'\n', u'<form name="main" method="post"> \n']
> name
> ''
> out
> <generator object __template__ at 0x9a49464>
> self
> <web.template.Template instance at 0x9a436ac>
> value
> u'<form name="main" method="post"> \n'
> # /usr/local/lib/python2.6/dist-packages/web/template.py in __call__
>
>  773. def _compile(self, code):
>  774. env = self.make_env(self._globals or {}, self._builtins)
>  775. exec(code, env)
>  776. return env['__template__']
>  777.
>  778. def __call__(self, *a, **kw):
>  779. out = self.t(*a, **kw)
>
>  780. return self._join_output(out) ...
>
>  781.
>  782. def _join_output(self, out):
>  783. d = TemplateResult()
>  784. data = []
>  785.
>  786. for name, value in out:
>
> ▶ Local vars
> Variable        Value
> a
> (<web.form.Form instance at 0x998346c>,)
> kw
> {}
> out
> <generator object __template__ at 0x9a49464>
> self
> <web.template.Template instance at 0x9a436ac>
> # /usr/local/lib/python2.6/dist-packages/web/template.py in __call__
>
>  860. normalize_text = staticmethod(normalize_text)
>  861.
>  862. def __call__(self, *a, **kw):
>  863. import webapi as web
>  864. if 'headers' in web.ctx and self.content_type:
>  865. web.header('Content-Type', self.content_type, unique=True)
>  866.
>
>  867. return BaseTemplate.__call__(self, *a, **kw) ...
>
>  868.
>  869. def generate_code(text, filename):
>  870. # parse the text
>  871. rootnode = Parser(text, filename).parse()
>  872.
>  873. # generate python code from the parse tree
>
> ▶ Local vars
> Variable        Value
> a
> (<web.form.Form instance at 0x998346c>,)
> kw
> {}
> self
> <web.template.Template instance at 0x9a436ac>
> web
> <module 'web.webapi' from '/usr/local/lib/python2.6/dist-packages/web/
> webapi.pyc'>
> # /home/melandory/project/inquire/application.py in GET
>
>  14. form.Validator('Must be more than 5', lambda x:int(x)>5)),
>  15. form.Textarea(u'Name'),
>  16. form.Dropdown(u'Choise', ['mustard', 'fries', 'wine']))
>  17.
>  18. class index:
>  19. def GET(self):
>  20. form = myform()
>
>  21. return render.formtest(form) ...
>
>  22.
>  23. def POST(self):
>  24. form = myform()
>  25. if not form.validates():
>  26. return render.formtest(form)
>  27. else:
>
> ▶ Local vars
> Variable        Value
> form
> <web.form.Form instance at 0x998346c>
> self
> <application.index instance at 0x998348c>
> # /usr/local/lib/python2.6/dist-packages/web/application.py in
> handle_class
>
>  379. def handle_class(cls):
>  380. meth = web.ctx.method
>  381. if meth == 'HEAD' and not hasattr(cls, meth):
>  382. meth = 'GET'
>  383. if not hasattr(cls, meth):
>  384. raise web.nomethod(cls)
>  385. tocall = getattr(cls(), meth)
>
>  386. return tocall(*args) ...
>
>  387.
>  388. def is_class(o): return isinstance(o, (types.ClassType, type))
>  389.
>  390. if f is None:
>  391. raise web.notfound()
>  392. elif isinstance(f, application):
>
> ▶ Local vars
> Variable        Value
> args
> []
> cls
> <class application.index at 0x997f59c>
> meth
> u'GET'
> tocall
> <bound method index.GET of <application.index instance at 0x998348c>>
> # /usr/local/lib/python2.6/dist-packages/web/application.py in
> _delegate
>
>  404. elif '.' in f:
>  405. x = f.split('.')
>  406. mod, cls = '.'.join(x[:-1]), x[-1]
>  407. mod = __import__(mod, globals(), locals(), [""])
>  408. cls = getattr(mod, cls)
>  409. else:
>  410. cls = fvars[f]
>
>  411. return handle_class(cls) ...
>
>  412. elif hasattr(f, '__call__'):
>  413. return f()
>  414. else:
>  415. return web.notfound()
>  416.
>  417. def _match(self, mapping, value):
>
> # /usr/local/lib/python2.6/dist-packages/web/application.py in handle
>
>  225.
>  226. def browser(self):
>  227. import browser
>  228. return browser.AppBrowser(self)
>  229.
>  230. def handle(self):
>  231. fn, args = self._match(self.mapping, web.ctx.path)
>
>  232. return self._delegate(fn, self.fvars, args) ...
>
>  233.
>  234. def handle_with_processors(self):
>  235. def process(processors):
>  236. try:
>  237. if processors:
>  238. p, processors = processors[0], processors[1:]
>
> ▶ Local vars
> <web.application.application instance at 0x995ac8c>
> # /usr/local/lib/python2.6/dist-packages/web/application.py in process
>
>  234. def handle_with_processors(self):
>  235. def process(processors):
>  236. try:
>  237. if processors:
>  238. p, processors = processors[0], processors[1:]
>  239. return p(lambda: process(processors))
>  240. else:
>
>  241. return self.handle()

-- 
You received this message because you are subscribed to the Google Groups 
"web.py" 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/webpy?hl=en.

Reply via email to