Comment 2 for bug 583318

Revision history for this message
James Westby (james-w) wrote : Re: [Bug 583318] Re: Add shim objects for looked-up entries, similar to top-level collections

On Thu, 20 May 2010 17:59:32 -0000, Leonard Richardson <email address hidden> wrote:
> Actually all entry objects would benefit from starting out as empty
> shims. If you write bug.owner.someNamedOperation() there's no reason to
> actually get a representation of bug.owner.

One thing to be careful of is that

  lp.me.someNamedOperation()

still works.

If you POST to

  /+me/

then you get a redirect (302 I believe), check that the http library
doesn't turn this in to a GET of /~your-id/. The HTTP rfc says that
anything but GET or HEAD shouldn't automatically follow a 302.

Also, txrestfulclient uses shims, but for a different reason, because
making __getattr__ return a Deferred would be both ugly and really hard
to use. It still does the intermediate GET requests, but I should see
about short circuiting that.

What it does have to have is an explicit way to resolve (lp_resolve()
was picked), so that you control when you get a deferred. This means
that you don't have to trigger a GET when anything is done to the
object. If you use shims for every attribute then I guess you have to
have the shim check for a representation for during __getattr__, __eq__,
__str__, etc.

Thanks,

James