本文整理汇总了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
示例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