def create_bucket(request, bucket_id):
    """Create a bucket if it doesn't exists."""
    bucket_put = (request.method.lower() == 'put' and
                  request.path.endswith('buckets/default'))
    # Do nothing if current request will already create the bucket.
    if bucket_put:
        return

    # Do not intent to create multiple times per request (e.g. in batch).
    already_created = request.bound_data.setdefault('buckets', {})
    if bucket_id in already_created:
        return

    bucket = resource_create_object(request=request,
                                    resource_cls=Bucket,
                                    uri='/buckets/%s' % bucket_id,
                                    resource_name='bucket',
                                    obj_id=bucket_id)
    already_created[bucket_id] = bucket
dataset/ETHPy150Open Kinto/kinto/kinto/plugins/default_bucket/__init__.py/create_bucket/original