Exemple #1
0
    def _default(self, widget, chrome=False, live=False, source=False, module=False, iframe=False, **kw):
        """ Display a single widget.

        :chrome: Display in a Moksha Container
        :live: Inject a socket for live widgets
        :source: Display the source code for this widget
        """
        options = {}
        options.update(kw)
        w = moksha._widgets.get(widget)
        if not w:
            raise WidgetNotFound(widget)
        if (chrome and getattr(w["widget"], "visible", True)) or source:
            tmpl_context.widget = container
            options["content"] = w["widget"]
            options["content_args"] = kw
            options["title"] = w["name"]
            options["id"] = widget + "_container"

            # Allow widgets to specify container options
            container_options = getattr(w["widget"], "container_options", None)
            if container_options:
                options.update(container_options)
        else:
            tmpl_context.widget = w["widget"]
        if live:
            tmpl_context.moksha_socket = moksha.get_widget("moksha_socket")
        if source:
            options["content"] = iframe_widget(url="/widgets/code/" + source + "?module=%s" % module, height="425px")
            options["id"] += source + "_source"
            options["view_source"] = False
        if iframe:
            options["content"] = iframe_widget(url="/widgets/" + widget + "?" + urlencode(kw), height="425px")
            options["view_source"] = False
        return dict(options=options)
Exemple #2
0
 def update_params(self, d):
     super(SourceCodeWidget, self).update_params(d)
     title = d.widget.__class__.__name__
     if not d.source:
         try:
             d.widget = moksha.get_widget(d.widget)
         except Exception, e:
             d.widget = namedAny(d.widget)
         if d.module:
             obj = namedAny(d.widget.__module__)
         else:
             obj = d.widget.__class__
         d.source = inspect.getsource(obj)
Exemple #3
0
 def update_params(self, d):
     super(SourceCodeWidget, self).update_params(d)
     title = d.widget.__class__.__name__
     if not d.source:
         try:
             d.widget = moksha.get_widget(d.widget)
         except Exception, e:
             d.widget = namedAny(d.widget)
         if d.module:
             obj = namedAny(d.widget.__module__)
         else:
             obj = d.widget.__class__
         d.source = inspect.getsource(obj)
Exemple #4
0
    def _default(self,
                 widget,
                 chrome=False,
                 live=False,
                 source=False,
                 module=False,
                 iframe=False,
                 **kw):
        """ Display a single widget.

        :chrome: Display in a Moksha Container
        :live: Inject a socket for live widgets
        :source: Display the source code for this widget
        """
        options = {}
        options.update(kw)
        w = moksha._widgets.get(widget)
        if not w:
            raise WidgetNotFound(widget)
        if (chrome and getattr(w['widget'], 'visible', True)) or source:
            tmpl_context.widget = container
            options['content'] = w['widget']
            options['content_args'] = kw
            options['title'] = w['name']
            options['id'] = widget + '_container'

            # Allow widgets to specify container options
            container_options = getattr(w['widget'], 'container_options', None)
            if container_options:
                options.update(container_options)
        else:
            tmpl_context.widget = w['widget']
        if live:
            tmpl_context.moksha_socket = moksha.get_widget('moksha_socket')
        if source:
            options['content'] = iframe_widget(url='/widgets/code/' + source +
                                               '?module=%s' % module,
                                               height='425px')
            options['id'] += source + '_source'
            options['view_source'] = False
        if iframe:
            options['content'] = iframe_widget(url='/widgets/' + widget + '?' +
                                               urlencode(kw),
                                               height='425px')
            options['view_source'] = False
        return dict(options=options)
Exemple #5
0
 def livewidget(self, *args, **kwargs):
     tmpl_context.widget = moksha.get_widget('live')
     tmpl_context.moksha_socket = moksha.get_widget('moksha_socket')
     return dict(options={})
Exemple #6
0
 def livewidget(self, *args, **kwargs):
     tmpl_context.widget = moksha.get_widget('live')
     tmpl_context.moksha_socket = moksha.get_widget('moksha_socket')
     return dict(options={})