Locate and return some specific control within the form. At least one of the name, type, kind, predicate and nr arguments must be supplied. If no matching control is found, ControlNotFoundError is raised. If name is specified, then the control must have the indicat
(self,
name=None, type=None, kind=None, id=None,
predicate=None, nr=None,
label=None)
| 3188 | #--------------------------------------------------- |
| 3189 | |
| 3190 | def find_control(self, |
| 3191 | name=None, type=None, kind=None, id=None, |
| 3192 | predicate=None, nr=None, |
| 3193 | label=None): |
| 3194 | """Locate and return some specific control within the form. |
| 3195 | |
| 3196 | At least one of the name, type, kind, predicate and nr arguments must |
| 3197 | be supplied. If no matching control is found, ControlNotFoundError is |
| 3198 | raised. |
| 3199 | |
| 3200 | If name is specified, then the control must have the indicated name. |
| 3201 | |
| 3202 | If type is specified then the control must have the specified type (in |
| 3203 | addition to the types possible for <input> HTML tags: "text", |
| 3204 | "password", "hidden", "submit", "image", "button", "radio", "checkbox", |
| 3205 | "file" we also have "reset", "buttonbutton", "submitbutton", |
| 3206 | "resetbutton", "textarea", "select" and "isindex"). |
| 3207 | |
| 3208 | If kind is specified, then the control must fall into the specified |
| 3209 | group, each of which satisfies a particular interface. The types are |
| 3210 | "text", "list", "multilist", "singlelist", "clickable" and "file". |
| 3211 | |
| 3212 | If id is specified, then the control must have the indicated id. |
| 3213 | |
| 3214 | If predicate is specified, then the control must match that function. |
| 3215 | The predicate function is passed the control as its single argument, |
| 3216 | and should return a boolean value indicating whether the control |
| 3217 | matched. |
| 3218 | |
| 3219 | nr, if supplied, is the sequence number of the control (where 0 is the |
| 3220 | first). Note that control 0 is the first control matching all the |
| 3221 | other arguments (if supplied); it is not necessarily the first control |
| 3222 | in the form. If no nr is supplied, AmbiguityError is raised if |
| 3223 | multiple controls match the other arguments (unless the |
| 3224 | .backwards-compat attribute is true). |
| 3225 | |
| 3226 | If label is specified, then the control must have this label. Note |
| 3227 | that radio controls and checkboxes never have labels: their items do. |
| 3228 | |
| 3229 | """ |
| 3230 | if ((name is None) and (type is None) and (kind is None) and |
| 3231 | (id is None) and (label is None) and (predicate is None) and |
| 3232 | (nr is None)): |
| 3233 | raise ValueError( |
| 3234 | "at least one argument must be supplied to specify control") |
| 3235 | return self._find_control(name, type, kind, id, label, predicate, nr) |
| 3236 | |
| 3237 | #--------------------------------------------------- |
| 3238 | # Private methods. |
no test coverage detected