45 self.
__ctx__ctx = context
59 def _logInfo(self, message):
60 mevis.MLAB.log(message)
65 def _logError(self, message):
66 mevis.MLAB.logError(message)
80 field = self.
__ctx__ctx.field(fieldName)
83 self.
_logError_logError(
"Field (%s) not found in the used context!" % (fieldName))
86 fieldType = field.type
87 if (fieldType
in (
"Trigger"))
or fieldValue
is None:
89 self.
_logInfo_logInfo(
"Touched field %s" % (fieldName))
97 self.
__changeDict__changeDict.setdefault(fieldName, oldFieldValue)
100 self.
_logInfo_logInfo(
"Set field %s to value %s" % (fieldName, fieldValue))
112 field = self.
__ctx__ctx.field(fieldName)
115 self.
_logError_logError(
"Field (%s) not found in the used context!" % (fieldName))
136 field = self.
__ctx__ctx.field(fieldName)
154 if "Vector6" in field.type:
155 return field.stringValue()
156 elif "MLBase" in field.type:
157 return field.object()
163 if "Vector6" in field.type:
164 if isinstance(fieldValue, (str, bytes)):
165 field.setStringValue(fieldValue)
167 field.setVectorValue(fieldValue)
168 elif "MLBase" in field.type:
169 field.setObject(fieldValue)
171 field.value = fieldValue
Class to handle field changes and make them revertable.
def revert(self)
Revert all changes made.
def _logError(self, message)
def __init__(self, context)
The default constructor.
def enableAutoRevert(self, enable)
def _logInfo(self, message)
def __del__(self)
The default destructor.
def addField(self, fieldName, verbose=False)
Add a field and its value without setting it.
def autoRevert(self)
Revert all changes made if auto-revert is enabled.
def setFieldValue(self, fieldName, fieldValue, verbose=False)
Set the value of a field.
def setFieldValue(field, fieldValue)