You can do IMyInterface(context) looks-ups with Zope 3 and it somehow automatically maps to getAdapter().
However does there exist multi-adapter equivalent. Something like:
portal_state = IPortalState((self.context, self.request))
would map to
portal_state = getMultiAdapter((self.context, self.request), interface=IPortalState)
There isn't such a short-cut; your first example is adapting a tuple (a general case that needs to be supported too).
This has been discussed numerous times on the lists, but I cannot recall the ins and outs of the details. You could start with the following thread if you have to know: http://tech.groups.yahoo.com/group/zope/message/185605
No, there's no shorthand for multi-adapter lookup. The reason given in the discussion toward the end of http://groups.google.com/group/zope-core-dev/browse_thread/thread/156acde2c8e799c7/63ca158f076ed010?pli=1 is that some users of zope.interface rely on being able to do single adaptation of tuples.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.