91 # validators availables are : |
91 # validators availables are : |
92 # DTDValidator : validates XML + declared DTD |
92 # DTDValidator : validates XML + declared DTD |
93 # SaxOnlyValidator : guarantees XML is well formed |
93 # SaxOnlyValidator : guarantees XML is well formed |
94 # None : do not try to validate anything |
94 # None : do not try to validate anything |
95 # validators used must be imported from from.devtools.htmlparser |
95 # validators used must be imported from from.devtools.htmlparser |
|
96 valmap = {None: None, 'dtd': DTDValidator, 'xml': SaxOnlyValidator} |
96 content_type_validators = { |
97 content_type_validators = { |
97 # maps MIME type : validator name |
98 # maps MIME type : validator name |
98 # |
99 # |
99 # do not set html validators here, we need HTMLValidator for html |
100 # do not set html validators here, we need HTMLValidator for html |
100 # snippets |
101 # snippets |
107 'text/x-vcard': None, |
108 'text/x-vcard': None, |
108 'text/calendar': None, |
109 'text/calendar': None, |
109 'application/json': None, |
110 'application/json': None, |
110 'image/png': None, |
111 'image/png': None, |
111 } |
112 } |
112 vid_validators = { |
113 # maps vid : validator name (override content_type_validators) |
113 # maps vid : validator name (override content_type_validators) |
114 vid_validators = dict((vid, valmap[valkey]) |
114 } |
115 for vid, valkey in VIEW_VALIDATORS.iteritems()) |
115 valmap = {None: None, 'dtd': DTDValidator, 'xml': SaxOnlyValidator} |
116 |
116 no_auto_populate = () |
117 no_auto_populate = () |
117 ignored_relations = () |
118 ignored_relations = () |
118 |
|
119 def __init__(self, *args, **kwargs): |
|
120 self.validators = {} |
|
121 EnvBasedTC.__init__(self, *args, **kwargs) |
|
122 for view, valkey in VIEW_VALIDATORS.iteritems(): |
|
123 self.validators[view] = self.valmap[valkey] |
|
124 |
119 |
125 def custom_populate(self, how_many, cursor): |
120 def custom_populate(self, how_many, cursor): |
126 pass |
121 pass |
127 |
122 |
128 def post_populate(self, cursor): |
123 def post_populate(self, cursor): |