Symbol DistributedNode is not a class name.

Hello, everyone!

While trying to use DistibutedNode’s w/ Panda 1.2.3, I wasn’t able to get around this error message:

Symbol DistributedNode is not a class name.

Since “plain” DistributedObject’s worked, I looked for errors in my code and setup.

When others’ code also failed (like panda.egg’s example from Panda 1.0 in this thread https://discourse.panda3d.org/viewtopic.php?t=320) i finally looked closer at the ServerRepository source. It turns out the patch below fixes this, presumable because DistributedNode is a new-style class and DistributedObject is a classic class? Correct me on this, I’m new to python.

--- ServerRepository.py	2006-05-25 02:33:32.000000000 +0200
+++ ServerRepository.patched.py	2006-06-14 16:00:17.771086088 +0200
@@ -149,7 +149,7 @@
                         self.notify.error("Module %s does not define class %s." % (className, className))
                     classDef = getattr(classDef, className)
 
-                if type(classDef) != types.ClassType:
+                if type(classDef) != types.ClassType and type(classDef) != types.ClassType.__class__:
                     self.notify.error("Symbol %s is not a class name." % (className))
                 else:
                     dclass.setClassDef(classDef)

I can’t find that anyone else has had this problem (or bothered the board with it), and I’m not quite sure were to post this, so it goes here.

cheers

Right, this happens because DistributedNode inherits from NodePath, which is a C++ object, and this is not a python “class” but instead becomes a python “type”. It’s a subtle difference within Python, but for the most part you can treat them interchangeably.

A better patch would be to replace the line with:


if type(classDef) != types.ClassType and type(classDef) != types.TypeType:

which achieves the same thing, only a little bit clearer.

David