active.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 
00003 import nstart
00004 import config
00005 import os, sys, string, time
00006 
00007 from pyclearsilver.log import *
00008         
00009 from pyclearsilver.CSPage import Context
00010 import neo_cgi, neo_cs, neo_util
00011 from MBPage import MBPage
00012 
00013 class ActivePage(MBPage):
00014     def setup(self, hdf):
00015       self.requestURI = hdf.getValue("Query.request", "")
00016       if not self.requestURI:
00017         self.requestURI = self.default_app_path()
00018 
00019     def display(self, hdf):
00020       pass
00021 
00022     def __del__(self):
00023       if self.authdb:
00024         self.authdb.close()
00025         self.authdb = None
00026 
00027     def Action_Display(self, hdf):
00028       if hdf.getValue("Query.dismiss_active_warning", "") == "1":
00029         user_record = self.authdb.users.lookup(self.username)
00030         user_record.dismiss_notice("active_warning")
00031       self.display(hdf)
00032 
00033     def Action_MakeActive(self, hdf):
00034       # if one of the following are true, make the user active
00035       if (not self.get_active_user()) or self.is_active_user() or hdf.getValue("Query.override", "") == "1":
00036         self.make_active_user(hdf)
00037         self.ncgi.cookieClear("inactive")
00038 
00039         # if the dismiss checkbox was checked, store it in the database
00040         if hdf.getValue("Query.dismiss_active_warning", "") == "1":
00041           user_record = self.authdb.users.lookup(self.username)
00042           user_record.dismiss_notice("active_warning")
00043 
00044         self.redirectUri(self.requestURI)
00045       else:
00046         # if this user has already dismissed the active warning page, make them active
00047         user_record = self.authdb.users.lookup(self.username)
00048         if user_record.notice_dismissed("active_warning"):
00049           self.make_active_user(hdf)
00050           self.ncgi.cookieClear("inactive")
00051           self.redirectUri(self.requestURI)
00052         else:
00053           # redirect to page warning about active user
00054           url = self.http + hdf.getValue("HTTP.Host", "") + config.gBaseURL + "active/active_warning.py?request=%s" % (neo_cgi.urlEscape(hdf.getValue("Query.request", "")))
00055           self.redirectUri(url)
00056 
00057   
00058     def Action_MakeInactive(self, hdf):
00059       self.ncgi.cookieSet("inactive", "1")
00060       if self.is_active_user():
00061         self.remove_active_user()
00062       self.redirectUri(self.requestURI)
00063 
00064     def Action_DismissNotice(self, hdf):
00065         self.pagename = "notice"
00066         user_record = self.authdb.users.lookup(self.username)
00067         notice = hdf.getValue("Query.notice", "")
00068         if notice != "":
00069             user_record.dismiss_notice(notice)
00070             hdf.setValue("CGI.cur.value", "OK")
00071 
00072     def Action_NoticeDismissed(self, hdf):
00073         self.pagename = "notice"
00074         user_record = self.authdb.users.lookup(self.username)
00075         notice = hdf.getValue("Query.notice", "")
00076         if user_record.notice_dismissed(notice):
00077             hdf.setValue("CGI.cur.value", "YES")
00078         else:
00079             hdf.setValue("CGI.cur.value", "NO")
00080         
00081 def run(context):
00082     page = ActivePage(context, pagename="active", nologin=False)
00083     return page
00084 
00085 def main(context):
00086   page = run(context)
00087   page.start()
00088   
00089 
00090 if __name__ == "__main__":
00091     main(Context())


webui
Author(s): Scott Hassan/hassan@willowgarage.com
autogenerated on Wed Apr 23 2014 10:36:00