treeeditor/admin.py
def _build_tree_structure(cls):
    """
    Build an in-memory representation of the item tree, trying to keep
    database accesses down to a minimum. The returned dictionary looks like
    this (as json dump):

        {"6": [7, 8, 10]
         "7": [12],
         "8": [],
         ...
         }
    """
    all_nodes = {}

    for p_id, parent_id in cls.objects.order_by(cls._mptt_meta.tree_id_attr, cls._mptt_meta.left_attr).values_list(
            "pk", "%s_id" % cls._mptt_meta.parent_attr
    ):
        all_nodes[p_id] = []

        if parent_id:
            if not all_nodes.has_key(parent_id):
                # This happens very rarely, but protect against parents that
                # we have yet to iteratove over.
                all_nodes[parent_id] = []
            all_nodes[parent_id].append(p_id)

    return all_nodes
def _build_tree_structure(cls):
    """
    Build an in-memory representation of the item tree, trying to keep
    database accesses down to a minimum. The returned dictionary looks like
    this (as json dump):

        {"6": [7, 8, 10]
         "7": [12],
         "8": [],
         ...
         }
    """
    all_nodes = {}

    for p_id, parent_id in cls.objects.order_by(cls._mptt_meta.tree_id_attr, cls._mptt_meta.left_attr).values_list(
            "pk", "%s_id" % cls._mptt_meta.parent_attr
    ):
        all_nodes[p_id] = []

        if parent_id:
            if not all_nodes.has_key(parent_id):
                # This happens very rarely, but protect against parents that
                # we have yet to iteratove over.
                all_nodes[parent_id] = []
            all_nodes[parent_id].append(p_id)

    return all_nodes
def _build_tree_structure ( cls ) : all_nodes = { } for p_id , parent_id in cls . objects . order_by ( cls . _mptt_meta . tree_id_attr , cls . _mptt_meta . left_attr ) . values_list ( "pk" , "%s_id" % cls . _mptt_meta . parent_attr ) : all_nodes [ p_id ] = [ ] if parent_id : if not all_nodes . has_key ( parent_id ) : # This happens very rarely, but protect against parents that # we have yet to iteratove over. all_nodes [ parent_id ] = [ ] all_nodes [ parent_id ] . append ( p_id ) return all_nodes
Build an in-memory representation of the item tree, trying to keep
    database accesses down to a minimum. The returned dictionary looks like
    this (as json dump):

        {"6": [7, 8, 10]
         "7": [12],
         "8": [],
         ...
         }
Build an in - memory representation of the item tree trying to keep database accesses down to a minimum . The returned dictionary looks like this ( as json dump ) :