コード例 #1
0
ファイル: index.py プロジェクト: black0592/xnote
 def GET(self, name=""):
     display_name = xutils.unquote(name)
     name = xutils.get_real_path(display_name)
     if not name.endswith(".py"):
         name += ".py"
     script_name = "plugins/" + name
     if not os.path.exists(os.path.join(xconfig.PLUGINS_DIR, name)):
         error = "file `%s` not found" % script_name
         return xtemplate.render("error.html", error=error)
     try:
         try:
             cacheutil.zadd("plugins.history", time.time(),
                            os.path.splitext(display_name)[0])
         except TypeError:
             cacheutil.delete("plugins.history")
             cacheutil.zadd("plugins.history", time.time(),
                            os.path.splitext(display_name)[0])
         vars = dict()
         vars["script_name"] = script_name
         xutils.load_script(script_name, vars)
         main_class = vars.get("Main")
         if main_class != None:
             return main_class().render()
         else:
             return xtemplate.render("error.html",
                                     error="class `Main` not found!")
     except:
         error = xutils.print_exc()
         return xtemplate.render("error.html", error=error)
コード例 #2
0
ファイル: plugins.py プロジェクト: Kevin-CodeHub/xnote
def log_plugin_visit(name):
    try:
        fname = xutils.unquote(name)
        cacheutil.zadd("plugins.history", time.time(), fname)
    except TypeError:
        cacheutil.delete("plugins.history")
        cacheutil.zadd("plugins.history", time.time(), fname)
コード例 #3
0
ファイル: test_xutils.py プロジェクト: Cicin411/xnote
 def test_cache_set_delete(self):
     cacheutil.set("name", 123)
     self.assertEqual(123, cacheutil.get("name"))
     cacheutil.delete("name")
     self.assertEqual(None, cacheutil.get("name"))