コード例 #1
0
class AuthRandoms(db.Model):
    '''
    @@ unique key uk_value(value)
    @@ index idx_expires_time(expires_time)
    '''

    _id = db.StringField(primary_key=True,
                         default=db.next_id,
                         ddl='varchar(50)')

    value = db.StringField(
        updatable=False,
        default=lambda: '%s%s' %
        (uuid.uuid4().hex, random.randrange(100000000, 999999999)),
        ddl='varchar(100)')
    expires_time = db.FloatField(updatable=False,
                                 default=lambda: time.time() + 600,
                                 ddl='real')

    creation_time = db.FloatField(updatable=False)
    modified_time = db.FloatField()
    version = db.VersionField()

    def pre_insert(self):
        self.creation_time = self.modified_time = time.time()
コード例 #2
0
ファイル: models.py プロジェクト: wangyudi/brighterpage
class Pages(db.Model):
    '''
    Static page object.

    @@ unique idx_alias(alias)
    '''

    _id = db.StringField(primary_key=True, default=db.next_id, ddl='varchar(50)')

    alias = db.StringField(updatable=False, ddl='varchar(50)')
    content_id = db.StringField(ddl='varchar(50)')

    draft = db.BooleanField()
    name = db.StringField(ddl='varchar(50)')
    tags = db.StringField(ddl='varchar(200)')

    creation_time = db.FloatField(updatable=False)
    modified_time = db.FloatField()
    version = db.VersionField()

    def pre_insert(self):
        self.creation_time = self.modified_time = time.time()

    def pre_update(self):
        self.modified_time = time.time()
        self.version = self.version + 1
コード例 #3
0
ファイル: models.py プロジェクト: wangyudi/brighterpage
class Resources(db.Model):
    '''
    A resource represents a single file.
    
    @@ index idx_ref_id(ref_id)
    '''

    _id = db.StringField(primary_key=True,
                         default=db.next_id,
                         ddl='varchar(50)')

    ref_id = db.StringField(updatable=False, ddl='varchar(50)')

    deleted = db.BooleanField()

    size = db.IntegerField(updatable=False)
    meta = db.StringField(updatable=False, ddl='varchar(100)')
    mime = db.StringField(updatable=False, ddl='varchar(100)')
    url = db.StringField(updatable=False, ddl='varchar(2000)')
    data = db.BlobField(updatable=False, ddl='mediumblob')

    creation_time = db.FloatField(updatable=False)
    modified_time = db.FloatField()
    version = db.VersionField()

    def pre_insert(self):
        self.creation_time = self.modified_time = time.time()

    def pre_update(self):
        self.modified_time = time.time()
        self.version = self.version + 1
コード例 #4
0
class AuthUsers(db.Model):
    '''
    Authenticate user by third-party. e.g. weibo.

    @@ unique key uk_auth_id(auth_id)
    @@ index idx_creation_time(creation_time)
    '''

    _id = db.StringField(primary_key=True,
                         default=db.next_id,
                         ddl='varchar(50)')

    user_id = db.StringField(ddl='varchar(50)')

    auth_provider = db.StringField(updatable=False, ddl='varchar(50)')
    auth_id = db.StringField(updatable=False, ddl='varchar(200)')
    auth_token = db.StringField(ddl='varchar(200)')

    expires_time = db.FloatField()
    creation_time = db.FloatField(updatable=False)
    modified_time = db.FloatField()
    version = db.VersionField()

    def pre_insert(self):
        self.creation_time = self.modified_time = time.time()

    def pre_update(self):
        self.modified_time = time.time()
        self.version = self.version + 1
コード例 #5
0
ファイル: models.py プロジェクト: wangyudi/brighterpage
class WikiPages(db.Model):
    '''
    @@ index idx_wiki_id(wiki_id)
    '''
    _id = db.StringField(primary_key=True,
                         default=db.next_id,
                         ddl='varchar(50)')

    wiki_id = db.StringField(updatable=False, ddl='varchar(50)')
    parent_id = db.StringField(ddl='varchar(50)')

    name = db.StringField(ddl='varchar(50)')
    content_id = db.StringField(ddl='varchar(50)')

    display_order = db.IntegerField()

    creation_time = db.FloatField(updatable=False)
    modified_time = db.FloatField()
    version = db.VersionField()

    def pre_insert(self):
        self.creation_time = self.modified_time = time.time()

    def pre_update(self):
        self.modified_time = time.time()
        self.version = self.version + 1
コード例 #6
0
ファイル: models.py プロジェクト: wangyudi/brighterpage
class Comments(db.Model):
    '''
    Comment object.
    
    @@ index idx_ref_id(ref_id)
    '''
    _id = db.StringField(primary_key=True,
                         default=db.next_id,
                         ddl='varchar(50)')
    ref_id = db.StringField(updatable=False, ddl='varchar(50)')
    ref_type = db.StringField(updatable=False, ddl='varchar(50)')

    user_id = db.StringField(updatable=False, ddl='varchar(50)')
    user_name = db.StringField(updatable=False, ddl='varchar(50)')
    user_image_url = db.StringField(updatable=False, ddl='varchar(1000)')

    content = db.StringField(updatable=False, ddl='varchar(1000)')

    creation_time = db.FloatField(updatable=False)
    modified_time = db.FloatField()
    version = db.VersionField()

    def pre_insert(self):
        self.creation_time = self.modified_time = time.time()

    def pre_update(self):
        self.modified_time = time.time()
        self.version = self.version + 1
コード例 #7
0
ファイル: models.py プロジェクト: wangyudi/brighterpage
class SNSTokens(db.Model):
    '''
    SNS Token object.
    '''

    _id = db.StringField(primary_key=True,
                         default=db.next_id,
                         ddl='varchar(50)')

    auth_provider = db.StringField(updatable=False, ddl='varchar(50)')
    auth_name = db.StringField(updatable=False, ddl='varchar(50)')
    auth_token = db.StringField(updatable=False, ddl='varchar(200)')

    creation_time = db.FloatField(updatable=False)
    expires_time = db.FloatField(updatable=False)
    version = db.VersionField()

    def pre_insert(self):
        self.creation_time = time.time()
コード例 #8
0
class Users(db.Model):
    '''
    user object.

    @@ unique key uk_email(email)
    @@ index idx_creation_time(creation_time)
    '''

    _id = db.StringField(primary_key=True,
                         default=db.next_id,
                         ddl='varchar(50)')

    name = db.StringField(ddl='varchar(50)')
    role = db.IntegerField(default=1000000, ddl='int')

    email = db.StringField(updatable=False, ddl='varchar(100)')
    verified = db.BooleanField(ddl='bool')

    binds = db.StringField(ddl='varchar(100)')
    passwd = db.StringField(ddl='varchar(100)')
    image_url = db.StringField(ddl='varchar(1000)')

    locked_time = db.FloatField(ddl='real')
    creation_time = db.FloatField(updatable=False)
    modified_time = db.FloatField()
    version = db.VersionField()

    def pre_insert(self):
        self.creation_time = self.modified_time = time.time()

    def pre_update(self):
        self.modified_time = time.time()
        self.version = self.version + 1
コード例 #9
0
ファイル: models.py プロジェクト: wangyudi/brighterpage
class Attachments(db.Model):
    '''
    Attachment object.
    
    @@ index idx_creation_time(creation_time)
    '''

    _id = db.StringField(primary_key=True, ddl='varchar(50)')

    user_id = db.StringField(updatable=False, ddl='varchar(50)')
    resource_ids = db.StringField(updatable=False, ddl='varchar(1000)')

    kind = db.StringField(updatable=False, ddl='varchar(50)')
    size = db.IntegerField(updatable=False)
    name = db.StringField(updatable=False, ddl='varchar(100)')
    description = db.StringField(updatable=False,
                                 default='',
                                 ddl='varchar(100)')

    creation_time = db.FloatField(updatable=False)
    modified_time = db.FloatField()
    version = db.VersionField()

    def pre_insert(self):
        self.creation_time = self.modified_time = time.time()

    def pre_update(self):
        self.modified_time = time.time()
        self.version = self.version + 1
コード例 #10
0
ファイル: models.py プロジェクト: wangyudi/brighterpage
class Texts(db.Model):
    '''
    @@ index idx_ref_id(ref_id)
    @@ index idx_creation_time(creation_time)
    '''
    _id = db.StringField(primary_key=True,
                         default=db.next_id,
                         ddl='varchar(50)')

    ref_id = db.StringField(updatable=False, ddl='varchar(50)')
    value = db.StringField(updatable=False, ddl='text')

    creation_time = db.FloatField(updatable=False)
    modified_time = db.FloatField()
    version = db.VersionField()

    def pre_insert(self):
        self.creation_time = self.modified_time = time.time()

    def pre_update(self):
        self.modified_time = time.time()
        self.version = self.version + 1
コード例 #11
0
class Categories(db.Model):
    '''
    Category object.
    '''

    _id = db.StringField(primary_key=True,
                         default=db.next_id,
                         ddl='varchar(50)')

    display_order = db.IntegerField()
    name = db.StringField(ddl='varchar(50)')
    description = db.StringField(ddl='varchar(100)')

    creation_time = db.FloatField(updatable=False)
    modified_time = db.FloatField()
    version = db.VersionField()

    def pre_insert(self):
        self.creation_time = self.modified_time = time.time()

    def pre_update(self):
        self.modified_time = time.time()
        self.version = self.version + 1
コード例 #12
0
ファイル: models.py プロジェクト: wangyudi/brighterpage
class Wikis(db.Model):
    '''
    Wiki object.
    '''
    _id = db.StringField(primary_key=True,
                         default=db.next_id,
                         ddl='varchar(50)')

    name = db.StringField(ddl='varchar(50)')
    description = db.StringField(ddl='varchar(100)')

    cover_id = db.StringField(ddl='varchar(50)')
    content_id = db.StringField(ddl='varchar(50)')

    creation_time = db.FloatField(updatable=False)
    modified_time = db.FloatField()
    version = db.VersionField()

    def pre_insert(self):
        self.creation_time = self.modified_time = time.time()

    def pre_update(self):
        self.modified_time = time.time()
        self.version = self.version + 1
コード例 #13
0
class Articles(db.Model):
    '''
    @@ index idx_publish_time(publish_time)
    @@ index idx_user_id(user_id)
    '''

    _id = db.StringField(primary_key=True,
                         default=db.next_id,
                         ddl='varchar(50)')

    user_id = db.StringField(updatable=False, ddl='varchar(50)')
    category_id = db.StringField(ddl='varchar(50)')
    cover_id = db.StringField(ddl='varchar(50)')
    content_id = db.StringField(ddl='varchar(50)')

    draft = db.BooleanField(ddl='bool')
    user_name = db.StringField(updatable=False, ddl='varchar(20)')

    name = db.StringField(ddl='varchar(50)')
    tags = db.StringField(ddl='varchar(200)')
    summary = db.StringField(ddl='varchar(1000)')

    publish_time = db.FloatField(ddl='real')
    creation_time = db.FloatField(updatable=False)
    modified_time = db.FloatField()
    version = db.VersionField()

    def pre_insert(self):
        self.creation_time = self.modified_time = time.time()
        if self.draft:
            self.publish_time = TIME_FEATURE + self.creation_time
        else:
            if 'publish_time' not in self or self.publish_time < 1.0:
                self.publish_time = self.creation_time

    def pre_update(self):
        self.modified_time = time.time()
        self.version = self.version + 1