| 38 | | if conf.has_info('ecscart.connector'): |
|---|
| 39 | | self.connector = conf.get('ecscart.connector') |
|---|
| 40 | | rules_chains = conf.keys_section('ecscart_rules') |
|---|
| 41 | | |
|---|
| 42 | | #now we will build rules chain |
|---|
| 43 | | self.chain = {} |
|---|
| 44 | | for chain_key in rules_chains: |
|---|
| 45 | | process = None |
|---|
| 46 | | chain_name = chain_key.split('.')[-1] |
|---|
| 47 | | for rule_path in conf.get(chain_key).split(','): |
|---|
| 48 | | rule_path = rule_path.strip() |
|---|
| 49 | | # get the name of module and name of rule class |
|---|
| 50 | | module_name, rule_name = rule_path.split('.') |
|---|
| 51 | | # try to import the rule |
|---|
| 52 | | exec "from %s import %s as rule" % (module_name, |
|---|
| 53 | | rule_name) |
|---|
| 54 | | # chain the rule |
|---|
| 55 | | process = rule(process) |
|---|
| 56 | | # the chain build is over, add it into the chain dict |
|---|
| 57 | | self.chain[chain_name] = process |
|---|
| 58 | | else: |
|---|
| 59 | | self.connector = 'standard' |
|---|
| 60 | | amount_chain = [CartReduction, CartAmount, ObjectReduction, |
|---|
| 61 | | ObjectAmount] |
|---|
| 62 | | process = None |
|---|
| 63 | | for rule in amount_chain: |
|---|
| 64 | | process = rule(process) |
|---|
| 65 | | self.chain = {'amount': process} |
|---|
| | 32 | # if conf.has_info('ecscart.connector'): |
|---|
| | 33 | # self.connector = conf.get('ecscart.connector') |
|---|
| | 34 | # rules_chains = conf.keys_section('ecscart_rules') |
|---|
| | 35 | # |
|---|
| | 36 | # #now we will build rules chain |
|---|
| | 37 | # self.chain = {} |
|---|
| | 38 | # for chain_key in rules_chains: |
|---|
| | 39 | # process = None |
|---|
| | 40 | # chain_name = chain_key.split('.')[-1] |
|---|
| | 41 | # for rule_path in conf.get(chain_key).split(','): |
|---|
| | 42 | # rule_path = rule_path.strip() |
|---|
| | 43 | # # get the name of module and name of rule class |
|---|
| | 44 | # module_name, rule_name = rule_path.split('.') |
|---|
| | 45 | # # try to import the rule |
|---|
| | 46 | # exec "from %s import %s as rule" % (module_name, |
|---|
| | 47 | # rule_name) |
|---|
| | 48 | # # chain the rule |
|---|
| | 49 | # process = rule(process) |
|---|
| | 50 | # # the chain build is over, add it into the chain dict |
|---|
| | 51 | # self.chain[chain_name] = process |
|---|
| | 52 | # else: |
|---|
| | 53 | self.connector = 'standard' |
|---|
| | 54 | amount_chain = [CartReduction, CartAmount, ObjectReduction, |
|---|
| | 55 | ObjectAmount] |
|---|
| | 56 | process = None |
|---|
| | 57 | for rule in amount_chain: |
|---|
| | 58 | process = rule(process) |
|---|
| | 59 | self.chain = {'amount': process} |
|---|