params.py
Go to the documentation of this file.
00001 #! /usr/bin/env python
00002 
00003 """
00004 usage: %(progname)s [args]
00005 """
00006 
00007 import nstart
00008 
00009 import os, sys, string, time, getopt, re
00010 from pyclearsilver.log import *
00011 
00012 import neo_cgi, neo_util, neo_cs
00013 
00014 from pyclearsilver import CSPage
00015 from pyclearsilver import odb
00016 
00017 import MBPage
00018 import db_webui
00019 
00020 import roslib
00021 import roslib.scriptutil
00022 
00023 import webutil
00024 
00025 from roslib.names import ns_join, get_ros_namespace, make_caller_id, make_global_ns, GLOBALNS
00026 
00027 
00028 def _get_caller_id():
00029     return make_caller_id('rosparam-%s'%os.getpid())
00030 
00031 class MyPage(MBPage.MBPage):
00032   def setup(self, hdf):
00033     self.master = roslib.scriptutil.get_master()
00034     
00035   def display(self, hdf):
00036     webutil.grabTopics(hdf, [])
00037     webutil.set_tabs(hdf, ["status", "params"])    
00038 
00039     _c, _t, params = self.master.getParam(_get_caller_id(), "/")
00040     self.flatten(hdf, params, path="CGI.cur.params.")
00041     
00042   def flatten(self, hdf, params, path=""):
00043     for k,v in params.items():
00044       _path=path + k
00045       if type(v) == type({}):
00046         self.flatten(hdf, v, _path + ".")
00047       else:
00048         hdf.setValue(_path, str(v)[:128])
00049         
00050 
00051   def Action_Edit(self, hdf):
00052     key = hdf.getValue("Query.element_id", "")
00053     value = hdf.getValue("Query.update_value", "")
00054     delete = hdf.getValue("Query.delete", "")
00055     hdf.setValue("CGI.result", hdf.getValue("Query.original_html", "ERROR"))
00056         
00057     if delete == "1":
00058       results = self.master.deleteParam(_get_caller_id(), key)
00059       if results[0] == 1:
00060         hdf.setValue("CGI.result", "OK")
00061       else:
00062         hdf.setValue("CGI.result", "")
00063     elif key != "" and value != "":
00064       results = self.master.setParam(_get_caller_id(), key, value)
00065       if results[0] == 1:
00066         hdf.setValue("CGI.result", value)
00067     
00068     hdf.setValue("Content", "ajax_result.cs")
00069     
00070   def Action_New(self, hdf):
00071     key = hdf.getValue("Query.key", "")
00072     value = hdf.getValue("Query.value", "")
00073 
00074     if key != "" and value != "":
00075       results = self.master.setParam(_get_caller_id(), key, value)
00076       if results[0] == 1:
00077         hdf.setValue("CGI.result", value)
00078         self.redirectUri("params.py")
00079     
00080 
00081 def run(context):
00082   return MyPage(context, pagename="params", nologin=False)
00083 
00084 def main():
00085   context = CSPage.Context()
00086   run(context).start()
00087 
00088 if __name__ == "__main__":
00089   main()


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