File: trait_dict_context_adapter.py

package info (click to toggle)
enthought-traits-ui 2.0.5-1
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 15,204 kB
  • ctags: 9,623
  • sloc: python: 45,547; sh: 32; makefile: 19
file content (38 lines) | stat: -rw-r--r-- 1,249 bytes parent folder | download | duplicates (2)
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 ######################################################################