Skip to content

DISCUSSION: Does a Transaction need to be bound to a Connection and vice versa #495

@dhermes

Description

@dhermes

It seems we could have connection=None as an optional / implicit argument in the Transaction methods add_auto_id_entity(), begin(), commit() and rollback().

On Connection, the current transaction is used to alter the behavior of the methods, e.g. from commit()

        if self.transaction():
            request.mode = datastore_pb.CommitRequest.TRANSACTIONAL
            request.transaction = self.transaction().id()
        else:
            request.mode = datastore_pb.CommitRequest.NON_TRANSACTIONAL

It seems instead this separation would benefit by having Transaction subclass Connection and adding the "extra" transaction parts when needed.

Metadata

Metadata

Assignees

Labels

api: datastoreIssues related to the Datastore API.type: questionRequest for information or clarification. Not an issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions