Skip to content

Commit 539f6f9

Browse files
author
matmoncon
committed
refactor(RelationshipProperty): pass source node to relationship-property hooks instead of self
1 parent 657dff4 commit 539f6f9

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

pyneo4j_ogm/fields/relationship_property.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,9 @@ async def decorator(self: "RelationshipProperty", *args, **kwargs): # type: ign
7777
if hook_name in settings.pre_hooks:
7878
for hook_function in settings.pre_hooks[hook_name]:
7979
if iscoroutinefunction(hook_function):
80-
await hook_function(self, *args, **kwargs)
80+
await hook_function(source_node, *args, **kwargs)
8181
else:
82-
hook_function(self, *args, **kwargs)
82+
hook_function(source_node, *args, **kwargs)
8383

8484
result = await func(self, *args, **kwargs)
8585

@@ -88,9 +88,9 @@ async def decorator(self: "RelationshipProperty", *args, **kwargs): # type: ign
8888
if hook_name in settings.post_hooks:
8989
for hook_function in settings.post_hooks[hook_name]:
9090
if iscoroutinefunction(hook_function):
91-
await hook_function(self, result, *args, **kwargs)
91+
await hook_function(source_node, result, *args, **kwargs)
9292
else:
93-
hook_function(self, result, *args, **kwargs)
93+
hook_function(source_node, result, *args, **kwargs)
9494

9595
return result
9696

@@ -108,9 +108,9 @@ def decorator(self: "RelationshipProperty", *args, **kwargs):
108108
if hook_name in settings.pre_hooks:
109109
for hook_function in settings.pre_hooks[hook_name]:
110110
if iscoroutinefunction(hook_function):
111-
loop.run_until_complete(hook_function(self, *args, **kwargs))
111+
loop.run_until_complete(hook_function(source_node, *args, **kwargs))
112112
else:
113-
hook_function(self, *args, **kwargs)
113+
hook_function(source_node, *args, **kwargs)
114114

115115
result = func(self, *args, **kwargs)
116116

@@ -119,9 +119,9 @@ def decorator(self: "RelationshipProperty", *args, **kwargs):
119119
if hook_name in settings.post_hooks:
120120
for hook_function in settings.post_hooks[hook_name]:
121121
if iscoroutinefunction(hook_function):
122-
loop.run_until_complete(hook_function(self, result, *args, **kwargs))
122+
loop.run_until_complete(hook_function(source_node, result, *args, **kwargs))
123123
else:
124-
hook_function(self, result, *args, **kwargs)
124+
hook_function(source_node, result, *args, **kwargs)
125125

126126
return result
127127

0 commit comments

Comments
 (0)