import sys from AdminPage import AdminPage from AdminSecurity import AdminSecurity class AppControl(AdminSecurity): def writeContent(self): req = self.request() wr = self.writeln action = self.request().field("action", None) if action is None: if not self.application().server().isPersistent(): wr('
You are running the OneShot version of WebKit.' ' None of the options below are applicable.
') wr('''
') elif action == "Clear cache": from WebKit.URLParser import ServletFactoryManager factories = filter(lambda f: f._classCache, ServletFactoryManager._factories) wr('')
for factory in factories:
wr('Flushing cache of %s...
' % factory.name())
factory.flushCache()
wr('
The caches of all factories' ' have been flushed.
') wr('Click here to view the Servlet cache:' ' Servlet Cache
') elif action == "Reload": wr('Reloading selected modules. Any existing classes' ' will continue to use the old module definitions,' ' as will any functions/variables imported using "from".' ' Use "Clear Cache" to clean out any servlets' ' in this condition.
') reloadnames = req.field("reloads", None) if not type(reloadnames) == type([]): reloadnames = [reloadnames] wr('
')
for n in reloadnames:
m = sys.modules.get(n)
if m:
wr("Reloading %s...
" % self.htmlEncode(str(m)))
try:
reload(m)
except Exception, e:
wr('Could not reload, '
'error was "%s".
' % e)
wr('
The selected modules' ' have been reloaded.
') elif action == "Shutdown": wr('Shutting down the Application server...
') self.application().server().initiateShutdown() self.write('Good Luck!
') else: wr('Cannot perform "%s".
' % action)