Ejemplo n.º 1
0
    def __init__(self,
                 type=None,
                 db=None,
                 db_required=False,
                 namespace='global',
                 **kwargs):
        ''' :param type: (optional) the Field type to use for the values.  It
                must be a DocumentField.  If you want to save refs to raw mongo
                objects, you can leave this field out
            :param db: (optional) The database to load the object from.
                Defaults to the same database as the object this field is
                bound to.
            :param namespace: If using the namespace system and using a
                collection name instead of a type, selects which namespace to
                use
        '''
        from mongoalchemy.fields import DocumentField
        if type and not isinstance(type, DocumentField):
            type = DocumentField(type)

        super(RefField, self).__init__(**kwargs)
        self.db_required = db_required
        self.type = type
        self.namespace = namespace
        self.db = db
        self.parent = None
Ejemplo n.º 2
0
    def __init__(self, type, db=None, **kwargs):
        from mongoalchemy.fields import DocumentField

        super(SRefField, self).__init__(**kwargs)

        self.type = type
        if not isinstance(type, DocumentField):
            self.type = DocumentField(type)
        self.db = db