Merge lp:~benji/lazr.restful/bug-539070 into lp:lazr.restful
| Status: | Merged |
|---|---|
| Approved by: | Edwin Grubbs on 2010-11-04 |
| Approved revision: | 159 |
| Merged at revision: | 161 |
| Proposed branch: | lp:~benji/lazr.restful/bug-539070 |
| Merge into: | lp:lazr.restful |
| Diff against target: |
119 lines (+59/-6) 3 files modified
src/lazr/restful/_resource.py (+18/-3) src/lazr/restful/tales.py (+9/-2) src/lazr/restful/tests/test_error.py (+32/-1) |
| To merge this branch: | bzr merge lp:~benji/lazr.restful/bug-539070 |
| Related bugs: |
| Reviewer | Review Type | Date Requested | Status |
|---|---|---|---|
| Edwin Grubbs (community) | code | 2010-11-03 | Approve on 2010-11-04 |
|
Review via email:
|
|||
Description of the Change
Bug 539070 describes a case where an error message doesn't give much of a hint as to where to start looking for a problem. This branch enhances the error message with the interface in question so the developer knows where to look.
- 157. By Benji York <benji@benji-laptop> on 2010-11-03
-
checkpoint
- 158. By Benji York on 2010-11-04
-
finish up reworking the error reporting
- 159. By Benji York on 2010-11-04
-
remove some dead code that snuck in
| Benji York (benji) wrote : | # |
I removed the dead code. Thanks.
| Jonathan Lange (jml) wrote : | # |
Thanks so much for working on this change Benji – it promises to save me much hair-pulling in the future.
Perhaps it would also be worth adding a similar try/except/whence thingummy around WadlTopLevelEnt
class WadlTopLevelEnt
"""Namespace for WADL functions that operate on top-level entry links."""
def __init__(self, entry_link):
def type_link(self):
return EntryAdapterUti

Hi Benji,
The changes you made look good for showing which interface attribute tries to set the schema to a class that doesn't have an IEntry adapter. I just have one comment below.
-Edwin
>=== modified file 'src/lazr/ restful/ tales.py' restful/ tales.py 2010-08-24 18:57:50 +0000 restful/ tales.py 2010-11-04 19:25:16 +0000 oder, CollectionResource, lity, IObjectLink, RESTUtilityBase) _resource import UnknownEntryAdapter interfaces import ( Operation, IResourceGETOpe ration, __name_ _) lity.forSchemaI nterface( web_service_ request( )) lity.forSchemaI nterface( web_service_ request( )) pter, e: interface, self.field. getName( ))) entry_page_ type_link
>--- src/lazr/
>+++ src/lazr/
>@@ -29,6 +29,7 @@
> from lazr.restful import (
> EntryResource, ResourceJSONEnc
> EntryAdapterUti
>+from lazr.restful.
> from lazr.restful.
> ICollection, ICollectionField, IEntry, IJSONRequestCache,
> IReferenceChoice, IResourceDELETE
>@@ -540,8 +541,15 @@
> raise TypeError("Field is not of a supported type.")
> assert schema is not IObject, (
> "Null schema provided for %s" % self.field.
>- return EntryAdapterUti
>- schema, get_current_
>+ try:
>+ return EntryAdapterUti
>+ schema, get_current_
>+ except UnknownEntryAda
>+ e.whence = (
>+ 'Encountered as a result of the entry interface %r, field %r.'
>+ % (self.field.
>+ raise e
>+ return adapter.
Can you remove this line that can never be reached?