summaryrefslogtreecommitdiff
path: root/examples/console/web/index.py
diff options
context:
space:
mode:
authorianb <devnull@localhost>2005-05-07 19:18:55 +0000
committerianb <devnull@localhost>2005-05-07 19:18:55 +0000
commite9dfa19430b660ef063b2a42947ecf97c766d44a (patch)
tree2e9dec669b0afaea009e6424297db2387708e3ed /examples/console/web/index.py
parent76fcfe11f5268dffd0b3f2aae256e3f8e83a8ed3 (diff)
downloadpaste-e9dfa19430b660ef063b2a42947ecf97c766d44a.tar.gz
Use urllib instead of jsonrpc
Diffstat (limited to 'examples/console/web/index.py')
-rw-r--r--examples/console/web/index.py25
1 files changed, 24 insertions, 1 deletions
diff --git a/examples/console/web/index.py b/examples/console/web/index.py
index aec3498..571a9f1 100644
--- a/examples/console/web/index.py
+++ b/examples/console/web/index.py
@@ -1,6 +1,7 @@
from console.sitepage import SitePage
from console.JSONComponent import JSONComponent
from console.evalcontext import EvalContext
+import time
context = EvalContext()
@@ -9,13 +10,35 @@ class index(SitePage):
components = SitePage.components + [
JSONComponent(baseConfig='console')]
+ def awake(self, trans):
+ self.t1 = time.time()
+ SitePage.awake(self, trans)
+
def setup(self):
self.options.title = 'Console'
def jsonMethods(self):
return ['run']
+
+ def actions(self):
+ return ['postrun']
def run(self, expr):
+ self.t2 = time.time()
+ if not expr.endswith('\n'):
+ expr += '\n'
+ result = context.exec_expr(expr)
+ self.t3 = time.time()
+ timing = '%s - %s\n%s' % (
+ self.t2 - self.t1, self.t3 - self.t2, result)
+ return timing
+
+ def postrun(self):
+ self.response().setHeader('content-type', 'text/plain')
+ expr = self.request().field('command', '')
if not expr.endswith('\n'):
expr += '\n'
- return context.exec_expr(expr)
+ result = context.exec_expr(expr)
+ print [expr, result]
+ self.write(result)
+