MCPcopy Index your code
hub / github.com/ddserver/ddserver / validate_python

Method validate_python

ddserver/interface/validation.py:163–184  ·  view source on GitHub ↗
(self,
                      field_dict,
                      state,
                      db)

Source from the content-addressed store, hash-verified

161
162 @require(db = 'ddserver.db:Database')
163 def validate_python(self,
164 field_dict,
165 state,
166 db):
167 with db.cursor() as cur:
168 cur.execute('''
169 SELECT 1
170 FROM `hosts` AS `host`
171 LEFT JOIN `suffixes` AS `suffix`
172 ON ( `suffix`.`id` = `host`.`suffix_id` )
173 WHERE `host`.`hostname` = %(hostname)s
174 AND `host`.`suffix_id` = %(suffix_id)s
175 ''', {'hostname': field_dict[self.hostname],
176 'suffix_id': field_dict[self.suffix]})
177 result = cur.fetchone()
178
179 if result != None:
180 msg = self.message('not_uniq', state)
181 raise formencode.Invalid(msg,
182 field_dict,
183 state,
184 error_dict = {field_dict[self.hostname]: msg})
185
186
187

Callers

nothing calls this directly

Calls 1

cursorMethod · 0.80

Tested by

no test coverage detected