Skip to content

Conversation

@ArneGudermann
Copy link
Contributor

@ArneGudermann ArneGudermann commented Sep 12, 2023

This PR adds a run_in_transaction decorator. Now you can call transaction like :

@exposed
def test(self, key):
    @run_in_transaction
    def trans(key):
        e = db.Get(db.Key.from_legacy_urlsafe(key))
	assert e
	e["new"] = "123"
	return e

return trans(key)

I think it looks cleaner.
This is only an Idea What do you think of it?

@ArneGudermann ArneGudermann added feature New feature or request Priority: Low This issue can be considered with enough idle time. idea labels Sep 12, 2023
@sveneberth
Copy link
Member

I still don't understand why we should have a method for this and not have a context manager implementation like Google's Datastore client.

@exposed
	def test(self, key):
		with db.Transaction():
			e = db.Get(db.Key.from_legacy_urlsafe(key))
			assert e
			e["new"] = "123"
			return e

is so much more simple and pythonic

@ArneGudermann
Copy link
Contributor Author

ArneGudermann commented Sep 12, 2023

The context of the transaction is currently handled by the viur-datastore. But we can exposed it to the core. We can discuss about that in the viur meeting.

@phorward
Copy link
Member

is so much more simple and pythonic

Why not simply...

with skel:
    if skel.fromDB(key):
        skel["count"] += 1
        skel.toDB()

@sveneberth
Copy link
Member

Why not simply...

skel = MySkeleton(auto_save=True)
skel["count"] += 1

@ArneGudermann ArneGudermann added the viur-meeting Issues to discuss in the next ViUR meeting label Sep 12, 2023
@sveneberth sveneberth added this to the ViUR-core v3.6 milestone Sep 19, 2023
@sveneberth sveneberth removed the viur-meeting Issues to discuss in the next ViUR meeting label Sep 20, 2023
@phorward phorward removed this from the ViUR-core v3.7 milestone Sep 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature New feature or request idea Priority: Low This issue can be considered with enough idle time.

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

3 participants