[Checkins] SVN: Sandbox/J1m/dozodb/ checkpoint
Jim Fulton
jim at zope.com
Mon Jan 10 09:43:44 EST 2011
Log message for revision 119470:
checkpoint
Changed:
U Sandbox/J1m/dozodb/buildout.cfg
U Sandbox/J1m/dozodb/setup.py
U Sandbox/J1m/dozodb/src/zc/dozodb/dozodb.js
A Sandbox/J1m/dozodb/src/zc/dozodb/dozodb.js.test
A Sandbox/J1m/dozodb/src/zc/dozodb/test_setup.js
A Sandbox/J1m/dozodb/src/zc/dozodb/tests.py
-=-
Modified: Sandbox/J1m/dozodb/buildout.cfg
===================================================================
--- Sandbox/J1m/dozodb/buildout.cfg 2011-01-10 14:36:45 UTC (rev 119469)
+++ Sandbox/J1m/dozodb/buildout.cfg 2011-01-10 14:43:43 UTC (rev 119470)
@@ -1,13 +1,20 @@
[buildout]
-parts = py dojo testjs
-develop = .
+parts = py dojo testjs test
+develop = . python-spidermonkey
+[test]
+recipe = zc.recipe.testrunner
+eggs = zc.dozodb [test]
+
+
[py]
recipe = zc.recipe.egg
eggs =
ZODB3
bobo
zc.dozodb
+ python-spidermonkey
+
interpreter = py
initialization =
sys.path.insert(0, "${buildout:directory}")
Modified: Sandbox/J1m/dozodb/setup.py
===================================================================
--- Sandbox/J1m/dozodb/setup.py 2011-01-10 14:36:45 UTC (rev 119469)
+++ Sandbox/J1m/dozodb/setup.py 2011-01-10 14:43:43 UTC (rev 119470)
@@ -13,8 +13,8 @@
##############################################################################
name, version = 'zc.dozodb', '0'
-install_requires = ['setuptools']
-extras_require = dict(test=['zope.testing'])
+install_requires = ['setuptools', 'ZODB3']
+extras_require = dict(test=['zope.testing', 'python-spidermonkey', 'manuel'])
entry_points = """
"""
Modified: Sandbox/J1m/dozodb/src/zc/dozodb/dozodb.js
===================================================================
--- Sandbox/J1m/dozodb/src/zc/dozodb/dozodb.js 2011-01-10 14:36:45 UTC (rev 119469)
+++ Sandbox/J1m/dozodb/src/zc/dozodb/dozodb.js 2011-01-10 14:43:43 UTC (rev 119470)
@@ -62,10 +62,12 @@
_convert_outgoing_items_to_item_refs: function (item, isobject) {
var maybe_array = (! isobject) && (item.length != null);
var result;
- if (maybe_array)
+ if (maybe_array) {
result = [];
- else
+ }
+ else {
result = {};
+ }
for (var name in item) {
if (! item.hasOwnProperty(name))
Added: Sandbox/J1m/dozodb/src/zc/dozodb/dozodb.js.test
===================================================================
--- Sandbox/J1m/dozodb/src/zc/dozodb/dozodb.js.test (rev 0)
+++ Sandbox/J1m/dozodb/src/zc/dozodb/dozodb.js.test 2011-01-10 14:43:43 UTC (rev 119470)
@@ -0,0 +1,21 @@
+dozodb -- ZODB-based dojo storage implementation
+================================================
+
+This files tests the javascript portion of the dozodb implementation.
+
+To use, you need to require:
+
+ >>> dojo.require('zc.dozodb');
+ [object Object]
+
+Create a store:
+
+ >>> store = zc.dozodb.Store({url: '/store'});
+
+where the url option names a dozodb web resource. dozodb web
+resources support loading and saving data via GET and POST ajax
+requests. Fopr these tests, we've stubbed out dojo's xhr interface to
+provide implementations that save xhr callbacks and print other data
+passed to xhr.
+
+
Added: Sandbox/J1m/dozodb/src/zc/dozodb/test_setup.js
===================================================================
--- Sandbox/J1m/dozodb/src/zc/dozodb/test_setup.js (rev 0)
+++ Sandbox/J1m/dozodb/src/zc/dozodb/test_setup.js 2011-01-10 14:43:43 UTC (rev 119470)
@@ -0,0 +1,33 @@
+
+var last_xhr;
+
+dojo.xhr = function (method, args, hasBody) {
+ var i, name, aa=[];
+ last_xhr = {};
+ for (name in args) {
+ if (args.hasOwnProperty(name)) {
+ if (typeof args[name] == 'function') {
+ last_xhr[name] = args[name];
+ }
+ else {
+ aa.push([name, args[name]]);
+ }
+ }
+ }
+ aa.sort();
+ console.log("xhr "+method);
+ for (i=0; i < aa.length; i++) {
+ console.log(" "+aa[i][0]+': '+aa[i][1]);
+ }
+ if (hasBody ? method !== 'POST' : method !== 'GET') {
+ console.error('Bad hasBody: '+ hasBody);
+ }
+};
+dojo.xhrGet = function (args) {
+ return dojo.xhr("GET", args);
+};
+dojo.xhrPost = function (args) {
+ return dojo.xhr("POST", args, true);
+};
+
+
Added: Sandbox/J1m/dozodb/src/zc/dozodb/tests.py
===================================================================
--- Sandbox/J1m/dozodb/src/zc/dozodb/tests.py (rev 0)
+++ Sandbox/J1m/dozodb/src/zc/dozodb/tests.py 2011-01-10 14:43:43 UTC (rev 119470)
@@ -0,0 +1,64 @@
+##############################################################################
+#
+# Copyright (c) 2006 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+
+import doctest
+import os
+import spidermonkey
+import sys
+import unittest
+
+run_time = spidermonkey.Runtime()
+
+class DocTestParser(doctest.DocTestParser):
+ ""
+
+ def parse(self, string, name='<string>'):
+ r =doctest.DocTestParser.parse(self, string, name)
+ for s in r:
+ if isinstance(s, doctest.Example):
+ s.source = "JS(%r)" % s.source
+ return r
+
+def setUp(test):
+
+ cx = run_time.new_context()
+ cx.add_global('line2pc', 0)
+ base = '/home/jim/p/dozodb/dev/parts/dojo/release/dojo/dojo/'
+ cx.add_global('djConfig',dict(baseUrl=base))
+
+ def load(name):
+ cx.execute(open(name).read(), name)
+
+ cx.add_global('load', load)
+
+ load(base+'dojo.js.uncompressed.js')
+ cx.execute('console').log = lambda s: sys.stdout.write('%s\n' % (s, ))
+ cx.execute('console'
+ ).error = lambda s: sys.stdout.write('Error: %s\n' % (s, ))
+
+ test.globs['JS'] = JS = cx.execute
+
+ load(os.path.join(os.path.dirname(__file__), 'test_setup.js'))
+ JS('dojo.registerModulePath("zc.dozodb", "%s")' %
+ os.path.join(os.path.dirname(__file__), 'dozodb')
+ )
+
+def test_suite():
+ return unittest.TestSuite((
+ doctest.DocFileSuite(
+ 'dozodb.js.test',
+ parser=DocTestParser(),
+ setUp=setUp,
+ ),
+ ))
More information about the checkins
mailing list