Example #1
0
    def set_data_key(self, key):
        """
        Set data_info's model and key. It puts info into attributes.
            
        Args:
            key: (string) Key of the data info.
        """
        # Save data info's key and model
        utils.set_obj_data_key(self, key)

        # Load data.
        self.load_data()

        # initialize with data
        if self.db.FIRST_CREATE:
            self.set_initial_data()
            del self.db.FIRST_CREATE
Example #2
0
    def set_data_key(self, key):
        """
        Set data_info's model and key. It puts info into attributes.
            
        Args:
            key: (string) Key of the data info.
        """
        # Save data info's key and model
        utils.set_obj_data_key(self, key)
        
        # Load data.
        self.load_data()

        # initialize with data
        if self.db.FIRST_CREATE:
            self.set_initial_data()
            del self.db.FIRST_CREATE
Example #3
0
    def set_data_key(self, key, level, set_location=True):
        """
        Set data_info's model and key. It puts info into attributes.
            
        Args:
            key: (string) Key of the data info.
            level: (number) object's level.
        """
        # Save data info's key and model
        utils.set_obj_data_key(self, key)

        self.db.level = level

        # Load data.
        try:
            # Load db data.
            self.load_data(set_location=set_location)
        except Exception, e:
            traceback.print_exc()
            logger.log_errmsg("%s(%s) can not load data:%s" %
                              (key, self.dbref, e))
Example #4
0
    def set_data_key(self, key, set_location=True):
        """
        Set data_info's model and key. It puts info into attributes.
            
        Args:
            key: (string) Key of the data info.
        """
        current_key = self.get_data_key(default=None)
        if current_key is not None:
            # Has data key
            if key == current_key:
                # Key has not changed.
                return

        # Save data info's key and model
        utils.set_obj_data_key(self, key)

        # Load data.
        self.load_data(set_location=set_location)

        # call data_key hook
        self.after_data_key_changed()
Example #5
0
    def set_data_key(self, key, level=None, reset_location=True):
        """
        Set data_info's model and key. It puts info into attributes.
            
        Args:
            key: (string) Key of the data info.
            level: (number) object's level.
            reset_location: (boolean) reset the object to its default location.
        """
        # Save data info's key and model
        utils.set_obj_data_key(self, key)
        
        # Load data.
        try:
            # Load db data.
            self.load_data(level, reset_location=reset_location)
        except Exception as e:
            traceback.print_exc()
            logger.log_errmsg("%s(%s) can not load data:%s" % (key, self.dbref, e))

        # call data_key hook
        self.after_data_key_changed()
Example #6
0
    def set_data_key(self, key, set_location=True):
        """
        Set data_info's model and key. It puts info into attributes.
            
        Args:
            key: (string) Key of the data info.
        """
        current_key = self.get_data_key(default=None)
        if current_key is not None:
            # Has data key
            if key == current_key:
                # Key has not changed.
                return
        
        # Save data info's key and model
        utils.set_obj_data_key(self, key)
        
        # Load data.
        self.load_data(set_location=set_location)

        # call data_key hook
        self.after_data_key_changed()
Example #7
0
 def set_data_key(self, key, set_location=True):
     """
     Set data_info's model and key. It puts info into attributes.
         
     Args:
         key: (string) Key of the data info.
     """
     current_key = self.get_data_key(default=None)
     if current_key is not None:
         # Has data key
         if key == current_key:
             # Key has not changed.
             return
     
     # Save data info's key and model
     utils.set_obj_data_key(self, key)
     
     # Load data.
     try:
         # Load db data.
         self.load_data(set_location=set_location)
     except Exception, e:
         logger.log_errmsg("%s(%s) can not load data:%s" % (key, self.dbref, e))
Example #8
0
    def set_data_key(self, key, set_location=True):
        """
        Set data_info's model and key. It puts info into attributes.
            
        Args:
            key: (string) Key of the data info.
        """
        current_key = self.get_data_key(default=None)
        if current_key is not None:
            # Has data key
            if key == current_key:
                # Key has not changed.
                return

        # Save data info's key and model
        utils.set_obj_data_key(self, key)

        # Load data.
        try:
            # Load db data.
            self.load_data(set_location=set_location)
        except Exception, e:
            logger.log_errmsg("%s(%s) can not load data:%s" %
                              (key, self.dbref, e))