#2472: forms get_validation_errors()
------------------------+---------------------------------------------------
 Reporter:  ratty       |       Owner:  somebody
     Type:  defect      |      Status:  new     
 Priority:  normal      |   Milestone:          
Component:  Validators  |     Version:          
 Severity:  normal      |    Keywords:          
------------------------+---------------------------------------------------
 In the included code exerpt, I am setting default values for form fields I
 do not want the user to be able to modify, specifically 'user' and 'hits'.
 I wrote a routine to remove any values from request.POST I don't want the
 user to have control over. This is done by creating an instance of
 MultiValueDict and copying over any values that the user is allowed to
 post, returning the new MultiValDict instance.
 
 ### post_sanitize
 def post_sanitize(post, fields):
     safe_post = MultiValueDict({})
     for f in fields:
         if post.get(f):
             safe_post[f] = post.get(f)
 
     return safe_post
 
 ### excerpt from view.py
      post_copy = request.POST.copy()
      safe_post = post_sanitize(post_copy, valid_post_fields)
      safe_post['user'] = 1
      safe_post['hits'] = 0
      errors = manipulator.get_validation_errors(safe_post)
 
 When safe_post['hits'] is set to 0, I get an form error when I call
 get_validation_errors, saying that 'hits' is not set
 
 If i set 'hits' to 1, I get this error:
 
 /usr/lib/python2.4/site-packages/Django-0.95-
 py2.4.egg/django/forms/__init__.py in hasNoNewlines
 
  384. def hasNoNewlines(self, data, form):
 
  385. if data and '\n' in data:
 
 Exception Type:         TypeError
 Exception Value:        iterable argument required

-- 
Ticket URL: <http://code.djangoproject.com/ticket/2472>
Django <http://code.djangoproject.org/>
The web framework for perfectionists with deadlines.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-updates
-~----------~----~----~----~------~----~------~--~---

Reply via email to