1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

Closes #4941: commit argument is now required argument in a custom script's run() method

This commit is contained in:
Jeremy Stretch
2020-08-21 11:06:36 -04:00
parent e02590ac96
commit 2339fe22ae
3 changed files with 9 additions and 15 deletions

View File

@ -1 +1 @@
version-2.9.md
version-2.10.md

View File

@ -0,0 +1,7 @@
# NetBox v2.10
## v2.10-beta1 (FUTURE)
### Other Changes
* [#4941](https://github.com/netbox-community/netbox/issues/4941) - `commit` argument is now required argument in a custom script's `run()` method

View File

@ -428,24 +428,11 @@ def run_script(data, request, commit=True, *args, **kwargs):
# Add the current request as a property of the script
script.request = request
# TODO: Drop backward-compatibility for absent 'commit' argument in v2.10
# Determine whether the script accepts a 'commit' argument (this was introduced in v2.7.8)
kwargs = {
'data': data
}
if 'commit' in inspect.signature(script.run).parameters:
kwargs['commit'] = commit
else:
warnings.warn(
f"The run() method of script {script} should support a 'commit' argument. This will be required beginning "
f"with NetBox v2.10."
)
with change_logging(request):
try:
with transaction.atomic():
script.output = script.run(**kwargs)
script.output = script.run(data=data, commit=commit)
job_result.set_status(JobResultStatusChoices.STATUS_COMPLETED)
if not commit: