replace data.has_key() with "key in data".

svn path=/plone.app.discussion/trunk/; revision=29342
This commit is contained in:
Timo Stollenwerk 2009-08-24 18:09:32 +00:00
parent c83d826c46
commit 8b9a3e63c9

View File

@ -92,6 +92,7 @@ def cancelButtonActionFactory(request, field):
button.klass += " standalone" button.klass += " standalone"
return button return button
class CommentForm(extensible.ExtensibleForm, form.Form): class CommentForm(extensible.ExtensibleForm, form.Form):
ignoreContext = True # don't use context to get widget data ignoreContext = True # don't use context to get widget data
@ -129,7 +130,7 @@ class CommentForm(extensible.ExtensibleForm, form.Form):
portal_membership = getToolByName(self.context, 'portal_membership') portal_membership = getToolByName(self.context, 'portal_membership')
if settings.captcha != 'disabled' and portal_membership.isAnonymousUser(): if settings.captcha != 'disabled' and portal_membership.isAnonymousUser():
# Check captcha only if it is not disabled # Check captcha only if it is not disabled
if data.has_key('captcha'): if 'captcha' in data:
# Check captcha only if there is a value, otherwise # Check captcha only if there is a value, otherwise
# the default "required" validator is sufficient. # the default "required" validator is sufficient.
captcha = CaptchaValidator(self.context, self.request, None, ICaptcha['captcha'], None) captcha = CaptchaValidator(self.context, self.request, None, ICaptcha['captcha'], None)
@ -137,22 +138,22 @@ class CommentForm(extensible.ExtensibleForm, form.Form):
else: else:
return return
if data.has_key('title') and data.has_key('text'): if 'title' in data and 'text' in data:
title = data['title'] title = data['title']
text = data['text'] text = data['text']
if data.has_key('author_name'): if 'author_name' in data:
author_name = data['author_name'] author_name = data['author_name']
else: else:
author_name = u"" author_name = u""
if data.has_key('author_username'): if 'author_username' in data:
author_name = data['author_username'] author_name = data['author_username']
else: else:
author_username = u"" author_username = u""
if data.has_key('author_email'): if 'author_email' in data:
author_email = data['author_email'] author_email = data['author_email']
else: else:
author_email = u"" author_email = u""
@ -202,7 +203,7 @@ class CommentForm(extensible.ExtensibleForm, form.Form):
portal_membership = getToolByName(self.context, 'portal_membership') portal_membership = getToolByName(self.context, 'portal_membership')
if settings.captcha != 'disabled' and portal_membership.isAnonymousUser(): if settings.captcha != 'disabled' and portal_membership.isAnonymousUser():
# Check captcha only if it is not disabled # Check captcha only if it is not disabled
if data.has_key('captcha'): if 'captcha' in data:
# Check captcha only if there is a value, otherwise # Check captcha only if there is a value, otherwise
# the default "required" validator is sufficient. # the default "required" validator is sufficient.
captcha = CaptchaValidator(self.context, self.request, None, ICaptcha['captcha'], None) captcha = CaptchaValidator(self.context, self.request, None, ICaptcha['captcha'], None)
@ -210,23 +211,23 @@ class CommentForm(extensible.ExtensibleForm, form.Form):
else: else:
return return
if data.has_key('title') and data.has_key('text') and data.has_key('in_reply_to'): if 'title' in data and 'text' in data and 'in_reply_to' in data:
title = data['title'] title = data['title']
text = data['text'] text = data['text']
reply_to_comment_id = data['in_reply_to'] reply_to_comment_id = data['in_reply_to']
if data.has_key('author_name'): if 'author_name' in data:
author_name = data['author_name'] author_name = data['author_name']
else: else:
author_name = u"" author_name = u""
if data.has_key('author_username'): if 'author_username' in data:
author_name = data['author_username'] author_name = data['author_username']
else: else:
author_username = u"" author_username = u""
if data.has_key('author_email'): if 'author_email' in data:
author_email = data['author_email'] author_email = data['author_email']
else: else:
author_email = u"" author_email = u""