##// END OF EJS Templates
allow multiple instances of magics...
MinRK -
Show More
@@ -469,13 +469,19 b' class Magics(object):'
469 # grab. Only now, that the instance exists, can we create the proper
469 # grab. Only now, that the instance exists, can we create the proper
470 # mapping to bound methods. So we read the info off the original names
470 # mapping to bound methods. So we read the info off the original names
471 # table and replace each method name by the actual bound method.
471 # table and replace each method name by the actual bound method.
472 # But we mustn't clobber the *class* mapping, in case of multiple instances.
473 class_magics = self.magics
474 self.magics = {}
472 for mtype in magic_kinds:
475 for mtype in magic_kinds:
473 tab = self.magics[mtype]
476 tab = self.magics[mtype] = {}
474 # must explicitly use keys, as we're mutating this puppy
477 cls_tab = class_magics[mtype]
475 for magic_name in tab.keys():
478 for magic_name, meth_name in cls_tab.iteritems():
476 meth_name = tab[magic_name]
477 if isinstance(meth_name, basestring):
479 if isinstance(meth_name, basestring):
480 # it's a method name, grab it
478 tab[magic_name] = getattr(self, meth_name)
481 tab[magic_name] = getattr(self, meth_name)
482 else:
483 # it's the real thing
484 tab[magic_name] = meth_name
479
485
480 def arg_err(self,func):
486 def arg_err(self,func):
481 """Print docstring if incorrect arguments were passed"""
487 """Print docstring if incorrect arguments were passed"""
General Comments 0
You need to be logged in to leave comments. Login now