GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — _PropertyMixin.patch() does not work as expected in a batch · Issue #736 · googleapis/google-cloud-python

_PropertyMixin.patch() does not work as expected in a batch #736

New issue
Copy link
New issue
Copy link
Closed
Closed
_PropertyMixin.patch() does not work as expected in a batch#736
Copy link
Assignees
dhermes
Labels
api: storageIssues related to the Cloud Storage API.
Milestone
Storage Stable

Description

@dhermes
dhermes
opened on Mar 14, 2015
Issue body actions

One big takeaway is that connection should not be bound to Blob and Bucket (#728).


If the Bucket does not explicitly have the batch set as it's connection, the request happens outside the batch:

>>> from gcloud import storage
>>> from gcloud.storage.batch import Batch
>>> storage._PROJECT_ENV_VAR_NAME = 'GCLOUD_TESTS_PROJECT_ID'
>>> storage.set_defaults()
>>> bucket_name = 'dsmlmsldfsacjnajdnkewee'
>>> connection = storage.get_default_connection()
>>> bucket = storage.Bucket(name=bucket_name, connection=connection)
>>> blob = storage.Blob('foo', bucket=bucket)
>>> blob._reload_properties()
<Blob: dsmlmsldfsacjnajdnkewee, foo>
>>> blob.content_type = 'foo/bar'
>>>
>>> with Batch() as batch:
...     blob.patch()
...
<Blob: dsmlmsldfsacjnajdnkewee, foo>
Traceback (most recent call last):
  File "<stdin>", line 2, in <module>
  File "gcloud/storage/batch.py", line 165, in __exit__
    self.finish()
  File "gcloud/storage/batch.py", line 130, in finish
    raise ValueError("No deferred requests")
ValueError: No deferred requests

On the other hand, if we do the setup correctly, it puts the blob in an undefined state (I referenced this some time ago):

>>> from gcloud import storage
>>> from gcloud.storage.batch import Batch
>>> storage._PROJECT_ENV_VAR_NAME = 'GCLOUD_TESTS_PROJECT_ID'
>>> storage.set_defaults()
>>>
>>> with Batch() as batch:
...     bucket_name = 'dsmlmsldfsacjnajdnkewee'
...     bucket = storage.Bucket(name=bucket_name, connection=batch)
...     blob = storage.Blob('foo', bucket=bucket)
...     blob.content_type = 'foo/bar'
...     blob.patch()
...
<Blob: dsmlmsldfsacjnajdnkewee, foo>
>>> blob._properties
''
>>> blob.content_type
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "gcloud/storage/_helpers.py", line 163, in _getter
    return self.properties[fieldname]
  File "gcloud/storage/_helpers.py", line 64, in properties
    return self._properties.copy()
AttributeError: 'str' object has no attribute 'copy'

Activity

  1. dhermes
    added
    api: storageIssues related to the Cloud Storage API.
    on Mar 14, 2015
  2. dhermes
    added this to the Storage Stable milestone on Mar 14, 2015
  3. dhermes commented on May 8, 2015

    @dhermes
    dhermes
    on May 8, 2015
    ContributorAuthor
    More actions

    This was fixed in #812

  4. dhermes
    closed this as completedon May 8, 2015
  5. JustinBeckwith
    assigned
    dhermes
    on Feb 1, 2021
  6. parthea
    added a commit that references this issue on Oct 21, 2023

    feat: Update Compute Engine API to revision 20221011 (#736) (#355)

    7d30915
  7. parthea
    added a commit that references this issue on Sep 18, 2025

    chore(main): release 0.22.0 (#736)

    a282c29
  8. parthea
    added 7 commits that reference this issue on Nov 24, 2025

    chore: release 0.40.0 (#736)

    e85dcc5

    feat: migrate to pyproject.toml (#736)

    1959e17

    fix: Avoid sqlalchemy20 (#736)

    307c48c

    fix: unintended exception omittion (#736)

    d08d456

    tests: use 'orchestrate' from 'google-cloud-testutils' (#736)

    53f8f3c

    fix: unintended exception omittion (#736)

    83f67bd

    chore: prevent normalization of semver versioning (#736)

    94eba0d
  9. parthea
    added 5 commits that reference this issue on Mar 2, 2026

    chore(main): release 2.13.3 (#736)

    a5c5e83

    feat: add `LoadJobConfig.projection_fields` to select DATASTORE_BACKU…

    ce9e9b6

    chore: release 2.22.0 (#771)

    ff79006

    chore(deps): update dependency charset-normalizer to v3.4.3 (#736)

    0d803d5

    chore(main): release 2.2.1 (#736)

    adad3e5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @dhermes
    dhermes

Labels

api: storageIssues related to the Cloud Storage API.

Type

No type

Projects

No projects

    Milestone

    • Storage Stable

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402775 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.