Subversion Repositories SmartDukaan

Rev

Rev 14481 | Rev 14485 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 14481 Rev 14482
Line 17... Line 17...
17
itemCashBackMap = {}
17
itemCashBackMap = {}
18
 
18
 
19
DataService.initialize(db_hostname="localhost")
19
DataService.initialize(db_hostname="localhost")
20
mc = MemCache("127.0.0.1")
20
mc = MemCache("127.0.0.1")
21
 
21
 
-
 
22
SOURCE_MAP = {1:'AMAZON',2:'FLIPKART',3:'SNAPDEAL',4:'SAHOLIC'}
-
 
23
 
22
def get_mongo_connection(host='localhost', port=27017):
24
def get_mongo_connection(host='localhost', port=27017):
23
    global con
25
    global con
24
    if con is None:
26
    if con is None:
25
        print "Establishing connection %s host and port %d" %(host,port)
27
        print "Establishing connection %s host and port %d" %(host,port)
26
        try:
28
        try:
Line 659... Line 661...
659
                                                             {"$set":{'updatedOn':to_java_date(datetime.now())}},upsert=False,multi=True)
661
                                                             {"$set":{'updatedOn':to_java_date(datetime.now())}},upsert=False,multi=True)
660
        return {1:"Document deleted successfully"}
662
        return {1:"Document deleted successfully"}
661
    except Exception as e:
663
    except Exception as e:
662
        print e
664
        print e
663
        return {0:"Document not deleted."}
665
        return {0:"Document not deleted."}
664
    
-
 
665
 
666
 
-
 
667
def searchMaster(offset, limit, search_term):
-
 
668
    data = []
-
 
669
    try:
-
 
670
        collection = get_mongo_connection().Catalog.MasterData.find({'source_product_name':re.compile(search_term, re.IGNORECASE),'source_id':{'$in':SOURCE_MAP.keys()}}).offset(offset).limit(limit)
-
 
671
        for record in collection:
-
 
672
            data.append(record)
-
 
673
    except:
-
 
674
        pass
-
 
675
    return data
666
 
676
 
667
def main():
677
def main():
668
    x = getNewDeals(1, 0, 0, 500, None, None)
678
    x = getNewDeals(1, 0, 0, 500, None, None)
669
    for i in x:
679
    for i in x:
670
        print i['_id'],
680
        print i['_id'],