> We're using the zca as the way our components interact, by instantiating
>> them inside adapters of request, context, and sometimes view. This is still
>> being done using the registry attached to request, so it's not the global
>> zca registry or global zca api. ie we get them by doing:
>>
>> # get the right kind of Foobar for current context & view
>> adapter_of_foobar = request.registry.queryAdapter(request, context, view)
>>
>
> I guess we're going off on a tangent here, but how does queryAdapter know
> how to get the right kind of Foobar?
>

Apologies, I was responding too quickly, and didn't put the signature in
correctly, it gets looked up according to which interfaces the adapter is
registered as adapting, and which interfaces the adaptees provide. So to
get a multi adapter adapting context, view, and request, where the adapter
itself provides the IFoobar interface, we'd do something like this:

# called from a view, where request and context have been set as attributes
of the view object
request.registry.queryMultiAdapter( (self.context, self, self.request),
IFoobar )

The specification of which interfaces are adapted and provided can be done
either in the adapter class itself, or in ZCML.
For example, this adapter class would get found and instantiated by the
above, when asking for an object providing the IFoobar interface,  and the
args passed in provide the IContent, IRequest, and IEditView interfaces
respectively.

class FoobarAdapter(object):
  implements(IFoobar)
  adapts( IContent, IRequest, IEditView )

The great thing is the look up is smart about interface inheritance, and
you can optionally provide string name keys too. I can definitely not do it
justice, but it's absolutely worth learning about. I heard it referred to
somewhere as being "like dependency injection on steroids". =)

A good explanation with examples is here:
http://www.muthukadan.net/docs/zca.html

There's also good stuff in "Web Component Development with Zope 3" by
Weitershausen, and Professional Plone Development by Aspeli.

HTH
iain










> --
> You received this message because you are subscribed to the Google Groups
> "pylons-discuss" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/pylons-discuss/-/EqyPEdN-B2YJ.
>
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/pylons-discuss?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en.

Reply via email to