def create_item(self, name=None, description='<Unset>', owner=0, location=None): """ Creates a new item in the ScalyMUCK world. Keyword arguments: name -- The name of the Item that is to be used. description -- The description of the Item that is to be used. Default: <Unset> owner -- The ID or instance of Player that is to become the owner of this Item. location -- The ID or instance of Room that is to become the location of this Item. """ if (name is None or location is None): raise exception.WorldArgumentError('Either the name or location was not specified. (or they were None)') try: item = Item(name, description, owner) if (type(location) is int): item.location_id = location item.location = self.find_room(id=location) else: item.location = location item.location_id = location.id connection = self.connect() self.session.add(item) self.session.commit() self.session.refresh(item) item.session = self.session item.engine = self.engine connection.close() return item except OperationalError: self.session.rollback() self.database_status.send(sender=self, status=False)