[Twisted-Python] Code question - semantic meaning of IServiceCollection(parent, parent)

Jonas Brunsgaard jonas.brunsgaard at gmail.com
Mon May 26 17:23:43 MDT 2014


Thanks Dustin, I got it ;)


On Mon, May 26, 2014 at 2:57 PM, Dustin J. Mitchell <dustin at v.igoro.us>wrote:

> It's certainly not an obvious syntax, but it "casts" the first
> argument into a provider of the interface, defaulting to the second
> argument if this is not possible.
>
> For example, if `parent` isn't a provider of `IServiceCollection`, but
> there's an adapter registered to covert to `IServiceCollection` from
> `type(parent)`, then that adapter will be called.  If there's no such
> adapter, the cast will return `parent`.
>
> Dustin
>
> On Mon, May 26, 2014 at 8:27 AM, Jonas Brunsgaard
> <jonas.brunsgaard at gmail.com> wrote:
> > Hello all
> >
> > Will someone explain to me what happens when you call an Interface with
> > arguments, and why the same argument twice?
> >
> >
> >
> > My problem is to understand the semantics of the line
> >
> >     parent = IServiceCollection(parent, parent)
> >
> >
> >
> > part of
> >
> >     def setServiceParent(self, parent):
> >
> >         if self.parent is not None:
> >
> >             self.disownServiceParent()
> >         parent = IServiceCollection(parent, parent)
> >
> >         self.parent = parent
> >         self.parent.addService(self)
> >
> >
> >
> > in twisted.application.service
> >
> > Thanks in advance.
> >
> >
> > _______________________________________________
> > Twisted-Python mailing list
> > Twisted-Python at twistedmatrix.com
> > http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
> >
>
> _______________________________________________
> Twisted-Python mailing list
> Twisted-Python at twistedmatrix.com
> http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://twistedmatrix.com/pipermail/twisted-python/attachments/20140527/cdfc6260/attachment.html>


More information about the Twisted-Python mailing list