From: erickson Date: Mon, 7 Apr 2008 17:08:43 +0000 (+0000) Subject: updated python code to use atomic calls for new streaming methods for backwards compa... X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=0dd9936ac505b9e842f6a039d555294814a2b5c9;p=Evergreen.git updated python code to use atomic calls for new streaming methods for backwards compat. streaming in js calls git-svn-id: svn://svn.open-ils.org/ILS/branches/acq-experiment@9251 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- diff --git a/Open-ILS/web/oilsweb/oilsweb/controllers/acq/fund.py b/Open-ILS/web/oilsweb/oilsweb/controllers/acq/fund.py index 857a2263d7..5a6bd5556b 100644 --- a/Open-ILS/web/oilsweb/oilsweb/controllers/acq/fund.py +++ b/Open-ILS/web/oilsweb/oilsweb/controllers/acq/fund.py @@ -82,7 +82,7 @@ class FundController(BaseController): fund = self._retrieve_fund(r, ses, r.ctx.acq.fund_id.value) source_list = ses.request( - 'open-ils.acq.funding_source.org.retrieve', + 'open-ils.acq.funding_source.org.retrieve.atomic', r.ctx.core.authtoken.value, None, {'limit_perm':'MANAGE_FUNDING_SOURCE', 'flesh_summary':1}).recv().content() Event.parse_and_raise(source_list) diff --git a/Open-ILS/web/oilsweb/oilsweb/lib/acq/fund.py b/Open-ILS/web/oilsweb/oilsweb/lib/acq/fund.py index f780c0a0a1..818a1af616 100644 --- a/Open-ILS/web/oilsweb/oilsweb/lib/acq/fund.py +++ b/Open-ILS/web/oilsweb/oilsweb/lib/acq/fund.py @@ -23,7 +23,7 @@ class FundMgr(object): def retrieve_org_funds(self, limit_perm=None): funds = self.ses.request( - 'open-ils.acq.fund.org.retrieve', + 'open-ils.acq.fund.org.retrieve.atomic', self.request_mgr.ctx.core.authtoken.value, None, limit_perm).recv().content() oils.event.Event.parse_and_raise(funds) return funds @@ -45,7 +45,7 @@ class FundMgr(object): def retrieve_org_funding_sources(self, options=None): sources = self.ses.request( - 'open-ils.acq.funding_source.org.retrieve', + 'open-ils.acq.funding_source.org.retrieve.atomic', self.request_mgr.ctx.core.authtoken.value, None, options).recv().content() oils.event.Event.parse_and_raise(sources) return sources diff --git a/Open-ILS/web/oilsweb/oilsweb/lib/acq/provider_mgr.py b/Open-ILS/web/oilsweb/oilsweb/lib/acq/provider_mgr.py index 30bc5a86b5..2223bfd637 100644 --- a/Open-ILS/web/oilsweb/oilsweb/lib/acq/provider_mgr.py +++ b/Open-ILS/web/oilsweb/oilsweb/lib/acq/provider_mgr.py @@ -11,7 +11,7 @@ def retrieve(r, id): def list(r): ses = ClientSession(oils.const.OILS_APP_ACQ) - providers = ses.request('open-ils.acq.provider.org.retrieve', + providers = ses.request('open-ils.acq.provider.org.retrieve.atomic', r.ctx.core.authtoken.value, None, {"flesh_summary":1}).recv().content() Event.parse_and_raise(providers) diff --git a/Open-ILS/web/oilsweb/oilsweb/public/oils/media/js/openils/acq/Fund.js b/Open-ILS/web/oilsweb/oilsweb/public/oils/media/js/openils/acq/Fund.js index e49f74438c..81de471ff7 100644 --- a/Open-ILS/web/oilsweb/oilsweb/public/oils/media/js/openils/acq/Fund.js +++ b/Open-ILS/web/oilsweb/oilsweb/public/oils/media/js/openils/acq/Fund.js @@ -12,18 +12,17 @@ dojo.declare('openils.acq.Fund', null, { openils.acq.Fund.loadGrid = function(domId, columns) { /** Fetches the list of funds and builds a grid from them */ + var gridRefs = util.Dojo.buildSimpleGrid(domId, columns, [], 'id', true); var ses = new OpenSRF.ClientSession('open-ils.acq'); var req = ses.request('open-ils.acq.fund.org.retrieve', - oilsAuthtoken, null, {flesh_summary:1}); /* XXX make this a streaming call */ + oilsAuthtoken, null, {flesh_summary:1}); req.oncomplete = function(r) { - var funds = r.recv().content(); - var items = []; - - for(var f in funds) { - var fund = funds[f]; - - items.push({ + var msg + gridRefs.grid.setModel(gridRefs.model); + while(msg = r.recv()) { + var fund = msg.content(); + gridRefs.store.newItem({ id:fund.id(), name:fund.name(), org: findOrgUnit(fund.org()).name(), @@ -32,9 +31,11 @@ openils.acq.Fund.loadGrid = function(domId, columns) { combined_balance:fund.summary()['combined_balance'] }); } - util.Dojo.buildSimpleGrid(domId, columns, items); + gridRefs.grid.update(); }; + req.send(); + return gridRefs.grid; }; } diff --git a/Open-ILS/web/oilsweb/oilsweb/public/oils/media/js/openils/acq/FundingSource.js b/Open-ILS/web/oilsweb/oilsweb/public/oils/media/js/openils/acq/FundingSource.js index 6b22e287fc..dbfbde9d2a 100644 --- a/Open-ILS/web/oilsweb/oilsweb/public/oils/media/js/openils/acq/FundingSource.js +++ b/Open-ILS/web/oilsweb/oilsweb/public/oils/media/js/openils/acq/FundingSource.js @@ -15,13 +15,13 @@ openils.acq.FundingSource.loadGrid = function(domId, columns) { var gridRefs = util.Dojo.buildSimpleGrid(domId, columns, [], 'id', true); var ses = new OpenSRF.ClientSession('open-ils.acq'); var req = ses.request('open-ils.acq.funding_source.org.retrieve', - oilsAuthtoken, null, {flesh_summary:1}); /* XXX make this a streaming call */ + oilsAuthtoken, null, {flesh_summary:1}); req.oncomplete = function(r) { - srcs = r.recv().content(); - - for(var f in srcs) { - var src = srcs[f]; + var msg + gridRefs.grid.setModel(gridRefs.model); + while(msg = r.recv()) { + var src = msg.content(); gridRefs.store.newItem({ id:src.id(), name:src.name(), @@ -30,12 +30,10 @@ openils.acq.FundingSource.loadGrid = function(domId, columns) { balance:src.summary()['balance'] }); } - - /* set the model after loading all of the data */ - gridRefs.grid.setModel(gridRefs.model); + gridRefs.grid.update(); }; + req.send(); - //return gridRefs; return gridRefs.grid; }; } diff --git a/Open-ILS/web/oilsweb/oilsweb/public/oils/media/js/openils/acq/Provider.js b/Open-ILS/web/oilsweb/oilsweb/public/oils/media/js/openils/acq/Provider.js index 669ba9ad94..f0a674ff7a 100644 --- a/Open-ILS/web/oilsweb/oilsweb/public/oils/media/js/openils/acq/Provider.js +++ b/Open-ILS/web/oilsweb/oilsweb/public/oils/media/js/openils/acq/Provider.js @@ -13,25 +13,27 @@ dojo.declare('openils.acq.Provider', null, { openils.acq.Provider.loadGrid = function(domId, columns) { /** Fetches the list of providers and builds a grid from them */ + var gridRefs = util.Dojo.buildSimpleGrid(domId, columns, [], 'id', true); var ses = new OpenSRF.ClientSession('open-ils.acq'); - var req = ses.request('open-ils.acq.provider.org.retrieve', oilsAuthtoken); /* XXX make this a streaming call */ + var req = ses.request('open-ils.acq.provider.org.retrieve', oilsAuthtoken); req.oncomplete = function(r) { - var providers = r.recv().content(); - var items = []; - - for(var p in providers) { - var prov = providers[p]; - items.push({ + var msg + gridRefs.grid.setModel(gridRefs.model); + while(msg = r.recv()) { + var prov = msg.content(); + gridRefs.store.newItem({ id:prov.id(), name:prov.name(), owner: findOrgUnit(prov.owner()).name(), currency_type:prov.currency_type() }); } - util.Dojo.buildSimpleGrid(domId, columns, items); + gridRefs.grid.update(); }; + req.send(); + return gridRefs.grid; }; }