Merge lp:~leonardr/lazr.restful/561521 into lp:lazr.restful
| Status: | Merged |
|---|---|
| Approved by: | Edwin Grubbs on 2010-04-14 |
| Approved revision: | 130 |
| Merged at revision: | not available |
| Proposed branch: | lp:~leonardr/lazr.restful/561521 |
| Merge into: | lp:lazr.restful |
| Diff against target: |
436 lines (+123/-47) 5 files modified
src/lazr/restful/NEWS.txt (+8/-3) src/lazr/restful/_resource.py (+46/-13) src/lazr/restful/docs/webservice-declarations.txt (+6/-13) src/lazr/restful/docs/webservice.txt (+62/-17) src/lazr/restful/version.txt (+1/-1) |
| To merge this branch: | bzr merge lp:~leonardr/lazr.restful/561521 |
| Related bugs: |
| Reviewer | Review Type | Date Requested | Status |
|---|---|---|---|
| Edwin Grubbs (community) | 2010-04-14 | Approve on 2010-04-14 | |
|
Review via email:
|
|||
Description of the Change
This branch fixes bug 561521, in which a Launchpad test was found to fail on some Lucid installs because modifications dictated by PATCH requests happened in a nondeterministic order. This branch enforces a 1) deterministic order that's 2) less likely to cause problems.
The new order is less likely to cause problems because all of an entry's fields that are handled by mutator methods are saved until last. For testability purposes, I defined a helper function get_entry_
I also did some drive-by cleanup of test headings.
I have one slight misgiving about the get_entry_
You could argue that I'm really looking for an instance of PropertyWithMut
| Leonard Richardson (leonardr) wrote : | # |
| Edwin Grubbs (edwin-grubbs) wrote : | # |
Hi Leonard,
This branch looks good. I just have one comment below.
merge-conditional
-Edwin
>=== modified file 'src/lazr/
>--- src/lazr/
>+++ src/lazr/
>@@ -1988,3 +1988,36 @@
> """The URL to the description of the object's full representation."""
> return "%s#%s-full" % (
> self._service_
>+
>+
>+def get_entry_
>+ """Return the entry's fields in the order they should be written to.
>+
>+ The ordering is intended to 1) be deterministic for a given schema
>+ and 2) minimize the chance of conflicts. Fields that are just
>+ fields come before fields (believed to be) controlled by
>+ mutators. Within each group, fields are returned in the order they
>+ appear in the schema.
>+
>+ :param entry: An object that provides IEntry.
>+ :return: A list of 2-tuples (field name, field object)
>+ """
>+ non_mutator_fields = []
>+ mutator_fields = []
>+ field_implement
>+ for name, field in getFieldsInOrde
>+ if name.startswith
>+ # This field is not part of the web service interface.
>+ continue
>+
>+ add_to = non_mutator_fields
>+ # If this field is secretly a subclass of lazr.delegates
>+ # Passthrough (but not a direct instance of Passthrough), put
>+ # it at the end -- it's probably controlled by a mutator.
>+ implementation = field_implement
>+ if (issubclass(
>+ and not implementation.
>+ add_to = mutator_fields
>+ add_to.
>+ return non_mutator_fields + mutator_fields
Setting the add_to variable makes it a little harder to follow the
logic. I would prefer getting rid of it and using an if/else with
mutator_

Oh, I should mention that in addition to testing the unit tests, I tested this branch in conjunction with Launchpad to make sure it made the test failure go away. (The test that failed was webservice/ xx-distribution .txt)