Activity log for bug #400477

Date Who What changed Old value New value Message
2009-07-17 01:56:58 Curtis Hovey bug added bug
2009-07-17 02:21:25 Curtis Hovey lazr.restful: status New Triaged
2009-07-17 02:21:34 Curtis Hovey lazr.restful: importance Undecided High
2009-07-17 02:22:03 Curtis Hovey bug task added launchpad-foundations
2009-07-17 02:22:17 Curtis Hovey launchpad-foundations: status New Triaged
2009-07-17 02:22:22 Curtis Hovey launchpad-foundations: importance Undecided High
2009-07-17 02:22:25 Curtis Hovey lazr.restful: importance High Low
2009-07-17 14:07:27 Francis J. Lacoste summary FieldMarshallers do not honor a Field's set() rules Named operations bypass any normalization done by fields
2009-07-17 14:10:44 Francis J. Lacoste description The FieldMarshaller do no use a field's rule to validate or normalize data. So while the UI may use a field (or the help of a widget) to correct data instead of raising an error, the API will accept bad input. The direct solution would be to create a companion marshaller for each field, much like the UI may use a companion widget. The does not seem like a practical solution because specialized fields will will rarely be used except by the party that creates them; they are not valuable in lazr.restful. I propose that Fields place rules in commonly named functions that FieldMarshallers can call when the exist. Maybe there should be an IFieldMarshallerFriend interface that defines common methods like normalize(). For example, StripedTextField and its descendent NoneableTextLine both want a normalized value. The rules can be moved from their widgets to the fields themsleves. SimpleFieldMarshaller._marshall_from_json_data() could use the method to clean the data. This approach reduces the number of widgets and marshallers required to manage data, and allows lazr.restful to work with any field that does-the-right-thing. Thus class StrippedTextLine(TextLine): implements(IStrippedTextLine) def normalize(self, value): """Return the value striped of leading and trailing whitespace.""" return value.strip() class SimpleFieldMarshaller: implements(IFieldMarshaller) def _marshall_from_json_data(self, value): .... if safe_hasattr(self.field, 'normalize'): value = self.field.normalize(value) return value This may relate to bug 373370, where the widget knows that '' should be converted to None. When calling named operations on the web service, the IField API is only used to validate the parameter. The IField.set() method is never called (because there is no real context to which to assign the value). When IField do normalization in the set() method, that normalization won't happen on named operation parameters. The fix would be to create a "parameters context object" which is bound to the field and call set() to set the parameters value. And then retrieve the value to use for the underlying method calls from this parameter object.
2009-07-17 14:10:44 Francis J. Lacoste tags api
2009-10-09 00:12:35 Curtis Hovey tags api api tech-debt
2012-01-01 08:08:50 Robert Collins launchpad: importance High Low
2017-05-15 13:50:34 Curtis Hovey removed subscriber Curtis Hovey