4 usage: %(progname)s [args] 7 import os, sys, string, time, getopt, re
9 import neo_cgi, neo_util, neo_cs
11 from pyclearsilver
import CSPage
12 from pyclearsilver
import odb
25 self.
db = db_webui.initSchema()
28 webutil.grabTopics(hdf, [])
30 hdf.setValue(
"CGI.now", str(time.time()))
31 webutil.set_tabs(hdf, [
"apps"])
33 apps = self.db.apps.fetchAllRows()
34 prefix =
"CGI.cur.apps" 38 aprefix = prefix +
".%d" % i
39 app.hdfExport(aprefix, hdf)
40 app.fetchApp(aprefix, hdf)
43 apps = webutil.list_apps()
45 user_record = self.authdb.users.lookup(self.
username)
46 user_apps = user_record.favorite_apps_list()
48 taskids = [db_webui.path2taskid(app)
for app
in apps]
51 for user_app
in user_apps:
52 if user_app
in taskids:
53 actual_apps.append(user_app)
54 categories[
"Favorites"] = actual_apps
58 taskid = db_webui.path2taskid(appfn)
60 prefix =
"CGI.cur.available_apps.%s" % taskid
62 doc = _app.load_yaml()
64 iapp = self.db.apps.lookup(taskid=taskid)
69 robot_type = config.get_robot_type()
70 if "robot" in doc
and robot_type != doc[
"robot"]:
74 category_apps = categories[doc.get(
"category",
"Other")]
77 categories[doc.get(
"category",
"Other")] = category_apps
78 category_apps.append(taskid)
80 hdf.setValue(prefix +
".taskid", taskid)
81 for key, val
in doc.items():
83 for i
in range(0,len(val)):
84 hdf.setValue(prefix +
"." + key +
"." + str(i), val[i])
86 hdf.setValue(prefix +
"." + key, val)
88 hdf.setValue(prefix +
"." + key,
'')
90 if user_record.is_favorite_app(taskid):
91 hdf.setValue(prefix +
".favorite",
"1")
93 def compare_categories(a, b):
94 if a[0] ==
"Favorites":
96 if b[0] ==
"Favorites":
101 prefix =
"CGI.cur.categories" 103 for category, apps
in sorted(categories.items(), compare_categories):
104 hdf.setValue(prefix +
".%d" % i, category)
107 hdf.setValue(prefix +
".%d.apps.%d" % (i, j), app)
112 return MyPage(context, pagename=
"apps", nologin=
False)
115 context = CSPage.Context()
118 if __name__ ==
"__main__":