Beispiel #1
0
 def __init__(self, **kwargs):
     self._model_cls = kwargs.pop('Model')
     self.verbose_name = kwargs.pop('verbose_name', None)
     if self.verbose_name is None:
         from api.base.utils import convert_name
         self.verbose_name = convert_name(self._model_cls.__name__,
                                          to_text=True)
     super(UniqueNameField, self).__init__(**kwargs)
Beispiel #2
0
 def get_trainer_filename(self):
     # we don't use sqlalchemy to avoid auto loading of trainer file
     # into trainer object
     from api.base.utils import convert_name
     name = convert_name(self.__class__.__name__)
     sql = text("SELECT trainer from %s where id=:id" % name)
     trainer_filename, = db.engine.execute(sql, id=self.id).first()
     return trainer_filename
Beispiel #3
0
 def predict_model(cls):
     from api.base.utils import convert_name, pluralize
     backref_name = pluralize(convert_name(cls.__name__))
     return relationship(
         "PredictModel",
         backref=backref(backref_name))
Beispiel #4
0
 def import_handler(cls):
     from api.base.utils import convert_name, pluralize
     backref_name = pluralize(convert_name(cls.__name__))
     return relationship(
         "XmlImportHandler", backref=backref(backref_name,
                                             cascade='all,delete'))
Beispiel #5
0
 def status(cls):
     from api.base.utils import convert_name
     name = convert_name(cls.__name__)
     return db.Column(db.Enum(*cls.STATUSES, name='%s_statuses' % name),
                      default=cls.STATUS_NEW)