Exemple #1
0
 def display(self):
     if not config.is_multisite():
         choices = [("", _("(local)"))]
     else:
         if self.enforce:
             choices = []
         else:
             choices = [("","")]
         for sitename, state in sites.states().items():
             if state["state"] == "online":
                 choices.append((sitename, config.site(sitename)["alias"]))
     html.sorted_select("site", choices)
Exemple #2
0
 def display(self):
     if not config.is_multisite():
         choices = [("", _("(local)"))]
     else:
         if self.enforce:
             choices = []
         else:
             choices = [("","")]
         for sitename, state in sites.states().items():
             if state["state"] == "online":
                 choices.append((sitename, config.site(sitename)["alias"]))
     html.sorted_select("site", choices)
Exemple #3
0
def ajax_snapin():
    # Update online state of the user (if enabled)
    userdb.update_user_access_time(config.user.id)

    snapname = html.var("name")
    if snapname:
        snapnames = [snapname]
    else:
        snapnames = html.var('names', '').split(',')

    html.plug()
    snapin_code = []
    try:
        for snapname in snapnames:
            if not config.user.may("sidesnap." + snapname):
                continue
            snapin = sidebar_snapins.get(snapname)

            # When restart snapins are about to be refreshed, only render
            # them, when the core has been restarted after their initial
            # rendering
            if not snapin.get('refresh') and snapin.get('restart'):
                since = float(html.var('since', 0))
                newest = since
                for site in sites.states().values():
                    prog_start = site.get("program_start", 0)
                    if prog_start > newest:
                        newest = prog_start
                if newest <= since:
                    # no restart
                    snapin_code.append('')
                    continue

            try:
                snapin["render"]()
            except Exception, e:
                if config.debug:
                    raise
                snapin_exception(e)
            snapin_code.append(html.drain())

        html.unplug()
        html.write('[%s]' % ','.join([
            '"%s"' % s.replace('"', '\\"').replace('\n', '')
            for s in snapin_code
        ]))
Exemple #4
0
def ajax_snapin():

    # Update online state of the user (if enabled)
    userdb.update_user_access_time(config.user.id)

    snapname = html.var("name")
    if snapname:
        snapnames = [snapname]
    else:
        snapnames = html.var('names', '').split(',')

    snapin_code = []
    for snapname in snapnames:
        if not config.user.may("sidesnap." + snapname):
            continue
        snapin = sidebar_snapins.get(snapname)

        # When restart snapins are about to be refreshed, only render
        # them, when the core has been restarted after their initial
        # rendering
        if not snapin.get('refresh') and snapin.get('restart'):
            since = float(html.var('since', 0))
            newest = since
            for site in sites.states().values():
                prog_start = site.get("program_start", 0)
                if prog_start > newest:
                    newest = prog_start
            if newest <= since:
                # no restart
                snapin_code.append('')
                continue

        with html.plugged():
            try:
                # For testing purposes uncomment:
                # raise Exception("Test")
                snapin["render"]()
            except Exception, e:
                write_snapin_exception(e)
                e_message = _("Exception during snapin refresh (snapin \'%s\')"
                              ) % snapname
                logger.error(
                    "%s %s: %s" %
                    (html.request_uri(), e_message, traceback.format_exc()))
            finally:
Exemple #5
0
def ajax_snapin():
    # Update online state of the user (if enabled)
    userdb.update_user_access_time(config.user.id)

    snapname = html.var("name")
    if snapname:
        snapnames = [snapname]
    else:
        snapnames = html.var("names", "").split(",")

    html.plug()
    snapin_code = []
    try:
        for snapname in snapnames:
            if not config.user.may("sidesnap." + snapname):
                continue
            snapin = sidebar_snapins.get(snapname)

            # When restart snapins are about to be refreshed, only render
            # them, when the core has been restarted after their initial
            # rendering
            if not snapin.get("refresh") and snapin.get("restart"):
                since = float(html.var("since", 0))
                newest = since
                for site in sites.states().values():
                    prog_start = site.get("program_start", 0)
                    if prog_start > newest:
                        newest = prog_start
                if newest <= since:
                    # no restart
                    snapin_code.append("")
                    continue

            try:
                snapin["render"]()
            except Exception, e:
                if config.debug:
                    raise
                snapin_exception(e)
            snapin_code.append(html.drain())

        html.unplug()
        html.write("[%s]" % ",".join(['"%s"' % s.replace('"', '\\"').replace("\n", "") for s in snapin_code]))