コード例 #1
0
ファイル: objects.py プロジェクト: xmunoz/Humongolus
class Loca(orm.EmbeddedDocument):
    city = field.Char()


class BadHuman(Human):
    unique = field.Integer()
    phone = field.Phone()
    email = field.Email(dbkey="em")
    car = field.ModelChoice(type=Car)
    active = field.Boolean()
    state = field.Char(validate=StateValidator)
    country = field.Char(validate=orm.FieldValidator)
    location = Loca()
    avatar = field.File(database=MongoClient().avatars)

Human.cars = orm.Lazy(type=Car, key='owner')


class AddressForm(widget.FieldSet):
    _fields = ["street", "street2", "zip"]

    street = widget.Input()
    street2 = widget.TextArea(cls="Woot", rows=10, cols=30)
    zip = widget.Input()

class LocationForm(widget.FieldSet):
    _fields = ["city"]
    _cls = "location"

    city = widget.Input()
コード例 #2
0
class Token(orm.Document):
    _db = 'lablog'
    _collection = 'tokens'

    _indexes = [
        orm.Index('access_token', key=('access_token', 1), unique=True),
        orm.Index('refresh_token', key=('refresh_token', 1), unique=True),
        orm.Index('client', key=('client', 1)),
        orm.Index('user', key=('user', 1)),
        orm.Index('user_agent', key=('user_agent', 1)),
    ]

    access_token = field.Char()
    refresh_token = field.Char()
    client = field.DocumentId(type=Client)
    scopes = orm.List(type=unicode)
    expires = field.Date()
    user = field.DocumentId(type=Admin)
    user_agent = field.Char()
    _type = field.Char()

    @property
    def token_type(self):
        return self._type

    def delete(self):
        self.remove()


Client.users = orm.Lazy(type=Admin, key='clients.ref')