def clean(self):
    'Validate the new repo form.\n\n           Might perform a request to upstream Bower.'
    cleaned_data = super(NewRepoForm, self).clean()
    origin_url = cleaned_data['origin_url']
    origin_source = cleaned_data['origin_source']
    if ((origin_source == 'origin_url') and (not origin_url)):
        msg = 'Please provide an origin URL.'
        self._errors['origin_url'] = self.error_class([msg])
        del cleaned_data['origin_url']
        del cleaned_data['origin_source']
    elif (origin_source == 'upstream'):
        upstream = settings.UPSTREAM_BOWER_REGISTRY
        name = cleaned_data['name']
        try:
            upstream_pkg = bowerlib.get_package(upstream, name)
        except IOError as exc:
            msg = str(exc)
            self._errors['origin_source'] = self.error_class([msg])
        else:
            if (not upstream_pkg):
                msg = ('Upstream registry has no knowledge of %s.' % name)
                self._errors['name'] = self.error_class([msg])
                del cleaned_data['name']
            else:
                upstream_origin_url = upstream_pkg['url']
                cleaned_data['origin_url'] = upstream_origin_url
    return cleaned_data
Validate the new repo form.

Might perform a request to upstream Bower.
def clean(self):
    'Validate the new repo form.\n\n           Might perform a request to upstream Bower.'
    cleaned_data = super(NewRepoForm, self).clean()
    origin_url = cleaned_data['origin_url']
    origin_source = cleaned_data['origin_source']
    if ((origin_source == 'origin_url') and (not origin_url)):
        msg = 'Please provide an origin URL.'
        self._errors['origin_url'] = self.error_class([msg])
        del cleaned_data['origin_url']
        del cleaned_data['origin_source']
    elif (origin_source == 'upstream'):
        upstream = settings.UPSTREAM_BOWER_REGISTRY
        name = cleaned_data['name']
        try:
            upstream_pkg = bowerlib.get_package(upstream, name)
        except IOError as exc:
            msg = str(exc)
            self._errors['origin_source'] = self.error_class([msg])
        else:
            if (not upstream_pkg):
                msg = ('Upstream registry has no knowledge of %s.' % name)
                self._errors['name'] = self.error_class([msg])
                del cleaned_data['name']
            else:
                upstream_origin_url = upstream_pkg['url']
                cleaned_data['origin_url'] = upstream_origin_url
    return cleaned_data