def get_dataset_from_kwargs(self, bundle, **kwargs):
        """
        Extract a dataset from one of the variety of places it might be hiding.
        """
        kwargs_slug = kwargs['dataset_slug']
        
        bundle_uri = None
        bundle_slug = None

        if bundle:
            bundle_uri = bundle.data.pop('dataset', None)

        if bundle_uri:
            prefix = get_script_prefix()

            if prefix and bundle_uri.startswith(prefix):
                bundle_uri = bundle_uri[len(prefix)-1:]

            view, args, kwargs = resolve(bundle_uri)

            bundle_slug = kwargs['slug']

        if bundle_slug and bundle_slug != kwargs_slug:
            raise BadRequest(_('Dataset specified in request body does not agree with dataset API endpoint used.'))

        return Dataset.objects.get(slug=kwargs_slug)
dataset/ETHPy150Open pandaproject/panda/panda/api/data.py/DataResource.get_dataset_from_kwargs/original