本文整理汇总了Python中Rule.Rule.action方法的典型用法代码示例。如果您正苦于以下问题:Python Rule.action方法的具体用法?Python Rule.action怎么用?Python Rule.action使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Rule.Rule
的用法示例。
在下文中一共展示了Rule.action方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: write_rules
# 需要导入模块: from Rule import Rule [as 别名]
# 或者: from Rule.Rule import action [as 别名]
def write_rules(self,req):
'''Get the posted rules and write them to the temporary session table.'''
# read post values and save them. Intended as an Ajax call.
form_vars = req.POST
#print "Failed to open the rules file."
# rule_file = open('/var/tmp/rules_list.dat','wb')
rules = []
try:
try:
rule_file = open('/var/tmp/rules_list.dat','rb')
except:
pass
rules = pickle.load(rule_file)
rule_file.close()
except:
rules = []
#return "Failed to read the rules."
try:
command = form_vars['command']
if command == 'clear':
try:
rule_file = open('/var/tmp/rules_list.dat','wb')
rules = []
pickle.dump(rules,rule_file)
rule_file.close()
except:
pass
# self.session.cachestore['temp_rules'] = rules
# self.session.save()
return 'success'
except KeyError:
pass
try:
r = Rule()
r.action = form_vars['action']
r.content = 'children:' + form_vars['content']
r.theme = 'children:' + form_vars['theme']
except KeyError:
return "failed"
rules.append(r)
try:
rule_file = open('/var/tmp/rules_list.dat','wb')
pickle.dump(rules,rule_file)
except:
return "Failed to Write rules"
# self.session.cachestore['temp_rules'] = rules
# self.session.save()
return 'success'