예제 #1
0
    def get_data_context(self, name):
        """ Returns the **ITemplateDataContext** value associated with the
            specified *name*. Raises **ITemplateDataContextError** if *name* is
            not defined as a data context in the context.

            Parameters
            ----------
            name : A string specifying the name of the data context to be
                returned.

            Returns
            -------
            The **ITemplateDataContext** associated with *name* in the context.

            Raises **ITemplateDataContextError** if *name* is not associated
            with a data context in the context.
        """
        try:
            if name in self.data_contexts:
                bdca = IContextAdapter(self.adaptee[name])
                bdca.data_context_path = path_for(self.data_context_path,
                                                  self.data_context_name)
                return bdca

            raise ITemplateDataContextError("No context named '%s' found." %
                                            name)
        except Exception as excp:
            raise ITemplateDataContextError(str(excp))
예제 #2
0
    def get_data_context_value(self, name):
        """ Returns the data value with the specified *name*. Raises a
            **ITemplateDataContextError** if *name* is not defined as a data
            value in the context.

            Parameters
            ----------
            name : A string specifying the name of the context data value to
                be returned.

            Returns
            -------
            The data value associated with *name* in the context. The type of
            the data is application dependent.

            Raises **ITemplateDataContextError** if *name* is not associated
            with a data value in the context.
        """
        try:
            if name in self.data_context_values:
                return self.adaptee[name]

            raise ITemplateDataContextError("No value named '%s' found." %
                                            name)
        except Exception as excp:
            raise ITemplateDataContextError(str(excp))
예제 #3
0
    def get_data_context(self, name):
        """ Returns the **ITemplateDataContext** value associated with the
            specified *name*. Raises **ITemplateDataContextError** if *name* is
            not defined as a data context in the context.

            Parameters
            ----------
            name : A string specifying the name of the data context to be
                returned.

            Returns
            -------
            The **ITemplateDataContext** associated with *name* in the context.

            Raises **ITemplateDataContextError** if *name* is not associated
            with a data context in the context.
        """
        try:
            return self.context[name]
        except:
            raise ITemplateDataContextError("Context '%s' not found." % name)
예제 #4
0
    def get_data_context_value(self, name):
        """ Returns the data value with the specified *name*. Raises a
            **ITemplateDataContextError** if *name* is not defined as a data
            value in the context.

            Parameters
            ----------
            name : A string specifying the name of the context data value to
                be returned.

            Returns
            -------
            The data value associated with *name* in the context. The type of
            the data is application dependent.

            Raises **ITemplateDataContextError** if *name* is not associated
            with a data value in the context.
        """
        try:
            return self.values[name]
        except:
            raise ITemplateDataContextError("Value '%s' not found." % name)