Sorry if the mail content is a bit lengthy, but I need to put all the info.
In the following code, there are 2 render functions: - one using the interface (ok) - the other uses the utility (ko) Here is the code snippet: ----- class AMenuItem(menu.BrowserMenuItem): grok.implements(IAMenuItem, IMenuItemType) grok.provides(IMenuItemType) grok.name('menuitem') description = 'coucou' def __init__(self, **kw): self.kw = kw def __call__(self, context, request): super(menu.BrowserMenuItem, self).__init__(context, request) grok.global_utility(AMenuItem) class AMenuItemAdapter(grok.MultiAdapter): grok.adapts(ICdcmenu, IBrowserRequest) grok.implements(IAMenuItem) title = 'hello' description = 'toto' def __init__(self, context, request): self.context = context self.request = request class Index(grok.View): grok.context(Cdcmenu) a_menu = Menubar() a_menu('toto', 'Titre toto', 'Toto est de retour') id = 'menuitem' def getMenuItemType(self): return component.getUtility(IMenuItemType, self.id) # this function render correctly # def render(self): # resultat = [] # for name, item in component.getAdapters((self.context, self.request), IAMenuItem): # resultat.append(item.description) # return pformat(resultat) # this function does not render correctly def render(self): resultat = [] for name, item in component.getAdapters((self.context, self.request), self.getMenuItemType()): resultat.append(item.description) return pformat(resultat) --- If I try to create a utility subclassing interface.Interface and implementing IMenuItemType like this: class OtherMenuItem(interface.Interface): grok.implements(IAMenuItem, IMenuItemType) I get the following error: File "/home/simon/.buildout/eggs/zope.interface-3.4.1-py2.4-linux-i686.egg/zope/interface/interface.py", line 488, in __init__ raise InvalidInterface("Concrete attribute, " + name) zope.configuration.xmlconfig.ZopeXMLConfigurationError: File "/mnt/backup_software/virtualgrok/Menutest/etc/site.zcml", line 4.2-4.32 ZopeXMLConfigurationError: File "/mnt/backup_software/virtualgrok/Menutest/src/menutest/configure.zcml", line 5.2-5.27 InvalidInterface: Concrete attribute, __implements_advice_data__ Thanks for your help Simon Elbaz On Wed, Feb 4, 2009 at 2:37 AM, Dan Korostelev <nad...@gmail.com> wrote: > 2009/2/4 Simon Elbaz <elbazsim...@gmail.com>: > > When I look to the getMenuItemType() function, it returns a utility ( > > return zope.component.getUtility(IMenuItemType, self.id)) and the > > consequence is that the adapter lookup returns nothing in getMenuItems. > > That's strange, because that IMenuItemType utility is the interface > that the menu item adapters are registered as providing. It works as > intended here in plain zope3. Can you provide some more info? > > -- > WBR, Dan Korostelev >
_______________________________________________ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users