from dlkit_runtime import RUNTIME, PROXY_SESSION condition = PROXY_SESSION.get_proxy_condition() # getting req object from dlkit_gstudio.gstudio_user_proxy import GStudioRequest req_obj = GStudioRequest(id=1) condition.set_http_request(req_obj) proxy = PROXY_SESSION.get_proxy(condition) #================================================== GROUP as REPOSITORY ================== repository_service_mgr = RUNTIME.get_service_manager('REPOSITORY', proxy=proxy) # import ipdb; ipdb.set_trace() # The following two calls are equivalent: rl = repository_service_mgr.get_repository_lookup_session() all_repos = rl.get_repositories() all_repos = repository_service_mgr.get_repositories() print "\nTotal repositories: ", all_repos.available() test_repo = None for each in all_repos: test_repo = each d = test_repo.get_id() # import ipdb; ipdb.set_trace() grp_assets = test_repo.get_assets() print "\n Total Assets: ", grp_assets.available() if grp_assets.available(): asset_obj = grp_assets.next() print "\n Asset name: ", asset_obj.get_display_name().get_text()
from dlkit_runtime import PROXY_SESSION, RUNTIME from dlkit_gstudio.gstudio_user_proxy import GStudioRequest req_obj = GStudioRequest(id=1) condition = PROXY_SESSION.get_proxy_condition() condition.set_http_request(req_obj) proxy = PROXY_SESSION.get_proxy(condition) assessment_service_mgr = RUNTIME.get_service_manager('ASSESSMENT', proxy=proxy) all_banks = assessment_service_mgr.get_banks() all_banks.available() # ====== # from dlkit_runtime import PROXY_SESSION, RUNTIME # from dlkit_gstudio.gstudio_user_proxy import GStudioRequest # condition = PROXY_SESSION.get_proxy_condition() # proxy = PROXY_SESSION.get_proxy(condition) # assessment_service_mgr = RUNTIME.get_service_manager('ASSESSMENT', proxy=proxy) # all_banks = assessment_service_mgr.get_banks() # all_banks.available() # from dlkit.primordium.id.primitives import Id # bank = assessment_service_mgr.get_bank(Id('assessment.Bank%3A57c00fbded849b11f52fc8ec%40ODL.MIT.EDU')) # bank.get_display_name().text # # bank = all_banks.next() # assessment_items = bank.get_assessments() # assessment_items.available() # a = assessment_items.next() # offerings = bank.get_assessments_offered_for_assessment(a.get_id()) # Error: # /home/docker/code/gstudio/gnowsys-ndf/qbank_lite/dlkit/mongo/assessment/objects.pyc in next(self) # 1190
from dlkit_runtime import RUNTIME, PROXY_SESSION condition = PROXY_SESSION.get_proxy_condition() # getting req object from dlkit_gstudio.gstudio_user_proxy import GStudioRequest req_obj = GStudioRequest(id=1) condition.set_http_request(req_obj) proxy = PROXY_SESSION.get_proxy(condition) #================================================== GROUP as REPOSITORY ================== repository_service_mgr = RUNTIME.get_service_manager('REPOSITORY', proxy=proxy) # import ipdb; ipdb.set_trace() # The following two calls are equivalent: rl = repository_service_mgr.get_repository_lookup_session() all_repos = rl.get_repositories() # is equivalent to: all_repos = repository_service_mgr.get_repositories() # The latter is supported by the "services" implementation as a developer convenience # The service manager keeps track of the sessions on behalf of the consumer # In each case the "lookup_session" is invoked without a repository, which is the convention # for such sessions. So the authz_adapter will report the ROOT repository. # The GStudio Authorization implentation must deal with this. # print "\nTotal repositories: ", all_repos.len() # the above code should use available() instead. .len() mostly works but will not always guarantee # a correct answer for complex or very large iterators. Instead use:
from dlkit_runtime import PROXY_SESSION, RUNTIME from dlkit_gstudio.gstudio_user_proxy import GStudioRequest req_obj = GStudioRequest(id=1) condition = PROXY_SESSION.get_proxy_condition() condition.set_http_request(req_obj) proxy = PROXY_SESSION.get_proxy(condition) assessment_service_mgr = RUNTIME.get_service_manager('ASSESSMENT', proxy=proxy) all_banks = assessment_service_mgr.get_banks() all_banks.available() # ====== # from dlkit_runtime import PROXY_SESSION, RUNTIME # from dlkit_gstudio.gstudio_user_proxy import GStudioRequest # condition = PROXY_SESSION.get_proxy_condition() # proxy = PROXY_SESSION.get_proxy(condition) # assessment_service_mgr = RUNTIME.get_service_manager('ASSESSMENT', proxy=proxy) # all_banks = assessment_service_mgr.get_banks() # all_banks.available() # from dlkit.primordium.id.primitives import Id # bank = assessment_service_mgr.get_bank(Id('assessment.Bank%3A57c00fbded849b11f52fc8ec%40ODL.MIT.EDU')) # bank.get_display_name().text # # bank = all_banks.next() # assessment_items = bank.get_assessments() # assessment_items.available() # a = assessment_items.next() # offerings = bank.get_assessments_offered_for_assessment(a.get_id()) # Error: