

def submit(self, submit_name=None, make_request=True, url=None, extra_post=None):
    '\n        Submit default form.\n\n        :param submit_name: name of button which should be "clicked" to\n            submit form\n        :param make_request: if `False` then grab instance will be\n            configured with form post data but request will not be\n            performed\n        :param url: explicitly specify form action url\n        :param extra_post: (dict or list of pairs) additional form data which\n            will override data automatically extracted from the form.\n\n        Following input elements are automatically processed:\n\n        * input[type="hidden"] - default value\n        * select: value of last option\n        * radio - ???\n        * checkbox - ???\n\n        Multipart forms are correctly recognized by grab library.\n\n        Example::\n\n            # Assume that we going to some page with some form\n            g.go(\'some url\')\n            # Fill some fields\n            g.set_input(\'username\', \'bob\')\n            g.set_input(\'pwd\', \'123\')\n            # Submit the form\n            g.submit()\n\n            # or we can just fill the form\n            # and do manual submission\n            g.set_input(\'foo\', \'bar\')\n            g.submit(make_request=False)\n            g.request()\n\n            # for multipart forms we can specify files\n            from grab import UploadFile\n            g.set_input(\'img\', UploadFile(\'/path/to/image.png\'))\n            g.submit()\n        '
    post = self.form_fields()
    submit_controls = {
        
    }
    for elem in self.form.inputs:
        if ((elem.tag == 'input') and (elem.type == 'submit') and (elem.get('name') is not None)):
            submit_controls[elem.name] = elem
    if len(submit_controls):
        if ((submit_name is None) or (submit_name not in submit_controls)):
            controls = sorted(submit_controls.values(), key=(lambda x: x.name))
            submit_name = controls[0].name
        for name in submit_controls:
            if (name != submit_name):
                if (name in post):
                    del post[obj]
    if url:
        action_url = urljoin(self.url, url)
    else:
        action_url = urljoin(self.url, self.form.action)
    if (self.form.method == 'POST'):
        if ('multipart' in self.form.get('enctype', '')):
            for (key, obj) in self._file_fields.items():
                post[key] = obj
    post_items = list(post.items())
    del post
    if extra_post:
        if isinstance(extra_post, dict):
            extra_post_items = extra_post.items()
        else:
            extra_post_items = extra_post
        keys_to_drop = set([x for (x, y) in extra_post_items])
        for key in keys_to_drop:
            post_items = [(x, y) for (x, y) in post_items if (x != key)]
        for (key, value) in extra_post_items:
            post_items.append((key, value))
    if (self.form.method == 'POST'):
        if ('multipart' in self.form.get('enctype', '')):
            self.grab.setup(multipart_post=post_items)
        else:
            self.grab.setup(post=post_items)
        self.grab.setup(url=action_url)
    else:
        url = ((action_url.split('?')[0] + '?') + smart_urlencode(post_items))
        self.grab.setup(url=url)
    if make_request:
        return self.grab.request()
    else:
        return None

dataset/ETHPy150Open lorien/grab/grab/document.py FormExtension.submit/VarMisuse@184/710 `name`->`obj`