Ticket #2270 (new enhancement)

Opened 3 years ago

Last modified 2 years ago

getServiceProvider()

Reported by: mithrandi Assigned to: mithrandi
Priority: normal Milestone:
Component: Mantissa Severity: normal
Keywords: Cc:
Estimated Completion (YYYY/MM/DD): Branch:
Author:

Description

So, I have this utility function in my codebase that looks something like this:

def getServiceProvider(store, iface):
    """
    Retrieve the provider of a particular service interface.

    The interface is located as a powerup in the application store.

    @param store: the site store, or any substore thereof.
    @param iface: the service interface required.
    """
    siteStore = store
    while siteStore.parent:
        siteStore = siteStore.parent

    ls = IRealm(siteStore)
    la = ls.accountByAddress(u'Fusion', None)
    return iface(la)

In case it's not obvious, Fusion is my offering's name. My actual implementation has some caching going on, but that's besides the point; namely, that this sort of functionality should probably be part of Mantissa, and a little less hackish. I'd like to contribute a patch for this, but I'm not sure what form a more generic version of this written for Mantissa would look like, so a few pointers or some discussion about this with someone who has a better idea of what's going on, would be great.

Change History

08/24/07 21:17:22 changed by mithrandi

  • owner changed from amir to glyph.

08/24/07 21:20:31 changed by mithrandi

Re-reading the ticket description, I realise I don't really explain what the heck a "service provider" is; what I mean by that is an object, localized to this specific Mantissa site, that provides the required interface. This layer of abstraction lets me provide certain services (for example, semi-static external data sources) through different implementations; currently I have all of my services implemented locally in the app store, but later I can have them located on a remote node, and provide an implementation that forwards the operations to the remote node via AMP and so on.

Please tell me if any of this sounds like I'm heading down the wrong path.

08/26/07 15:59:46 changed by exarkun

Glyph and I were talking about this. One thing I said looked vaguely like this:

class Junk(Item):
    offering = magicofferingthing()

    def crud(self):
        c = ICrud(self.offering.appStore())
        ...

Maybe appStore as a method isn't awesome, but that's the general idea. The implementation might look something like what's in the description of this ticket. Something else would need to set offering, of course. Presumably the product installation code.

This has the added advantage over what you've suggested of making Junk much more easily unit testable, which is my primary interest in an API such as this.

08/28/07 18:43:30 changed by glyph

  • owner changed from glyph to mithrandi.

This sounds like it might be an interesting infrastructure task, so please keep working on it. I don't think it should be assigned to me at this stage though :).

01/10/08 19:28:39 changed by mithrandi

  • branch changed.
  • author changed.

This ticket probably falls under the general umbrella of #2191.

jethro@divmod.org