You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

36 lines
964 B

24 years ago
24 years ago
  1. from idlelib import rpc
  2. def remote_object_tree_item(item):
  3. wrapper = WrappedObjectTreeItem(item)
  4. oid = id(wrapper)
  5. rpc.objecttable[oid] = wrapper
  6. return oid
  7. class WrappedObjectTreeItem:
  8. # Lives in PYTHON subprocess
  9. def __init__(self, item):
  10. self.__item = item
  11. def __getattr__(self, name):
  12. value = getattr(self.__item, name)
  13. return value
  14. def _GetSubList(self):
  15. sub_list = self.__item._GetSubList()
  16. return list(map(remote_object_tree_item, sub_list))
  17. class StubObjectTreeItem:
  18. # Lives in IDLE process
  19. def __init__(self, sockio, oid):
  20. self.sockio = sockio
  21. self.oid = oid
  22. def __getattr__(self, name):
  23. value = rpc.MethodProxy(self.sockio, self.oid, name)
  24. return value
  25. def _GetSubList(self):
  26. sub_list = self.sockio.remotecall(self.oid, "_GetSubList", (), {})
  27. return [StubObjectTreeItem(self.sockio, oid) for oid in sub_list]