example of storing the user groups into a file as JSON and retrieving
authorphasefx <phasefx@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 20 Sep 2005 18:57:09 +0000 (18:57 +0000)
committerphasefx <phasefx@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 20 Sep 2005 18:57:09 +0000 (18:57 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@1839 dcc99617-32d9-48b4-a31d-7c20da2025e4

Evergreen/staff_client/chrome/content/evergreen/auth/auth.js
Evergreen/staff_client/chrome/content/evergreen/util/error.js
Evergreen/staff_client/chrome/content/evergreen/util/file.js

index 3f7a524..048eb13 100644 (file)
@@ -125,6 +125,7 @@ function auth_init_callback(request) {
        sdump( 'D_AUTH', 'D_AUTH_INIT: ' + typeof(auth_init) + ' : ' + auth_init + '\n');
        var name = document.getElementById('name_prompt').value;
        var pw = document.getElementById('password_prompt').value;
+       G.name = name; G.pw = pw;
 
        user_async_request(
                'open-ils.auth',
@@ -140,7 +141,7 @@ function auth_ses_callback(request) {
        var auth_ses;
        try {
                auth_ses = request.getResultObject();
-               if (!auth_ses) { throw('null result'); }
+               if (!auth_ses) { if (!G.offline) { throw('null result'); } }
                if (auth_ses == 0) { throw('0 result'); }
                if (instanceOf(auth_ses,ex)) {
                        throw(auth_ses.err_msg());
@@ -169,7 +170,14 @@ function ap_list_callback(request) {
        var ap_list;
        try {
                ap_list = request.getResultObject();
-               if (!ap_list) { throw('null result'); }
+               if (!ap_list) { 
+                       if (!G.offline) {
+                               throw('null result'); 
+                       } else {
+                               var f = create_input_stream('ap_list');
+                               ap_list = JSON2js( f.read(-1) ); f.close();
+                       }
+               }
                if (ap_list.length == 0) { throw('zero length result'); }
        } catch(E) {
                alert('Login failed on ap_list: ' + js2JSON(E)); 
@@ -177,6 +185,9 @@ function ap_list_callback(request) {
                        enable_login_prompts(); return;
                }
        }
+       var f = create_output_stream('ap_list');
+       var ap_list_json = js2JSON( ap_list );
+       f.write( ap_list_json, ap_list_json.length ); f.close();
        mw.G.ap_list = ap_list;
        mw.G.ap_hash = convert_object_list_to_hash( ap_list );
 
index b3d08aa..895ecf8 100644 (file)
@@ -55,6 +55,7 @@ var sdump_levels = {
        'D_PATRON_UTILS' : false,
        'D_CIRC_UTILS' : false,
 
+       'D_FILE' : true,
        'D_EXPLODE' : false,
        'D_FM_UTILS' : false,
        'D_PRINT' : false,
index 05b6e09..995fe63 100644 (file)
@@ -44,7 +44,6 @@ function get_file( fname ) {
                file = dirService.get( "AChrom",  Components.interfaces.nsIFile );
                file.append(mw.myPackageDir); file.append("content"); file.append("conf"); file.append(fname);
                sdump('D_FILE','get_file( ' + fname + ').path = ' + file.path + '\n');
-               alert('get_file( ' + fname + ').path = ' + file.path + '\n');
                return file;
        } catch(E) {
                sdump('D_ERROR', E);