How to use the fireo.fields.errors.ReferenceTypeError function in fireo

To help you get started, we’ve selected a few fireo examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github octabytes / FireO / src / fireo / fields / reference_field.py View on Github external
def db_value(self, model):
        # if no model is provided then return None
        if model is None:
            return None
        # check reference model and passing model is same
        if not issubclass(model.__class__, self.model_ref):
            raise errors.ReferenceTypeError(f'Invalid reference type. Field "{self.name}" required value type '
                                            f'"{self.model_ref.__name__}", but got "{model.__class__.__name__}"')
        # Get document reference from firestore
        return firestore.DocumentReference(*utils.ref_path(model.key), client=db.conn)
github octabytes / FireO / src / fireo / fields / fields.py View on Github external
def db_value(self, model):
        # check reference model and passing model is same
        if not issubclass(model.__class__, self.model_ref):
            raise errors.ReferenceTypeError(f'Invalid reference type. Field "{self.name}" required value type '
                                            f'{self.model_ref.__name__}, but got {model.__class__.__name__}')
        # Get document reference from firestore
        return firestore.DocumentReference(*utils.ref_path(model.key), client=db.conn)
github octabytes / FireO / src / fireo / fields / reference_field.py View on Github external
def __init__(self, model_ref, *args, **kwargs):
        super().__init__(*args, **kwargs)
        # Check model ref class is subclass for Model
        from fireo.models import Model
        if not issubclass(model_ref, Model):
            raise errors.ReferenceTypeError(f'Reference model "{model_ref.__name__}" must be inherit from Model class')
        self.model_ref = model_ref
        self.auto_load = True
        self.on_load = None
github octabytes / FireO / src / fireo / fields / fields.py View on Github external
def __init__(self, model_ref, *args, **kwargs):
        super().__init__(*args, **kwargs)
        # Check model ref class is subclass for Model
        from fireo.models import Model
        if not issubclass(model_ref, Model):
            raise errors.ReferenceTypeError(f'Reference model {model_ref.__name__} must be inherit from Model class')
        self.model_ref = model_ref
        self.auto_load = True
        self.on_load = None