[Checkins] SVN: Sandbox/J1m/dozodb/src/zc/dozodb/ checkpoint
Jim Fulton
jim at zope.com
Fri Jan 7 17:04:17 EST 2011
Log message for revision 119452:
checkpoint
Changed:
U Sandbox/J1m/dozodb/src/zc/dozodb/__init__.py
U Sandbox/J1m/dozodb/src/zc/dozodb/dozodb.js
-=-
Modified: Sandbox/J1m/dozodb/src/zc/dozodb/__init__.py
===================================================================
--- Sandbox/J1m/dozodb/src/zc/dozodb/__init__.py 2011-01-07 21:15:56 UTC (rev 119451)
+++ Sandbox/J1m/dozodb/src/zc/dozodb/__init__.py 2011-01-07 22:04:17 UTC (rev 119452)
@@ -107,7 +107,7 @@
raise ValueError("Unreachable new objects")
if inserted:
- app.insert(inserted)
+ app.insert([app.connection.get(new_ids[i]) for i in inserted])
# XXX it's annoying that we have to commit here, but we need the
# committed serials. :/ Maybe we can think of something better
@@ -132,11 +132,15 @@
def webob(app, request):
- if request.method == 'GET':
- if '_p_oid' in request.str_GET:
- return load(app.connection, request.str_GET.get('_p_oid'))
- return fetched(app.query())
+ import time; time.sleep(1)
+ try:
+ if request.method == 'GET':
+ if '_p_oid' in request.str_GET:
+ return load(app.connection, request.str_GET.get('_p_oid'))
+ return fetched(app.query())
- assert(request.method == 'POST')
- assert request.content_type.startswith('application/json')
- return save(app, request.body)
+ assert(request.method == 'POST')
+ assert request.content_type.startswith('application/json')
+ return save(app, request.body)
+ except Exception, e:
+ return json.dumps(dict(error=unicode(e)))
Modified: Sandbox/J1m/dozodb/src/zc/dozodb/dozodb.js
===================================================================
--- Sandbox/J1m/dozodb/src/zc/dozodb/dozodb.js 2011-01-07 21:15:56 UTC (rev 119451)
+++ Sandbox/J1m/dozodb/src/zc/dozodb/dozodb.js 2011-01-07 22:04:17 UTC (rev 119452)
@@ -282,22 +282,24 @@
loadItem : function (args) {
var item = args.item;
- console.log('loading '+item._p_oid);
if (item._p_changed != null) {
if (args.onItem != null)
dojo.hitch(args.scope, args.onItem)(item);
return;
}
self = this;
+ console.log('loading '+item._p_oid);
dojo.xhrGet(
{
// Server gets query arg _p_oid
// Server returns: {item: item}
url: this.url,
+ //sync: true,
handleAs: 'json',
preventCache: true,
content: {_p_oid: item._p_oid},
load: function (r) {
+ console.log('loaded '+item._p_oid);
dojo.safeMixin(item, r.item);
item._p_changed = false;
self._convert_incoming_items_refs_to_items(item);
@@ -401,34 +403,36 @@
setValue : function (item, attribute, value) {
if (item._p_changed == null)
throw("Attempt to modify ghost.");
- var old = undefined;
- if (attribute in item)
- old = attribute[item];
- if (old == null || old.length == null)
- item[attribute] = value;
- else
- item[attribute] = [value];
+
+ var old = item[attribute];
+ if (old === value)
+ return true;
+
+ item[attribute] = value;
+ item._p_changed = true;
this._changes.changed[item._p_id] = item;
this.onSet(item, attribute, old, value);
+ return true; // I guess :/
},
-
setValues : function (item, attribute, value) {
- if (item._p_changed == null)
- throw("Attempt to modify ghost.");
- var old = undefined;
- if (attribute in item)
- old = item[attribute];
- if (value == [])
- delete item[attribute];
- else
- item[attribute] = value;
- this._changes.changed[item._p_id] = item;
- this.onSet(item, attribute, old, value);
+ if (dojo.isArray(value) && value.length == 0)
+ return this.unsetAttribute(item, attribute);
+ return this.setValue(item, attribute, value);
},
onSet: function (item, attribute, old, new_) {}, // hook
unsetAttribute : function (item, attribute) {
- delete item[attribute];
+ if (item._p_changed == null)
+ throw("Attempt to modify ghost.");
+
+ if (attribute in item) {
+ var old = item[attribute];
+ delete item[attribute];
+ item._p_changed = true;
+ this._changes.changed[item._p_id] = item;
+ self.onset(item, attribute, old, undefined);
+ }
+ return true;
}
};
More information about the checkins
mailing list