source: Dev/trunk/src/client/qed-client/store.js @ 468

Last change on this file since 468 was 468, checked in by hendrikvanantwerpen, 12 years ago

Improved authentication

  • Authentication cannot be cancelled, removing a lot of weird race conditions.
  • We offer a request provider that has automatic retry in case of authentication failures.
  • Reduced dependency on LoginDialog? by having it act independent based on events. Other modules can just depend on 'session'.
File size: 1.3 KB
Line 
1define([
2    'dojo/date/stamp',
3    'dojo/store/Cache',
4    'dojo/store/Memory',
5    'dojox/json/schema',
6    './model/schema',
7    './request',
8    './store/CouchStore'
9],function(stamp,Cache,Memory,jsonSchema,schema,request,CouchStore){
10   
11    var couchStore = new CouchStore({
12        target: 'api/data/',
13        request: request /*,
14        validate: function(object) {
15            var result = jsonSchema.validate(object,schema);
16            if ( result.valid ) {
17                return true;
18            } else {
19                console.log("Found error ",result," for invalid object ",object);
20                return false;
21            }
22        }*/
23    });
24    var memoryStore = new Memory({
25        idProperty: couchStore.idProperty
26    });
27    var cacheStore = new Cache(couchStore,memoryStore,{
28        isLoaded: function(object) {
29            // Unfortunately we cannot determine of the full documents were
30            // loaded or not. Therefore never cache query results.
31            return false;
32        }
33    });
34
35    var store = cacheStore;
36    store.formatDate = function(date){
37        return stamp.toISOString(date,{zulu:true});
38    };
39    store.parseDate = function(dateString){
40        return stamp.fromISOString(dateString);
41    };
42    store.timestamp = function() {
43        return this.formatDate(new Date());
44    };
45    return store;
46
47});
Note: See TracBrowser for help on using the repository browser.