本文整理汇总了Python中models.Branch.parent_branch_authorname方法的典型用法代码示例。如果您正苦于以下问题:Python Branch.parent_branch_authorname方法的具体用法?Python Branch.parent_branch_authorname怎么用?Python Branch.parent_branch_authorname使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Branch
的用法示例。
在下文中一共展示了Branch.parent_branch_authorname方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testUpdateNoDuplicate
# 需要导入模块: from models import Branch [as 别名]
# 或者: from models.Branch import parent_branch_authorname [as 别名]
def testUpdateNoDuplicate(self):
branch = Branch()
branch.link = 'testIdenticalLink.some_link'
branch.content = 'some_content'
branch.revision = 0
branch.parent_branch = self.parent_branch.key
branch.parent_branch_authorname = self.parent_branch.authorname
branch.put()
self.parent_branch.append_child(branch)
self.assertTrue(len(self.parent_branch.children()) == 1)
self.child_branchs.append(branch)
示例2: save_branch
# 需要导入模块: from models import Branch [as 别名]
# 或者: from models.Branch import parent_branch_authorname [as 别名]
def save_branch(self,authorname,parent_urlsafe_key,link,content):
userinfo = UserInfo.get_by_username(authorname)
if userinfo is None or not self.is_user_info_current(userinfo):
return False, [ 'unauthenticated' ]
branch = Branch()
branch.authorname = authorname
parent_key = ndb.Key(urlsafe=parent_urlsafe_key)
parent_branch = parent_key.get()
if parent_branch is None:
return False, ['parent_branch_not_found']
branch.tree_name = parent_branch.tree_name
tree = Tree.get_by_name(parent_branch.tree_name)
if tree is None:
return False, ['tree_not_found']
if tree.moderatorname == authorname or not tree.link_moderator_only:
branch.link = link
else:
branch.link = ""
if tree.moderatorname == authorname or not tree.content_moderator_only:
branch.content = content
else:
branch.content = ""
errors = self.validate_branch(tree, branch,authorname)
#currently there is a db lock on unique links
#eventually we should have a memcache lcok
authored_branch_count = 0
branchs = parent_branch.children()
if tree.single_thread and parent_branch.authorname == authorname:
errors.append('has_single_thread_parent_branch')
if tree.single_thread and len(branchs) > 0:
errors.append('has_single_thread_branch')
for branch_branch in branchs:
if branch_branch.link == branch.link:
errors.append('has_identical_link')
if branch_branch.authorname == authorname:
authored_branch_count += 1
if tree.branch_max > 0 and tree.branch_max <= authored_branch_count:
errors.append('has_branches')
if len(errors) == 0:
branch.revision = 0
branch.parent_branch = parent_key
branch.parent_branch_authorname = parent_branch.authorname
branch.put()
self.create_branch_version(branch)
parent_branch.append_child(branch)
notification = Notification()
notification.from_username = branch.authorname
if branch.authorname != parent_branch.authorname:
notification.to_username = parent_branch.authorname
notification.notification_type = 'new_branch'
notification.branch = branch.key
notification.branch_link = branch.link
notification.tree_name = branch.tree_name
notification.put()
return True, branch
else:
return False, errors