Exemplo n.º 1
0
Arquivo: city.py Projeto: fuzeman/byte
class City(Model):
    id = Property(str, name='geonameid', primary_key=True)

    name = Property(str)

    country = Property(str)
    subcountry = Property(str)
Exemplo n.º 2
0
class Artist(Model):
    class Options:
        slots = True

    id = Property(int, primary_key=True)

    title = Property(str)
Exemplo n.º 3
0
class User(Model):
    class Options:
        slots = True

    id = Property(int, primary_key=True)

    username = Property(str)
    password = Property(str)
Exemplo n.º 4
0
class Album(Model):
    class Options:
        slots = True

    id = Property(int, primary_key=True)
    artist = Property(Artist)

    title = Property(str)
Exemplo n.º 5
0
class User(Model):
    id = Property(int, primary_key=True)

    username = Property(str)
    password = Property(str)

    created_at = Property(datetime, default=lambda: datetime.now())
    updated_at = Property(datetime, default=lambda: datetime.now())
Exemplo n.º 6
0
    def __bind_property_relation(cls, properties, key, prop):
        # Bind `prop` (to ensure metadata is available)
        prop.bind(cls, key + '_id')

        # Create identifier property
        p_id = Property(prop.relation.value_type)
        p_id.bind(cls, key + '_id')

        # Create resolve property
        p_resolve = RelationProperty(p_id, prop.value_type)
        p_resolve.bind(cls, key)

        # Store resolve property on model
        setattr(cls, key, p_resolve)

        # Store resolve property on model `Properties`
        setattr(properties, key, p_resolve)
        properties.__all__[key] = p_resolve

        # Store identifier property on model `Properties`
        setattr(properties, key + '_id', p_id)
        properties.__all__[key + '_id'] = p_id
Exemplo n.º 7
0
class Artist(Model):
    id = Property(int, primary_key=True)

    title = Property(str)
Exemplo n.º 8
0
class Album(Model):
    id = Property(int, primary_key=True)
    artist = Property(Artist)

    title = Property(str)
Exemplo n.º 9
0
class Track(Model):
    id = Property(int, primary_key=True)
    artist = Property(Artist)
    album = Property(Album)

    title = Property(str)