def get_keys( self ): collection_name = self.request.GET['collection_name'] col_obj = CollectionMapping( 'mongo_content' ) data_obj = col_obj.find_one( { "collection_name":collection_name} ) keys_name = ( data_obj['key_names'] ).keys() search_set = list( SEARCH_SET ) return render_to_response( 'search/key_list.html', locals(), context_instance = RequestContext( self.request ) )
def get_keys(self): collection_name = self.request.GET["collection_name"] col_obj = CollectionMapping("mongo_content") data_obj = col_obj.find_one({"collection_name": collection_name}) keys_name = (data_obj["key_names"]).keys() search_set = list(SEARCH_SET) return render_to_response("search/key_list.html", locals(), context_instance=RequestContext(self.request))
def upload_json( self, json_dump, unique_dict=None ): print "uploading" for key,value_list in json_dump.items(): self.collection_name=key self.create_content( value_list ) col_obj = CollectionMapping( key) load_all=True for value in value_list: if unique_dict: res=col_obj.find_one(unique_dict) if res: col_obj.objects.update(unique_dict,value) load_all=False if load_all: col_obj.load_json( value ) print "file uploaded" return HttpResponse( 'File Uploaded' )
def upload_json(self, json_dump, unique_dict=None): print "uploading" for key, value_list in json_dump.items(): self.collection_name = key self.create_content(value_list) col_obj = CollectionMapping(key) load_all = True for value in value_list: if unique_dict: res = col_obj.find_one(unique_dict) if res: col_obj.objects.update(unique_dict, value) load_all = False if load_all: col_obj.load_json(value) print "file uploaded" return HttpResponse('File Uploaded')