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


Python Connection.get_conn方法代码示例

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


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

示例1: get_from_list

# 需要导入模块: from connection import Connection [as 别名]
# 或者: from connection.Connection import get_conn [as 别名]
 def get_from_list(cls, list_name):
     conn = Connection.get_conn()
     objs = conn.lrange(list_name, 0, -1)
     for obj_list in objs:
         try:
             yield [cls.load_from_str(obj_str) for obj_str in eval(obj_list)]
         except:
             pass
开发者ID:imazepov,项目名称:arnie,代码行数:10,代码来源:models.py

示例2: delete

# 需要导入模块: from connection import Connection [as 别名]
# 或者: from connection.Connection import get_conn [as 别名]
    def delete(cls, inst, del_inst = False, list_name = None):
        if list_name is None:
            list_name = inst.get_default_list_name()

        conn = Connection.get_conn()
        conn.hdel(list_name, inst.get_key())
        if del_inst:
            del inst
开发者ID:imazepov,项目名称:arnie,代码行数:10,代码来源:models.py

示例3: get_all

# 需要导入模块: from connection import Connection [as 别名]
# 或者: from connection.Connection import get_conn [as 别名]
    def get_all(cls, list_name = None):
        if not cls.is_stored():
            return

        if list_name is None:
            list_name = cls.get_default_list_name()

        conn = Connection.get_conn()
        hkeys = conn.hkeys(list_name)
        for key in hkeys:
            yield cls.load(key, list_name)
开发者ID:imazepov,项目名称:arnie,代码行数:13,代码来源:models.py

示例4: save

# 需要导入模块: from connection import Connection [as 别名]
# 或者: from connection.Connection import get_conn [as 别名]
    def save(self, list_name=None):
        if not is_stored():
            return

        if list_name is None:
            list_name = self.get_default_list_name()

        self.list_name = list_name

        storage_key = self.get_key()
        conn = Connection.get_conn()
        s = self.save_to_str()
        conn.hset(list_name, storage_key, s)
开发者ID:imazepov,项目名称:arnie,代码行数:15,代码来源:models.py

示例5: add_to_list

# 需要导入模块: from connection import Connection [as 别名]
# 或者: from connection.Connection import get_conn [as 别名]
    def add_to_list(self, list_name):
        conn = Connection.get_conn()
        if conn.llen(list_name) > 0:
            last_elem = eval(conn.lindex(list_name, -1))
            if isinstance(last_elem, list):
                if len(last_elem) > 0:
                    try:
                        last_set = ExercizeSet.load_from_str(last_elem[-1])               
                        if last_set.exercize == self.exercize:
                            last_elem.append(self.save_to_str())
                            conn.lset(list_name, -1, last_elem)
                            return
                    except:
                        pass          

        conn.rpush(list_name, [self.save_to_str()])
开发者ID:imazepov,项目名称:arnie,代码行数:18,代码来源:models.py

示例6: load

# 需要导入模块: from connection import Connection [as 别名]
# 或者: from connection.Connection import get_conn [as 别名]
    def load(cls, key, list_name=None):
        if not cls.is_stored():
            return None

        if list_name is None:
            list_name = cls.get_default_list_name()

        print "--- Loading '{0}' by key '{1}'".format(cls.__name__, key)
        conn = Connection.get_conn()
        str = conn.hget(list_name, key)
        if str is None:
            return None
        obj = cls.load_from_str(str)
        obj.set_key(key)
        obj.list_name = list_name

        return obj
开发者ID:imazepov,项目名称:arnie,代码行数:19,代码来源:models.py

示例7: any

# 需要导入模块: from connection import Connection [as 别名]
# 或者: from connection.Connection import get_conn [as 别名]
 def any(day):        
     conn = Connection.get_conn()
     return conn.llen('workout:' + date_to_str(day)) > 0
开发者ID:imazepov,项目名称:arnie,代码行数:5,代码来源:models.py


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