def __call__(self): """Determine inherited view and attempt to find suitable collage view. If a view can't be determined, render fallback view. If the view does not exist, render an error message. """ layout = self.context.getLayout() name = self.mapping.get(layout, self.fallback_view_name) spec = providedBy(self.context), ICollageBrowserLayer lookup = getSiteManager().adapters.lookup factory = lookup(spec, Interface, name=name) if factory is None: name = None factory = lookup(spec, Interface, name=self.error_view_name) if factory is None: raise ComponentLookupError( "Layout not found: %s (and unable to render error view)." % layout) view = factory(self.context, self.request) if name is None: view.notfoundlayoutname = layout view.__alias__ = self.__alias__ return view()
def getSettings(site): registry = site.getSiteManager().getUtility(IRegistry) try: return registry.forInterface(ISettings) except: log_exc() raise ComponentLookupError(ISettings)
def browserDefault(self, request): """See zope.publisher.browser.interfaces.IBrowserPublisher""" # XXX this re-implements zope.app.publisher.browser.getDefaultViewName() # to break our only dependency on it. view_name = getSiteManager(None).adapters.lookup( map(providedBy, (self.context, request)), IDefaultViewName) if view_name is None: raise ComponentLookupError("Couldn't find default view name", self.context, request) view_uri = "@@%s" % view_name return self.context, (view_uri, )
def getSiteManager(self): self.called = True from zope.component import ComponentLookupError raise ComponentLookupError()
def get_settings(context): try: return getUtility(IRegistry).forInterface(IFeedSettings) except KeyError: raise ComponentLookupError(IFeedSettings)