예제 #1
0
파일: base.py 프로젝트: pombredanne/djpcms
def iterable_for_widget(data):
    if isinstance(data, dict):
        return iteritems(data)
    elif not isinstance(data, Widget) and hasattr(data,'__iter__') and\
         not is_string_or_native_string(data):
        return data
    else:
        return (data,)
예제 #2
0
def iterable_for_widget(data):
    if isinstance(data, dict):
        return iteritems(data)
    elif not isinstance(data, Widget) and hasattr(data,'__iter__') and\
         not is_string_or_native_string(data):
        return data
    else:
        return (data, )
예제 #3
0
파일: base.py 프로젝트: pombredanne/djpcms
    def add(self, *widgets):
        '''Add children *widgets* to this class:`WidgetMaker`.
*widgets* must be class:`WidgetMaker`. It returns ``self`` for concatenation.'''
        for widget in widgets:
            if isinstance(widget, WidgetMaker):
                key = widget.key or len(self.children)
                self.children[key] = widget
                for k in self.internal:
                    if k not in widget.internal:
                        widget.internal[k] = self.internal[k]
            elif is_string_or_native_string(widget):
                self.children[len(self.children)] = widget
        return self
예제 #4
0
    def add(self, *widgets):
        '''Add children *widgets* to this class:`WidgetMaker`.
*widgets* must be class:`WidgetMaker`. It returns ``self`` for concatenation.'''
        for widget in widgets:
            if isinstance(widget, WidgetMaker):
                key = widget.key or len(self.children)
                self.children[key] = widget
                for k in self.internal:
                    if k not in widget.internal:
                        widget.internal[k] = self.internal[k]
            elif is_string_or_native_string(widget):
                self.children[len(self.children)] = widget
        return self