durusmail: quixote-users: FormEncode with Quixote (Problems with defaults for nested schema and passing in httprequest object)
FormEncode with Quixote (Problems with defaults for nested schema and passing in httprequest object)
2004-07-05
2004-07-05
FormEncode with Quixote (Problems with defaults for nested schema and passing in httprequest object)
Vineet Jain
2004-07-05
Ive been playing with Formencode and quixote. So far it generates the
register form and does all the error handling. Everythin works as expected
and is well thought out. I then started to work on getting defaults to
populate the form when there are some errors. Defaults work as expected with
normal schemas. However, I'm having a problem with defaults with nexted
schemas. Register is the example that ships with FormEncode. Defaults don't
seem to work for anything that comes under the StreetAddress class.

Here's my example code so far. I'm having some problems with it working with
defaults for nested schemas. I'm including and example class and form for
registering a user. The problems I'm having so far are:

1. The defaults work for all fields except for those which are nested int he
address class
2. When I pass the request object as http_request I get the following
exception:

Traceback (most recent call last):
  File "C:\Python23\Lib\site-packages\quixote\publish.py", line 522, in
process_request
    output = self.try_publish(request, env.get('PATH_INFO', ''))
  File "C:\Python23\Lib\site-packages\quixote\publish.py", line 457, in
try_publish
    output = object(request)
  File
"c:\Trading\pytradeweb\modules\pytradeweb\testFormEncode\register_form.py",
line 19, in process_register
    return formProcessor.renderForm(httpRequest=request,
action='process_register', defaults=request.form)
  File "C:\Python23\Lib\site-packages\formencode\formprocessor.py", line
158, in renderForm
    errors=errors, state=state)
  File "C:\Python23\Lib\site-packages\formencode\htmlview.py", line 419, in
html
    contents = request.html()
  File "C:\Python23\Lib\site-packages\formencode\htmlview.py", line 228, in
html
    return self.field.html(self)
  File "C:\Python23\Lib\site-packages\formencode\htmlview.py", line 550, in
html
    text.append(self.htmlLine(line, request))
  File "C:\Python23\Lib\site-packages\formencode\htmlview.py", line 571, in
htmlLine
    sub.html(),
  File "C:\Python23\Lib\site-packages\formencode\htmlview.py", line 228, in
html
    return self.field.html(self)
  File "C:\Python23\Lib\site-packages\formencode\htmlview.py", line 342, in
html
    return self.htmlInput(request)
  File "C:\Python23\Lib\site-packages\formencode\htmlview.py", line 830, in
htmlInput
    value=request.default(),
  File "C:\Python23\Lib\site-packages\formencode\htmlview.py", line 284, in
default
    return self.httpRequest.get(self.prefix)
AttributeError: HTTPRequest instance has no attribute 'get'

Vineet

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.709 / Virus Database: 465 - Release Date: 6/22/2004
reply