﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
2472	forms get_validation_errors()	ratty	somebody	"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


"	defect	closed	Validators		normal	invalid			Unreviewed	0	0	0	0	0	0
