本文整理汇总了Python中models.Room.engine方法的典型用法代码示例。如果您正苦于以下问题:Python Room.engine方法的具体用法?Python Room.engine怎么用?Python Room.engine使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Room
的用法示例。
在下文中一共展示了Room.engine方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_room
# 需要导入模块: from models import Room [as 别名]
# 或者: from models.Room import engine [as 别名]
def create_room(self, name, description='<Unset>', owner=0):
""" Creates a new Room if the World.
Keyword arguments:
description -- The description that is to be used with the new Room instance.
owner -- The ID or instance of Player that is to become the owner of this Room.
"""
try:
room = Room(name, description, owner)
connection = self.connect()
self.session.add(room)
self.session.commit()
self.session.refresh(room)
room.session = self.session
room.engine = self.engine
connection.close()
return room
except OperationalError:
self.session.rollback()
self.database_status.send(sender=self, status=False)