+
+
+def cached_resources(proxy):
+ hosts = resources_cache.get('hosts')
+ if hosts is None:
+ # prevent circular import errors
+ from qcg.service import fetch_resources
+
+ hosts, _, applications, modules = map(make_choices, fetch_resources(proxy))
+ resources_cache.set('hosts', hosts)
+ resources_cache.set('applications', applications)
+ resources_cache.set('modules', modules)
+ else:
+ applications = resources_cache.get('applications')
+ modules = resources_cache.get('modules')
+
+ return hosts, applications, modules
+
+
+def make_choices(iterable):
+ return ((None, ''),) + tuple((item, item) for item in sorted(iterable))