mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-25 18:08:38 -06:00
Introduce BaseScript for extending Script without creating a new executable script
This commit is contained in:
parent
eb6e95ae9b
commit
a4936ad0dd
@ -21,6 +21,7 @@ from .forms import ScriptForm
|
|||||||
|
|
||||||
|
|
||||||
__all__ = [
|
__all__ = [
|
||||||
|
'BaseScript',
|
||||||
'BooleanVar',
|
'BooleanVar',
|
||||||
'FileVar',
|
'FileVar',
|
||||||
'IntegerVar',
|
'IntegerVar',
|
||||||
@ -164,9 +165,10 @@ class IPNetworkVar(ScriptVariable):
|
|||||||
# Scripts
|
# Scripts
|
||||||
#
|
#
|
||||||
|
|
||||||
class Script:
|
class BaseScript:
|
||||||
"""
|
"""
|
||||||
Custom scripts inherit this object.
|
Base model for custom scripts. User classes should inherit from this model if they want to extend Script
|
||||||
|
functionality for use in other subclasses.
|
||||||
"""
|
"""
|
||||||
class Meta:
|
class Meta:
|
||||||
pass
|
pass
|
||||||
@ -250,6 +252,13 @@ class Script:
|
|||||||
return data
|
return data
|
||||||
|
|
||||||
|
|
||||||
|
class Script(BaseScript):
|
||||||
|
"""
|
||||||
|
Classes which inherit this model will appear in the list of available scripts.
|
||||||
|
"""
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Functions
|
# Functions
|
||||||
#
|
#
|
||||||
@ -258,7 +267,10 @@ def is_script(obj):
|
|||||||
"""
|
"""
|
||||||
Returns True if the object is a Script.
|
Returns True if the object is a Script.
|
||||||
"""
|
"""
|
||||||
return obj in Script.__subclasses__()
|
try:
|
||||||
|
return issubclass(obj, Script) and obj != Script
|
||||||
|
except TypeError:
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
def is_variable(obj):
|
def is_variable(obj):
|
||||||
|
Loading…
Reference in New Issue
Block a user