def json_data(self, name): """Get a JSON compatible structure for the named attribute """ # fetch the field by name field = api.get_field(self.context, name) # bail out if we have no field if not field: return None fieldmanager = IFieldManager(field) return fieldmanager.json_data(self.context)
def get(self, name): """Get the value of the field by name """ # fetch the field by name field = api.get_field(self.context, name) # bail out if we have no field if not field: return None # call the field adapter and set the value fieldmanager = IFieldManager(field) return fieldmanager.get(self.context)
def set(self, name, value, **kw): """Set the field to the given value. The keyword arguments represent the other field values to integrate constraints to other values. """ # fetch the field by name field = api.get_field(self.context, name) # bail out if we have no field if not field: return False # call the field adapter and set the value fieldmanager = IFieldManager(field) return fieldmanager.set(self.context, value, **kw)
def json_data(self, name): """Get a JSON compatible structure for the named attribute """ # Check the write permission of the context # XXX: This should be done on field level by the field manager adapter if not self.can_write(): raise Unauthorized("You are not allowed to modify this content") # fetch the field by name field = api.get_field(self.context, name) # bail out if we have no field if not field: return None fieldmanager = IFieldManager(field) return fieldmanager.json_data(self.context)
def get(self, name): """Get the value of the field by name """ # Check the read permission of the context # XXX: This should be done on field level by the field manager adapter if not self.can_write(): raise Unauthorized("You are not allowed to modify this content") # fetch the field by name field = api.get_field(self.context, name) # bail out if we have no field if field is None: return None # call the field adapter and set the value fieldmanager = IFieldManager(field) return fieldmanager.get(self.context)
def set(self, name, value, **kw): """Set the field to the given value. The keyword arguments represent the other field values to integrate constraints to other values. """ # Check the write permission of the context # XXX: This should be done on field level by the field manager adapter if not self.can_write(): raise Unauthorized("You are not allowed to modify this content") # fetch the field by name field = api.get_field(self.context, name) # bail out if we have no field if not field: return False # call the field adapter and set the value fieldmanager = IFieldManager(field) return fieldmanager.set(self.context, value, **kw)