1#-------------------------------------------------------------------------------
2#
3#  Defines the ITemplateDataContext interface for accessing a named collection
4#  of data that can be bound to a templatized object when converting it to a
5#  'live' set of objects.
6#
7#  Written by: David C. Morrill
8#
9#  Date: 07/26/2007
10#
11#  (c) Copyright 2007 by Enthought, Inc.
12#
13#-------------------------------------------------------------------------------
14
15""" Defines the ITemplateDataContext interface for accessing a named collection
16    of data that can be bound to a templatized object when converting it to a
17    'live' set of objects.
18"""
19
20#-------------------------------------------------------------------------------
21#  Imports:
22#-------------------------------------------------------------------------------
23
24from traits.api\
25    import Interface, List, Str
26
27#-------------------------------------------------------------------------------
28#  'ITemplateDataContext' interface:
29#-------------------------------------------------------------------------------
30
31class ITemplateDataContext ( Interface ):
32    """ Defines the ITemplateDataContext interface for accessing a named
33        collection of data that can be bound to a templatized object when
34        converting it to a 'live' set of objects.
35    """
36
37    # The path to this data context (does not include the 'data_context_name'):
38    data_context_path = Str
39
40    # The name of the data context:
41    data_context_name = Str
42
43    # A list of the names of the data values in this context:
44    data_context_values = List( Str )
45
46    # The list of the names of the sub-contexts of this context:
47    data_contexts = List( Str )
48
49    def get_data_context_value ( self, name ):
50        """ Returns the data value with the specified *name*. Raises a
51            **ITemplateDataContextError** if *name* is not defined as a data
52            value in the context.
53
54            Parameters
55            ----------
56            name : A string specifying the name of the context data value to
57                be returned.
58
59            Returns
60            -------
61            The data value associated with *name* in the context. The type of
62            the data is application dependent.
63
64            Raises **ITemplateDataContextError** if *name* is not associated
65            with a data value in the context.
66        """
67
68    def get_data_context ( self, name ):
69        """ Returns the **ITemplateDataContext** value associated with the
70            specified *name*. Raises **ITemplateDataContextError** if *name* is
71            not defined as a data context in the context.
72
73            Parameters
74            ----------
75            name : A string specifying the name of the data context to be
76                returned.
77
78            Returns
79            -------
80            The **ITemplateDataContext** associated with *name* in the context.
81
82            Raises **ITemplateDataContextError** if *name* is not associated
83            with a data context in the context.
84        """
85
86#-------------------------------------------------------------------------------
87#  'ITemplateDataContextError' exception:
88#-------------------------------------------------------------------------------
89
90class ITemplateDataContextError ( Exception ):
91    """ The exception class associated with the **ITemplateDataContext**
92        interface.
93    """
94
95