Exemplo n.º 1
0
def mining_patterns_view(request):
    
    mptl = DL.MiningPatternsTableLoader()
    
    banner_patterns, lp_patterns = mptl.get_pattern_lists()
            
    return render_to_response('LML/mining_patterns.html', {'banner_patterns' : banner_patterns, 'lp_patterns' : lp_patterns},  context_instance=RequestContext(request))
Exemplo n.º 2
0
def mining_patterns_add(request):
    
    err_msg = ''
    mptl = DL.MiningPatternsTableLoader()
    
    type = 'banner'
    
    """ Extract Post data """
    try:
        regexp = MySQLdb._mysql.escape_string(request.POST['regexp_pattern'])
        type = MySQLdb._mysql.escape_string(request.POST['pattern_type'])
        
    except:
        
        err_msg = 'Fields to add mining pattern incorrect.'
        pass 
        
    mptl.insert_row(pattern_type=type, pattern=regexp)
    banner_patterns, lp_patterns = mptl.get_pattern_lists()
    
    return render_to_response('LML/mining_patterns.html', {'err_msg' : err_msg , 'banner_patterns' : banner_patterns, 'lp_patterns' : lp_patterns},  context_instance=RequestContext(request))
Exemplo n.º 3
0
def mining_patterns_delete(request):
    
    mptl = DL.MiningPatternsTableLoader()
    
    try:    
        banner_patterns = request.POST.getlist('banner_patterns')
        
        """ Escape POST input """
        for index in range(len(banner_patterns)):
            banner_patterns[index] = MySQLdb._mysql.escape_string(str(banner_patterns[index]))
    
    except:
        banner_patterns = list()
        pass
    
    try:
        lp_patterns =  request.POST.getlist('lp_patterns')
        
        """ Escape POST input """
        for index in range(len(lp_patterns)):
            lp_patterns[index] = MySQLdb._mysql.escape_string(str(lp_patterns[index]))
            
    except:        
        lp_patterns = list()
        pass
                
    logging.debug(banner_patterns)
    logging.debug(lp_patterns)
    
    """ Remove selected patterns """
    for elem in banner_patterns:
        mptl.delete_row(pattern=elem,pattern_type='banner')
    
    for elem in lp_patterns:
        mptl.delete_row(pattern=elem,pattern_type='lp')
        
    banner_patterns, lp_patterns = mptl.get_pattern_lists()
    
    return render_to_response('LML/mining_patterns.html', {'banner_patterns' : banner_patterns, 'lp_patterns' : lp_patterns},  context_instance=RequestContext(request))