diff options
author | makfire <mukeshpandey15@hotmail.com> | 2015-07-04 12:19:24 +0530 |
---|---|---|
committer | makfire <mukeshpandey15@hotmail.com> | 2015-07-04 12:19:24 +0530 |
commit | 140b91336d7067015d6e7e26126b6157a48cc27a (patch) | |
tree | a842c9810b642c0ba79edfc5f79973f620b0a882 /gnowsys-ndf/gnowsys_ndf | |
parent | 7bd32861825ec11a5da0a4f61dc800c4770b065d (diff) | |
parent | dda3e25fb03b5f517d21aff8dd593dd30d1ad4c1 (diff) | |
download | gnowsys-140b91336d7067015d6e7e26126b6157a48cc27a.tar.gz |
Merge pull request #1189 from Sanjay-Reddy-S/mongokit
implemented a optimizing technique in build_collection method
Diffstat (limited to 'gnowsys-ndf/gnowsys_ndf')
-rw-r--r-- | gnowsys-ndf/gnowsys_ndf/ndf/views/methods.py | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/gnowsys-ndf/gnowsys_ndf/ndf/views/methods.py b/gnowsys-ndf/gnowsys_ndf/ndf/views/methods.py index 2f983e2..7143e78 100644 --- a/gnowsys-ndf/gnowsys_ndf/ndf/views/methods.py +++ b/gnowsys-ndf/gnowsys_ndf/ndf/views/methods.py @@ -487,7 +487,7 @@ def get_drawers(group_id, nid=None, nlist=[], page_no=1, checked=None, **kwargs) for each in drawer: if each._id not in nlist: dict1[each._id] = each - + for oid in nlist: obj = node_collection.one({'_id': oid}) dict2.append(obj) @@ -502,9 +502,12 @@ def get_drawers(group_id, nid=None, nlist=[], page_no=1, checked=None, **kwargs) if each._id not in nlist: dict1[each._id] = each - for oid in nlist: + + for oid in nlist: obj = node_collection.one({'_id': oid}) dict2.append(obj) + + dict_drawer['1'] = dict1 dict_drawer['2'] = dict2 @@ -813,11 +816,12 @@ def build_collection(node, check_collection, right_drawer_list, checked): if node.prior_node != right_drawer_list: i = 0 node.prior_node=[] + node_prior_node_append_temp=node.prior_node.append #a temp. variable which stores the lookup for append method while (i < len(right_drawer_list)): node_id = ObjectId(right_drawer_list[i]) node_obj = node_collection.one({"_id": node_id}) if node_obj: - node.prior_node.append(node_id) + node_prior_node_append_temp(node_id) i = i+1 # print "\n Changed: prior_node" @@ -838,14 +842,16 @@ def build_collection(node, check_collection, right_drawer_list, checked): i = 0 node.collection_set = [] # checking if each _id in collection_list is valid or not + nlist_append_temp=nlist.append #a temp. variable which stores the lookup for append method + node_collection_set_append_temp=node.collection_set.append #a temp. variable which stores the lookup for append method while (i < len(right_drawer_list)): node_id = ObjectId(right_drawer_list[i]) node_obj = node_collection.one({"_id": node_id}) if node_obj: if node_id not in nlist: - nlist.append(node_id) + nlist_append_temp(node_id) else: - node.collection_set.append(node_id) + node_collection_set_append_temp(node_id) # After adding it to collection_set also make the 'node' as prior node for added collection element node_collection.collection.update({'_id': ObjectId(node_id), 'prior_node': {'$nin':[node._id]} },{'$push': {'prior_node': ObjectId(node._id)}}) @@ -853,7 +859,7 @@ def build_collection(node, check_collection, right_drawer_list, checked): for each in nlist: if each not in node.collection_set: - node.collection_set.append(each) + node_collection_set_append_temp(each) node.status = u"PUBLISHED" node.save() # After adding it to collection_set also make the 'node' as prior node for added collection element |