def _get_choices(self, context, path=""): """ Returns the list of available user settings choices for the specified context. """ choices = [TemplateChoice(choice_value=path_for(path, name)) for name in context.data_context_values] if self.recursive: # Now process all of the context's sub-contexts: gdc = context.get_data_context for name in context.data_contexts: choices.extend(self._get_choices(gdc(name), path_for(path, context.data_context_name))) return choices
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, excp: raise ITemplateDataContextError( str( excp ) )
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, excp: raise ITemplateDataContextError(str(excp))
def _get_choices(self, context, path=''): """ Returns the list of available user settings choices for the specified context. """ choices = [ TemplateChoice(choice_value=path_for(path, name)) for name in context.data_context_values ] if self.recursive: # Now process all of the context's sub-contexts: gdc = context.get_data_context for name in context.data_contexts: choices.extend( self._get_choices( gdc(name), path_for(path, context.data_context_name))) return choices
def _get_choices(self, context, path=''): """ Returns all of the valid TemplateChoices for this item. """ choices = [] gdc = context.get_data_context for name in context.data_contexts: next_path = path_for(path, name) choices.append(TemplateChoice(choice_value=next_path)) choices.extend(self._get_choices(gdc(name), next_path)) return choices
def _get_choices ( self, context, path = '' ): """ Returns all of the valid TemplateChoices for this item. """ choices = [] gdc = context.get_data_context for name in context.data_contexts: next_path = path_for( path, name ) choices.append( TemplateChoice( choice_value = next_path ) ) choices.extend( self._get_choices( gdc( name ), next_path ) ) return choices
def _add_values ( self, input_context, values, path = '' ): """ Adds all of the matching values in the specified *input_context* to the specified *values* dictionary. """ # Filter each name/value in the current input context to see if it # should be added to the output values: filter = self.filter gdcv = input_context.get_data_context_value for name in input_context.data_context_values: value = gdcv( name ) if self.filter( name, value ): values[ path_for( path, name ) ] = value
def _add_context ( self, input_context, values, path = '' ): """ Adds all of the matching values in the specified *input_context* to the specified *output_context*, and then applies itself recursively to all contexts contained in the specified *input_context*. """ # Add all of the filtered values in the specified input context: self._add_values( input_context, values, path ) # Now process all of the input context's sub-contexts: gdc = input_context.get_data_context for name in input_context.data_contexts: self._add_context( gdc( name ), values, path_for( path, input_context.data_context_name ) )