Skip to content

Commit

Permalink
Mark non-remote ManagedObject and DataObject methods
Browse files Browse the repository at this point in the history
"'Private' instance variables that cannot be accessed except from inside an object don’t exist in Python. However, there is a convention that is followed by most Python code: a name prefixed with an underscore (e.g. _spam) should be treated as a non-public part of the API (whether it is a function, a method or a data member). It should be considered an implementation detail and subject to change without notice." Ref. https://docs.python.org/3/tutorial/classes.html#private-variables

This change adds comment before the non-remote methods available for ManagedObject and DataObject that explains that those methods are not private but this is the way non-remote methods are marked in the VMODL1 context.
  • Loading branch information
ddraganov committed Apr 5, 2024
1 parent e43a287 commit 472bdfc
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions pyVmomi/VmomiSupport.py
Original file line number Diff line number Diff line change
Expand Up @@ -400,19 +400,28 @@ def _InvokeAccessor(info, self):

_InvokeAccessor = staticmethod(_InvokeAccessor)

# In contrast with the Python convention for "private" methods,
# the ManagedObject and DataObject method names beginning with
# an underscore denote public, officially supported system methods.
# The execution of these methods does not involve a remote call.

# Get the ID of a managed object
# Public non-remote method. Officially supported.
def _GetMoId(self):
return self._moId

# Get the serverGuid of a managed object
# Public non-remote method. Officially supported.
def _GetServerGuid(self):
return self._serverGuid

# Get the stub of a managed object
# Public non-remote method. Officially supported.
def _GetStub(self):
return self._stub

# Get a list of all properties of this type and base types
# Public non-remote method. Officially supported.
#
# @param cls The managed object type
@classmethod
Expand All @@ -432,6 +441,7 @@ def _GetPropertyList(cls, includeBaseClassProps=True):
return result

# Get a list of all methods of this type and base types
# Public non-remote method. Officially supported.
#
# @param cls The managed object type
@classmethod
Expand All @@ -449,6 +459,7 @@ def _GetMethodList(cls):
return result

# Lookup a method for a given managed object type
# Public non-remote method. Officially supported.
#
# @param type the type
# @param name the name of the property
Expand Down Expand Up @@ -536,7 +547,13 @@ def __init__(self, **kwargs):
for (k, v) in list(kwargs.items()):
setattr(self, k, v)

# In contrast with the Python convention for "private" methods,
# the ManagedObject and DataObject method names beginning with
# an underscore denote public, officially supported system methods.
# The execution of these methods does not involve a remote call.

# Get a list of all properties of this type and base types
# Public non-remote method. Officially supported.
#
# @param cls the data object type
@classmethod
Expand Down

0 comments on commit 472bdfc

Please sign in to comment.