当前位置: 首页>>代码示例>>Python>>正文


Python Rule.content方法代码示例

本文整理汇总了Python中Rule.Rule.content方法的典型用法代码示例。如果您正苦于以下问题:Python Rule.content方法的具体用法?Python Rule.content怎么用?Python Rule.content使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Rule.Rule的用法示例。


在下文中一共展示了Rule.content方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: write_rules

# 需要导入模块: from Rule import Rule [as 别名]
# 或者: from Rule.Rule import content [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'
开发者ID:macagua,项目名称:Motini,代码行数:59,代码来源:StartController.py


注:本文中的Rule.Rule.content方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。