Mercurial > sjsbox
changeset 14:ae958b456392
Backed out changeset 8958227b1baa
meh, we don't really need python box support.
author | Atul Varma <avarma@mozilla.com> |
---|---|
date | Mon, 31 May 2010 18:05:10 -0700 |
parents | 8958227b1baa |
children | 745b985ee84a |
files | sjsbox/box.py sjsbox/py.py tests/test_box.py |
diffstat | 3 files changed, 1 insertions(+), 33 deletions(-) [+] |
line wrap: on
line diff
--- a/sjsbox/box.py Mon May 31 18:04:49 2010 -0700 +++ b/sjsbox/box.py Mon May 31 18:05:10 2010 -0700 @@ -38,9 +38,6 @@ if f.name.endswith('.js'): import sjsbox.js self.__impl = sjsbox.js.JsBox(f.contents, f.name) - elif f.name.endswith('.py'): - import sjsbox.py - self.__impl = sjsbox.py.PyBox(f.contents, f.name) else: raise ValueError('unknown box type: %s' % f) self.pipe = pipe
--- a/sjsbox/py.py Mon May 31 18:04:49 2010 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,20 +0,0 @@ -try: - import json -except ImportError: - import simplejson as json - -from sjsbox.bunch import Bunch - -class PyBox(object): - def __init__(self, code, filename): - code = compile(code, filename, 'exec') - self.globals = {} - exec code in self.globals - - def handle(self, method, path): - request = Bunch(method=method, path=path) - response = self.globals['handle'](request) - return json.loads(json.dumps(response)) - - def shutdown(self): - pass
--- a/tests/test_box.py Mon May 31 18:04:49 2010 -0700 +++ b/tests/test_box.py Mon May 31 18:05:10 2010 -0700 @@ -10,12 +10,7 @@ name = 'foo.js', contents = 'function handle() { return 404; }' ) - self.bar = Bunch( - mtime = 0, - name = 'bar.py', - contents = 'def handle(request): return "hello"' - ) - self.dir = [self.foo, self.bar] + self.dir = [self.foo] self.boxes = sjsbox.box.Boxes(self.dir) self.assertEqual(self.boxes['foo'].handle('GET', '/'), 404) @@ -26,10 +21,6 @@ def test_contains_works(self): self.assertTrue('foo' in self.boxes) - def test_handle_py_works(self): - self.assertEqual(self.boxes['bar'].handle('GET', '/'), - "hello") - def test_handle_works(self): self.assertEqual(self.boxes['foo'].handle('GET', '/'), 404)