From: erickson Date: Wed, 23 Jan 2008 14:07:42 +0000 (+0000) Subject: verifying existance of local tree before performing some functions X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=104488f5bbad06eb9a1eadc1c32a68c62130e652;p=Evergreen.git verifying existance of local tree before performing some functions git-svn-id: svn://svn.open-ils.org/ILS/trunk@8477 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- diff --git a/Open-ILS/src/python/oils/org.py b/Open-ILS/src/python/oils/org.py index e0cb3c1e2f..d5f45b60a9 100644 --- a/Open-ILS/src/python/oils/org.py +++ b/Open-ILS/src/python/oils/org.py @@ -9,6 +9,11 @@ class OrgUtil(object): _flat_org_tree = {} @staticmethod + def _verify_tree(): + if not OrgUtil._org_tree: + OrgUtil.fetch_org_tree() + + @staticmethod def fetch_org_tree(): ''' Returns the whole org_unit tree ''' @@ -35,6 +40,7 @@ class OrgUtil(object): @staticmethod def get_org_unit(org_id): + OrgUtil._verify_tree() return OrgUtil._flat_org_tree[org_id] @@ -65,7 +71,8 @@ class OrgUtil(object): ''' Returns a cloned tree of orgs including all ancestors and descendants of the provided org ''' - org = org_unit = org_unit.shallow_clone() + OrgUtil._verify_tree() + org = org_unit = OrgUtil.get_org_unit(org_unit.id()).shallow_clone() while org.parent_ou(): parent = org.parent_ou() if not isinstance(parent, osrf.net_obj.NetworkObject): @@ -90,6 +97,7 @@ class OrgUtil(object): @staticmethod def get_related_list(org_unit): ''' Returns a flat list of related org_units ''' + OrgUtil._verify_tree() tree = OrgUtil.get_related_tree(org_unit) orglist = [] def flatten(node):