You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The call to base_helpers.get_user_ids() makes a network API call, which is not what you would expect from object instantiation. We need a way to either remove this until the synchronisation (it makes more sense to fail on sync with 'user not found' that on object instantiation), or at the very least to allow clients to force some kind of lazy validation.
The use case that highlighted this was trying to display the object JSON in the Django admin view, ironically in order to assist with debugging of synchronisation issues. If I want to load in an object, and serialize it, without pushing to Base, how can I do that?
The text was updated successfully, but these errors were encountered:
def _validate_field(self, field_name, field_value):
if field_value is None:
return True
if field_name == 'owner_id' and field_value not in base_helpers.get_user_ids():
return False
return super(ContactModelSerializer, self)._validate_field(field_name, field_value)
def _get_value(self, field_name):
"""
Gets the value of the field to be assigned to this instance.
First sees whether the field has a get_X function (where X is the BaseCRM field name) and if
so, runs it to derive the value from there.
If that doesn't exist, we check whether the value is specified on this class and if so,
assign that (calling the method if applicable) -- if not, we see whether the instance has
an identically-named field and we fall back to the value of that.
"""
...
# confirm that whatever we've ended up with is safe to set
if self._validate_field(field_name, val):
return val
else:
return None
I think making self._validate_field() an optional/toggleable call via a settings - with the assumption (yes, I know) that val is a legitimate one
# confirm that whatever we've ended up with is safe to set
if (
settings.BASECRM_DO_NOT_VALIDATE_ON_INSTANTIATION
or self._validate_field(field_name, val
):
return val
else:
return None
The
ContactModelSerializer
andDealModelSerializer
classes both include this line in the field validation method:The call to
base_helpers.get_user_ids()
makes a network API call, which is not what you would expect from object instantiation. We need a way to either remove this until the synchronisation (it makes more sense to fail on sync with 'user not found' that on object instantiation), or at the very least to allow clients to force some kind of lazy validation.The use case that highlighted this was trying to display the object JSON in the Django admin view, ironically in order to assist with debugging of synchronisation issues. If I want to load in an object, and serialize it, without pushing to Base, how can I do that?
The text was updated successfully, but these errors were encountered: