self.invokeFactory could not adapt (only with kss)

David Bain david.bain at alteroo.com
Tue Oct 23 12:56:02 UTC 2007


I have some code that creates a simple folder.
It seems that when invokeFactory is called via a "kss wrapper", the result
is a 'could not adapt' error.
Maybe I'm misinterpreting this, anyone familiar with this issue? Would love
your assistance.

I've included traceback and snippets of the original code, I figure that
should help.

Note:

   - that when the method is called directly or via a non-kss based
   method it works fine.
   - When called wrapped in a kss based method I get a 'could not adapt'
   error.


the traceback when called from my KSS based method:

2007-10-23 07:46:06 ERROR Zope.SiteErrorLog
http://localhost:8081/Plone/poleroll/my-roll/kss_do_stuff/do_stuff
Traceback (innermost last):
  Module ZPublisher.Publish, line 119, in publish
  Module ZPublisher.mapply, line 88, in mapply
  Module ZPublisher.Publish, line 42, in call_object
  Module <wrapper>, line 5, in wrapper
  Module kss.core.actionwrapper, line 238, in apply
  Module Products.peopleroll.browser.dostuff, line 12, in do_stuff
  Module Products.peopleroll.content.organization, line 276, in do_the_stuff
  Module Products.CMFCore.PortalFolder, line 315, in invokeFactory
  Module Products.CMFCore.TypesTool, line 716, in constructContent
  Module Products.CMFCore.TypesTool, line 276, in constructInstance
  Module Products.CMFCore.TypesTool, line 450, in _constructInstance
  Module Products.ATContentTypes.content.folder, line 7, in addATFolder
  Module OFS.ObjectManager, line 348, in _setObject
  Module zope.app.container.contained, line 365, in notifyContainerModified
  Module zope.event, line 23, in notify
  Module zope.component.event, line 26, in dispatch
  Module zope.component._api, line 130, in subscribers
  Module zope.component.registry, line 290, in subscribers
  Module zope.interface.adapter, line 535, in subscribers
  Module kss.core.kssview, line 127, in _eventRedispatcher
  Module zope.component._api, line 130, in subscribers
  Module zope.component.registry, line 290, in subscribers
  Module zope.interface.adapter, line 535, in subscribers
  Module plone.app.kss.globalui, line 23, in
attributesTriggerDocumentBylineReload
  Module kss.core.kssview, line 169, in getCommandSet
TypeError: ('Could not adapt', <Products.Five.metaclass.DoTheStuff object at
0x6ca7470>, <InterfaceClass plone.app.kss.commands.interfaces.IZopeCommands
>)


The Original Method from a content type called an organization:
----snip---
    security.declarePublic('do_the_stuff')
    def do_the_stuff(self,results, **kwargs):
        """
         do stuff here
        """
        dtnow = DateTime()
        year = str(DateTime.year(dtnow))
        if year not in self.contentIds():
            self.invokeFactory(id=year,title=year,type_name="Folder")
----snip---


The KSS class:
from kss.core import KSSView, kssaction
from Acquisition import aq_inner
from datetime import datetime

class DoTheStuff(KSSView):

    @kssaction
    def do_stuff(self, widgetid='blah', href='yah.com'):
        ksscore = self.getCommandSet('core')
        selector = ksscore.getHtmlIdSelector('organization-results')
        do_it = self.context.do_the_stuff
        output = do_it()

        ksscore.replaceInnerHTML(selector,
                '<h1>%s</h1>' % output)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.plone.org/pipermail/plone-product-developers/attachments/20071023/f5fd6fcb/attachment-0001.html>


More information about the Product-Developers mailing list