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


Python Node.get方法代码示例

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


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

示例1: addNodes

# 需要导入模块: from model import Node [as 别名]
# 或者: from model.Node import get [as 别名]
def addNodes(nodes):
    added = []
    for id in nodes:
        node,revision,tags = getNode(id)
        
        node['version'] = node['vid']
        node['user'] = node['uid']
        node['id'] = node['nid']
        revision['user'] = revision['uid']
        revision['id'] = revision['vid']
        revision['node'] = revision['nid']
        del(node['status'])
        del(node['uid'])
        del(node['nid'])
        del(node['vid'])
        del(revision['uid'])
        del(revision['nid'])
        del(revision['vid'])
        # add the nodes
        try:
            dbnode = Node.get(node['id']) 
            del(node['id'])
            dbnode.set(**node)
        except SQLObjectNotFound:
            dbnode = Node(**node)

        try:
            dbnoder = NodeRevision.get(revision['id'])
            del(revision['id'])
            dbnoder.set(**revision)
        except SQLObjectNotFound:
            dbnoder = NodeRevision(**revision)
        # add the termnodes
        for tag in tags:
            tag['node'] = tag['nid']
            tag['term'] = tag['tid']
            del(tag['nid'])
            del(tag['tid'])
            try:
                dbtag = Term.get(tag['term'])
            except SQLObjectNotFound:
                dbtag = addTags([tag['term']])[0]
            terms = list(TermNode.selectBy(node=dbnode,term=dbtag))
            if not terms:
                term = TermNode(**tag)
            else:
                term = terms[0]

        print "Node %d made!" % id
        added.append(id)
    return added
开发者ID:haxel,项目名称:spaceplace,代码行数:53,代码来源:sync.py

示例2: syncNodes

# 需要导入模块: from model import Node [as 别名]
# 或者: from model.Node import get [as 别名]
def syncNodes():
    print "syncing nodes"
    tags_checked = []
    users_checked = []
    nodes_checked = []
    tags_new = []
    users_new = []
    nodes_new = []
    
    for node in getNewNodes():
        tid = node['tid']
        nid = node['nid']
        changed = node['changed']
        uid = node['uid']

        if tid not in tags_checked:
            try:
                term = Term.get(tid)
            except SQLObjectNotFound:
                tags_new.append(tid)
            tags_checked.append(tid)

        if uid not in users_checked:
            try:
                node = User.get(uid)
            except SQLObjectNotFound:
                users_new.append(uid)
            users_checked.append(uid)

        if nid not in nodes_checked:
            try:
                node = Node.get(nid)
                if node.changed < changed:
                    nodes_new.append(nid)                    
            except SQLObjectNotFound:
                nodes_new.append(nid)
            nodes_checked.append(nid)
    
    
    hub.begin()    
    # add new db information
    addTags(tags_new)
    addUsers(users_new)
    nodes = addNodes(nodes_new)
    setWeight()
    hub.commit()
    
    return nodes
开发者ID:haxel,项目名称:spaceplace,代码行数:50,代码来源:sync.py


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