appinfo.py
Go to the documentation of this file.
00001 #! /usr/bin/env python
00002 
00003 """
00004 usage: %(progname)s [args]
00005 """
00006 
00007 import os, sys, string, time, getopt, re
00008 from pyclearsilver.log import *
00009 
00010 import neo_cgi, neo_util, neo_cs
00011 
00012 from pyclearsilver import CSPage
00013 from pyclearsilver import odb
00014 from launchman import app
00015 
00016 import MBPage
00017 import db_webui
00018 import webutil
00019 
00020 class MyPage(MBPage.MBPage):
00021   def setup(self, hdf):
00022     self.db = db_webui.initSchema()
00023 
00024   def display(self, hdf):
00025     webutil.set_tabs(hdf, ["apps", "appinfo"])
00026     webutil.grabTopics(hdf, [])
00027     taskid = hdf.getValue("Query.taskid", "")
00028     doc = app.App(taskid).load_yaml()
00029   
00030     prefix = "CGI.cur.app"
00031     hdf.setValue(prefix + "." + "taskid", taskid)
00032     for key, val in doc.items():
00033       if type(val) is list:
00034         for i in range(0,len(val)):
00035           hdf.setValue(prefix + "." + key + "." + str(i), val[i])
00036       elif val is not None:
00037         hdf.setValue(prefix + "." + key, val)
00038       else:
00039         hdf.setValue(prefix + "." + key, '')
00040 
00041     # for favorite apps
00042     user_record = self.authdb.users.lookup(self.username)
00043     hdf.setValue("CGI.cur.user.favorite_apps", user_record.favorite_apps)
00044 
00045     if user_record.is_favorite_app(taskid):
00046       hdf.setValue("CGI.cur.app.favorite", "1")
00047 
00048   def Action_Favorites(self, hdf):
00049     taskid = hdf.getValue("Query.taskid", "")
00050     doc = app.App(taskid).load_yaml()
00051   
00052     prefix = "CGI.cur.app"
00053     hdf.setValue(prefix + "." + "taskid", taskid)
00054 
00055     # for favorite apps
00056     user_record = self.authdb.users.lookup(self.username)
00057     if hdf.getValue("Query.set_favorite", "") == "1":
00058       user_record.add_favorite_app(taskid)
00059     elif hdf.getValue("Query.set_favorite", "") == "0":
00060       user_record.remove_favorite_app(taskid)
00061       
00062     if user_record.is_favorite_app(taskid):
00063       hdf.setValue("CGI.cur.favorite", "1")
00064     
00065     hdf.setValue("Content", "appinfo_favorites.cs")
00066       
00067 def run(context):
00068   return MyPage(context, pagename="appinfo", nologin=False)
00069 
00070 def main():
00071   context = CSPage.Context()
00072   run(context).start()
00073 
00074 if __name__ == "__main__":
00075   main()


webui
Author(s): Scott Hassan/hassan@willowgarage.com
autogenerated on Sat Dec 28 2013 17:47:58