本文整理汇总了Python中models.Message.tags_required方法的典型用法代码示例。如果您正苦于以下问题:Python Message.tags_required方法的具体用法?Python Message.tags_required怎么用?Python Message.tags_required使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Message
的用法示例。
在下文中一共展示了Message.tags_required方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: store_message
# 需要导入模块: from models import Message [as 别名]
# 或者: from models.Message import tags_required [as 别名]
def store_message(text, tagList, user, tags_required, private):
#Construct the message itself.
message = Message()
message.user = user
message.text = text
message.tags_required = tags_required
message.private = private
message.save()
#Store each tag.
for tag in tagList:
#Remove the prefix.
prefix = tag[0]
tag = tag[1:]
if prefix=="#":
if tag_exists(tag):
add_tag_to_message(tag, message)
else:
store_tag(tag, message)
elif prefix=="@":
if user_exists(tag):
add_user_to_message(tag, message);
else:
raise Exception("Tag has inapproriate prefix. Choices are '@' or '#'.")
message.save()
return message
示例2: store_message
# 需要导入模块: from models import Message [as 别名]
# 或者: from models.Message import tags_required [as 别名]
def store_message(text, tagList, user, tags_required, private):
#Construct the message itself.
message = Message()
message.user = user
message.text = text
message.tags_required = tags_required
message.private = private
message.save()
#Store each tag.
for tag in tagList:
connect_tag(tag, message=message)
message.save()
return message
示例3: store_message
# 需要导入模块: from models import Message [as 别名]
# 或者: from models.Message import tags_required [as 别名]
def store_message(text, tagList, user, tags_required):
#Construct the message itself.
message = Message()
message.user = user
message.text = text
message.tags_required = tags_required
message.save()
#Store each tag.
for new_tag in tagList:
if tag_exists(new_tag):
new_tag.message.add(message)
else:
store_tag(new_tag, message)
return message