def grok(self, name, interface, module_info, config, **kw): # This `InstanceGrokker` will be called for every instance of # `InterfaceClass` - that is, for every interface defined in an # application module! So we have to do our own filtering, by # checking whether each interface includes the `grok.restskin()` # directive, and skipping those that do not. restskin = grok.restskin.bind(default=_restskin_not_used ).get(interface) if restskin is _restskin_not_used: # The restskin directive is not actually used on the found # interface. return False if not interface.extends(grok.IRESTLayer): # For REST layers it is required to extend IRESTLayer. raise GrokError( "The grok.restskin() directive is used on interface %r. " "However, %r does not extend IRESTLayer which is " "required for interfaces that are used as layers and are to " "be registered as a restskin." % (interface.__identifier__, interface.__identifier__), interface ) config.action( discriminator=('restprotocol', restskin), callable=zope.component.interface.provideInterface, args=(restskin, interface, IRESTSkinType) ) return True
def grok(self, name, interface, module_info, config, **kw): skin = grokcore.view.skin.bind(default=_skin_not_used).get(interface) if skin is _skin_not_used: # The skin directive is not actually used on the found interface. return False if not interface.extends(IBrowserRequest): # For layers it is required to extend IBrowserRequest. raise GrokError( "The grok.skin() directive is used on interface %r. " "However, %r does not extend IBrowserRequest which is " "required for interfaces that are used as layers and are to " "be registered as a skin." % (interface.__identifier__, interface.__identifier__), interface ) config.action( discriminator=('utility', IBrowserSkinType, skin), callable=zope.component.interface.provideInterface, args=(skin, interface, IBrowserSkinType) ) return True