1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
|
""" Context adapter for trait dictionaries. """
# Enthought library imports.
from enthought.traits.api import Dict, Property, Str
# Local imports.
from dict_context_adapter import DictContextAdapter
class TraitDictContextAdapter(DictContextAdapter):
""" Context adapter for trait dictionaries. """
#### 'Context' interface ##################################################
# The name of the context within its own namespace.
namespace_name = Property(Str)
#### 'ContextAdapter' interface ###########################################
# The object that we are adapting.
adaptee = Dict
#### 'TraitDictContextAdapter' interface ##################################
# The name of the object's trait that provides the dictionary.
trait_name = Str
###########################################################################
# 'Context' interface.
###########################################################################
def _get_namespace_name(self):
""" Returns the name of the context within its own namespace. """
return self.context.namespace_name + '/' + self.trait_name
#### EOF ######################################################################
|