Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#825: Allow passing explicit connection to dataset API methods. #858

Closed
wants to merge 3 commits into from
Closed

#825: Allow passing explicit connection to dataset API methods. #858

wants to merge 3 commits into from

Conversation

tseaver
Copy link
Contributor

@tseaver tseaver commented May 4, 2015

See #825.

@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label May 4, 2015
@tseaver tseaver added the api: datastore Issues related to the Datastore API. label May 4, 2015
@coveralls
Copy link

Coverage Status

Coverage remained the same at 100.0% when pulling 9130c03 on tseaver:825-datastore-dataset_explicit_connection into 8b5c5b9 on GoogleCloudPlatform:master.

"""Proxy to :func:`gcloud.datastore.api.get`.

Passes our ``dataset_id``.
"""
if connection is None:
connection = self.connection

This comment was marked as spam.

@dhermes
Copy link
Contributor

dhermes commented May 4, 2015

I agree with the spirit of #825 but I think the Dataset was already doing the right thing. Maybe we should just make the connection required in the constructor?

@tseaver
Copy link
Contributor Author

tseaver commented May 4, 2015

ISTM that it would be better to just delete the connection attribute altogether from Dataset, because the methods it proxies to already DTRT if pass connection=None.

@dhermes
Copy link
Contributor

dhermes commented May 4, 2015

If we go the "clients everywhere" route, then Dataset needs to hold the same properties as _DefaultsContainer.

@tseaver
Copy link
Contributor Author

tseaver commented May 4, 2015

I'm actually opposed to the "client" notion at this point: I think the "use a connection as a context manager" bit would work better. We don't need to weld the project ID together with the connection, since it is only passed in a few cases.

@tseaver
Copy link
Contributor Author

tseaver commented May 4, 2015

I think @jgeewax was actually in agreement with that notion at the end of the last call, too.

@jgeewax
Copy link
Contributor

jgeewax commented May 6, 2015

I'm a fan of the Client pattern that Danny is tossing around -- take a look at #861? Maybe we can discuss it there?

@dhermes
Copy link
Contributor

dhermes commented May 6, 2015

It would be nice to avoid churn if we could.

I think making connections constructable with one-liner factories that also pull in credentials will make things easier (in addition to making them have long-lived contexts). If we need clients, we can go that route, but if we don't we can move forward instead of chasing our tail.

@tseaver
Copy link
Contributor Author

tseaver commented May 6, 2015

@dhermes a671672 removes the Dataset.connection attribute altogether -- I think it makes for a better DX.

@dhermes
Copy link
Contributor

dhermes commented May 6, 2015

@tseaver How does it help? What is better? It certainly doesn't capture the idea of a pre-loaded object. And after the change Dataset just becomes a string with a bunch of methods.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 100.0% when pulling a671672 on tseaver:825-datastore-dataset_explicit_connection into 8b5c5b9 on GoogleCloudPlatform:master.

@tseaver
Copy link
Contributor Author

tseaver commented May 7, 2015

The goal of the Dataset class was to ease the process of constructing many-many objects which needed to be passed a dataset_id in their ctors. Bundling in yet-another-way-to-spell-a-non-default-connection adds neither clarity for the user, who is likely to be confused about how to signal it, nor in straightforwardness of implementation.

Except for Batch and Transaction objects, which necessarily wrap a connection object, I would say that any connection attribute in a user-visible object is a misfeature, across all the APIs.

@dhermes
Copy link
Contributor

dhermes commented May 7, 2015

This really just brings up the question: do all config defaults matter as a bundle or just the some of them.

Proxied functions/methods already handle that directly.
@tseaver
Copy link
Contributor Author

tseaver commented May 14, 2015

ISTM we can't move on this until #861 settles out.

@dhermes
Copy link
Contributor

dhermes commented May 14, 2015

Indeed

@tseaver tseaver added the do not merge Indicates a pull request not ready for merge, due to either quality or timing. label Jun 9, 2015
@dhermes
Copy link
Contributor

dhermes commented Jun 22, 2015

@tseaver this doesn't exactly fit the pattern of #910. I image you'll be binding clients to make Transaction work anyhow?

@tseaver tseaver closed this Jun 23, 2015
@tseaver tseaver deleted the 825-datastore-dataset_explicit_connection branch June 23, 2015 20:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: datastore Issues related to the Datastore API. cla: yes This human has signed the Contributor License Agreement. do not merge Indicates a pull request not ready for merge, due to either quality or timing.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants