本文整理汇总了Python中pyasm.common.Common.generate_random_key方法的典型用法代码示例。如果您正苦于以下问题:Python Common.generate_random_key方法的具体用法?Python Common.generate_random_key怎么用?Python Common.generate_random_key使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyasm.common.Common
的用法示例。
在下文中一共展示了Common.generate_random_key方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: execute
# 需要导入模块: from pyasm.common import Common [as 别名]
# 或者: from pyasm.common.Common import generate_random_key [as 别名]
def execute(my):
login = Environment.get_user_name()
users = my.kwargs.get("users")
everyone = [login]
everyone.extend(users)
# find out if there already is a subscription between this user
# and others
search = Search("sthpw/subscription")
search.add_filter("login", login)
search.add_filter("category", "chat")
login_subscriptions = search.get_sobjects()
keys = [x.get_value("message_code") for x in login_subscriptions]
create = True
# find the subscriptions for each user with the same keys
for user in users:
search = Search("sthpw/subscription")
search.add_filters("message_code", keys)
search.add_filter("login", user)
user_subscriptions = search.get_sobjects()
if user_subscriptions:
create = False
# create a new subscription
if create:
key = Common.generate_random_key()
message = SearchType.create("sthpw/message")
message.set_value("code", key)
message.set_value("login", login)
message.set_value("category", "chat")
message.set_value("message", "Welcome!!!")
message.commit()
# create a subscription for each person
for person in everyone:
subscription = SearchType.create("sthpw/subscription")
subscription.set_value("message_code", key)
subscription.set_value("login", person)
subscription.set_value("category", "chat")
subscription.commit()
示例2: get_command_key
# 需要导入模块: from pyasm.common import Common [as 别名]
# 或者: from pyasm.common.Common import generate_random_key [as 别名]
def get_command_key(self):
return Common.generate_random_key()