[webpy] dropdown in GAE

11 views
Skip to first unread message

ProfessionalIT

unread,
May 13, 2010, 2:08:16 PM5/13/10
to web.py
Friends,

How create a form.Dropdown() control that run in GAE?

I have this code that don't run in GAE:

# in the forms.py
result = data.all_categories() # this method return all records of
table category in GAE/big table format.
args = [(row.key().id(), row.title) for row in result]

new_post = form.Form(
form.Dropdown('category', args),
form.Textbox('title'),
form.Textarea('text'),
form.Dropdown('language', [('pt', 'Portuguese'), ('en',
'English')]),
form.Button('Submit!')

# in app.py
class Post:
def GET(self):
frm = forms.new_post()
return render.full(render.form(frm))

def POST(self):
global last_updated
frm = forms.new_post()
if frm.validates():
data.save_entry(frm.d)
last_updated = data.last_updated()
raise web.seeother('/')
else:
return render.full(render.form(frm))

-- Leandro.

--
You received this message because you are subscribed to the Google Groups "web.py" group.
To post to this group, send email to we...@googlegroups.com.
To unsubscribe from this group, send email to webpy+un...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/webpy?hl=en.

ProfessionalIT

unread,
May 14, 2010, 2:05:36 PM5/14/10
to web.py
The problem is in the forms.py in this function:

def attrget(obj, attr, value=None):
if hasattr(obj, 'has_key') and obj.has_key(attr): return obj[attr]
if hasattr(obj, attr): return getattr(obj, attr)
return value

generate this error:

<type 'exceptions.AttributeError'>: 'unicode' object has no attribute
'has_key'
args = ("'unicode' object has no attribute 'has_key'",)
message = "'unicode' object has no attribute 'has_key'"

ProfessionalIT

unread,
May 18, 2010, 8:14:00 AM5/18/10
to web.py
Friends,

any idea how to solve this problem ?
The error occur in the form.validates() in the POST method.

IMHO the root cause of the problem is the 'big table' format, I
say this because the form generated by the GET method is correct(It
has the <option value="1">Category A</option>, <option
value="2">Category B</option>) but when I submit the form and the
forms.validates() is called the error occurs.

someone has a form like this running on Google App Engine?

Thanks,

best regards,
Leandro.

ProfessionalIT

unread,
May 25, 2010, 8:46:24 AM5/25/10
to web.py
Reply all
Reply to author
Forward
0 new messages