MCPcopy Index your code
hub / github.com/sqlmapproject/sqlmap / new_control

Method new_control

thirdparty/clientform/clientform.py:2828–2874  ·  view source on GitHub ↗

Adds a new control to the form. This is usually called by ParseFile and ParseResponse. Don't call it youself unless you're building your own Control instances. Note that controls representing lists of items are built up from controls holding only a single list item

(self, type, name, attrs,
                    ignore_unknown=False, select_default=False, index=None)

Source from the content-addressed store, hash-verified

2826 self.__dict__[name] = value
2827
2828 def new_control(self, type, name, attrs,
2829 ignore_unknown=False, select_default=False, index=None):
2830 """Adds a new control to the form.
2831
2832 This is usually called by ParseFile and ParseResponse. Don't call it
2833 youself unless you're building your own Control instances.
2834
2835 Note that controls representing lists of items are built up from
2836 controls holding only a single list item. See ListControl.__doc__ for
2837 further information.
2838
2839 type: type of control (see Control.__doc__ for a list)
2840 attrs: HTML attributes of control
2841 ignore_unknown: if true, use a dummy Control instance for controls of
2842 unknown type; otherwise, use a TextControl
2843 select_default: for RADIO and multiple-selection SELECT controls, pick
2844 the first item as the default if no 'selected' HTML attribute is
2845 present (this defaulting happens when the HTMLForm.fixup method is
2846 called)
2847 index: index of corresponding element in HTML (see
2848 MoreFormTests.test_interspersed_controls for motivation)
2849
2850 """
2851 type = type.lower()
2852 klass = self.type2class.get(type)
2853 if klass is None:
2854 if ignore_unknown:
2855 klass = IgnoreControl
2856 else:
2857 klass = TextControl
2858
2859 a = attrs.copy()
2860 if issubclass(klass, ListControl):
2861 control = klass(type, name, a, select_default, index)
2862 else:
2863 control = klass(type, name, a, index)
2864
2865 if type == "select" and len(attrs) == 1:
2866 for ii in xrange(len(self.controls)-1, -1, -1):
2867 ctl = self.controls[ii]
2868 if ctl.type == "select":
2869 ctl.close_control()
2870 break
2871
2872 control.add_to_form(self)
2873 control._urlparse = self._urlparse
2874 control._urlunparse = self._urlunparse
2875
2876 def fixup(self):
2877 """Normalise form after all controls have been added.

Callers 1

_ParseFileExFunction · 0.95

Calls 5

xrangeClass · 0.85
close_controlMethod · 0.80
getMethod · 0.45
copyMethod · 0.45
add_to_formMethod · 0.45

Tested by

no test coverage detected