Proxy class for a FeaturePython
Server instance.
More...
Public Member Functions | |
def | __init__ (self, fp) |
Initialization method for ServerProxy. More... | |
def | onDocumentRestored (self, fp) |
Method called when document is restored to make sure everything is as it was. More... | |
def | onDocumentClosed (self) |
def | setProperties (self, fp) |
Method to set properties during initialization or document restoration. More... | |
def | __getstate__ (self) |
Necessary method to avoid errors when trying to save unserializable objects. More... | |
def | __setstate__ (self, state) |
Necessary method to avoid errors when trying to restore unserializable objects. More... | |
Static Public Attributes | |
cmd_server = None | |
A CommandServer instance to handle external commands. More... | |
Proxy class for a FeaturePython
Server instance.
A ServerProxy instance adds properties to a FeaturePython
Server instance and responds to theirs changes. It provides a communication. CommandServer cmd_server
when Running
is set to True by double-clicking on it in the Tree View or right clicking and selecting Connect Server option from context menu. It closes the cmd_server
when Running
is set to False or an AnimateDocumentObserver
detects that a document with Server instance is closing
Because communication.CommandServer cmd_server
occupies a Port
at selected Address
, you cannot have duplicit Servers running simultaneously in a file, a FreeCAD window nor on one computer.
To connect this Proxy
object to a FeaturePython
Server do:
def Server.ServerProxy.__init__ | ( | self, | |
fp | |||
) |
Initialization method for ServerProxy.
A class instance is created and made a Proxy
for a generic FeaturePython
Server object. During initialization number of properties are specified and preset.
fp | A barebone FeaturePython Server object to be extended. |
def Server.ServerProxy.__getstate__ | ( | self | ) |
Necessary method to avoid errors when trying to save unserializable objects.
This method is used by JSON to serialize unserializable objects during autosave. Without this an Error would rise when JSON would try to do that itself.
We need this for unserializable cmd_server
attribute, but we don't serialize them, because it's enough to reset it when object is restored.
def Server.ServerProxy.__setstate__ | ( | self, | |
state | |||
) |
Necessary method to avoid errors when trying to restore unserializable objects.
This method is used during a document restoration. We need this for unserializable cmd_server
attribute, but we do not restore it, because it's enough to reset them from saved parameters.
def Server.ServerProxy.onDocumentRestored | ( | self, | |
fp | |||
) |
Method called when document is restored to make sure everything is as it was.
Reinitialization it creates properties and sets them to default values, if they were not restored automatically. It restarts a cmd_server if it was running when document was closed. Properties of connected ViewObject
are also recreated and reset if necessary.
fp | A restored FeaturePython Server object. |
def Server.ServerProxy.setProperties | ( | self, | |
fp | |||
) |
Method to set properties during initialization or document restoration.
The properties are set if they are not already present. Constrained properties have their boundaries reset even if present, because constrains are not saved. Also cmd_server
is restarted if it was running previously and an AnimateDocumentObserver
is recreated.
fp | A restored or barebone FeaturePython Server object. |
Definition at line 131 of file Server.py.
|
static |