예제 #1
0
    def get_extra(self, key, *args):
        from aiida.backends.djsite.db.models import DbExtra
        if len(args) > 1:
            raise ValueError("After the key name you can pass at most one"
                             "value, that is the default value to be used "
                             "if no extra is found.")

        try:
            if self._to_be_stored:
                raise AttributeError("DbExtra '{}' does not exist yet, the "
                                     "node is not stored".format(key))
            else:
                return DbExtra.get_value_for_node(dbnode=self.dbnode, key=key)
        except AttributeError as e:
            try:
                return args[0]
            except IndexError:
                raise e
예제 #2
0
 def _get_db_extra(self, key, *args):
     from aiida.backends.djsite.db.models import DbExtra
     return DbExtra.get_value_for_node(dbnode=self.dbnode, key=key)