aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2014-10-31 14:49:15 -0400
committerJesse Luehrs <doy@tozt.net>2014-10-31 14:49:15 -0400
commit1f2051414ac58454acd0e121527f5aa86f4de806 (patch)
tree5bc0ca53caf7d15419e7efeb565161982add1c19
parent842471171b898c3dcbde326f6c41df9e953f993c (diff)
downloadpython-mop-1f2051414ac58454acd0e121527f5aa86f4de806.tar.gz
python-mop-1f2051414ac58454acd0e121527f5aa86f4de806.zip
don't use the class name as the key
it's not necessarily unique
-rw-r--r--mop/__init__.py16
1 files changed, 10 insertions, 6 deletions
diff --git a/mop/__init__.py b/mop/__init__.py
index 4d806d3..e8c95eb 100644
--- a/mop/__init__.py
+++ b/mop/__init__.py
@@ -20,11 +20,13 @@ def execute_method(method, invocant, args, kwargs):
# necessary, but this allows us to pass python-level method calls through to
# our mop infrastructure
UNDERLYING_CLASSES = {}
-def python_class_for(c):
- name = c.slots["name"]
- if name not in UNDERLYING_CLASSES.keys():
- UNDERLYING_CLASSES[name] = type(name, (object,), {})
- return UNDERLYING_CLASSES[name]
+def python_class_for(c, name=None):
+ key = c.__hash__()
+ if key not in UNDERLYING_CLASSES.keys():
+ if name is None:
+ name = c.get_name()
+ UNDERLYING_CLASSES[key] = type(name, (object,), {})
+ return UNDERLYING_CLASSES[key]
def python_install_method(c, name, method):
setattr(
@@ -36,7 +38,7 @@ def python_install_method(c, name, method):
# and finally, bootstrap helpers to create hardcoded structures during the
# bootstrap (which we will inflate into real structures at the end)
def bootstrap_create_class(name, superclass):
- return BasicInstance(
+ c = BasicInstance(
globals().get("Class"),
{
"name": name,
@@ -45,6 +47,8 @@ def bootstrap_create_class(name, superclass):
"attributes": {},
},
)
+ python_class_for(c, name)
+ return c
def bootstrap_create_method(name, body):
return BasicInstance(