Exemple #1
0
class Rating(orm.Document):
    collection_name = None
    fields = [('mu', orm.FloatField(required=True, default=25.)),
              ('sigma', orm.FloatField(required=True, default=25. / 3))]

    def trueskill_rating(self):
        return trueskill.Rating(mu=self.mu, sigma=self.sigma)

    @classmethod
    def from_trueskill(cls, trueskill_rating):
        return Rating(mu=trueskill_rating.mu, sigma=trueskill_rating.sigma)
Exemple #2
0
class Comment(orm.Model):
    __table__ = 'comments'

    id = orm.StringField(primary_key=True, default=next_id, ddl='varchar(50)')
    blog_id = orm.StringField(ddl='varchar(50)')
    user_id = orm.StringField(ddl='varchar(50)')
    user_name = orm.StringField(ddl='varchar(50)')
    user_image = orm.StringField(ddl='varchar(500)')
    content = orm.TextField()
    created_at = orm.FloatField(default=time.time)
Exemple #3
0
class User(orm.Model):
    __table__ = 'users'

    id = orm.StringField(is_primary_key=True,
                         default=next_id(),
                         ddl='varchar(50)')
    email = orm.StringField(ddl='varchar(50)')
    passwd = orm.StringField(ddl='varchar(50)')
    admin = orm.BooleanField()
    name = orm.StringField(ddl='varchar(50)')
    image = orm.StringField(ddl='varchar(500)')
    created_at = orm.FloatField(default=time.time())
Exemple #4
0
class Blog(orm.Model):
    __table__ = 'blogs'

    id = orm.StringField(is_primary_key=True,
                         default=next_id(),
                         ddl='varchar(50)')
    user_id = orm.StringField(ddl='varchar(50)')
    user_name = orm.StringField(ddl='varchar(50)')
    user_image = orm.StringField(ddl='varchar(500)')
    name = orm.StringField(ddl='varchar(50)')
    summary = orm.StringField(ddl='varchar(200)')
    content = orm.TextField()
    created_at = orm.FloatField(default=time.time())
Exemple #5
0
class User(orm.Model):
    id = orm.StringField(default=db.get_id(),
                         primary_key=True,
                         updatable=False)
    username = orm.StringField(default='admin')
    age = orm.IntegerField(default=10)
    height = orm.FloatField(default=1.2)
    male = orm.BooleanField(default=True)

    def pre_insert(self):
        print '========pre========insert'

    def pre_update(self):
        print '--------pre--------update'

    def pre_delete(self):
        print '........pre<<<<<<<<<delete'
Exemple #6
0
class RankingEntry(orm.Document):
    collection_name = None
    fields = [('player', orm.ObjectIDField(required=True)),
              ('rank', orm.IntField(required=True)),
              ('rating', orm.FloatField(required=True)),
              ('previous_rank', orm.IntField())]