Ticket #13688 (new Bug)

Opened 3 years ago

Import a Plone Site with personal Grok event handlers: AttributeError

Reported by: ndrezet Owned by:
Priority: minor Milestone: 4.x
Component: Unknown Version: 4.3
Keywords: dexterity, grok, import Cc:

Description

While trying to import a whole Plone site with some personal Dexterity contents, a Grok event handler raise an AttributeError.

  • The event handler, constructed with a decorator, works well on the original site
@grok.subscribe(IProgram, IObjectAddedEvent)
def createResourcesFolder(program, event):
    program.invokeFactory(id="resources", 
                      type_name="Folder", 
                      title="Resources", 
                      description="My resources")
  • The error traceback during the import into another Plone instance
Traceback (innermost last):
  Module ZPublisher.Publish, line 126, in publish
  Module ZPublisher.mapply, line 77, in mapply
  Module ZPublisher.Publish, line 46, in call_object
  Module OFS.ObjectManager, line 620, in manage_importObject
  Module OFS.ObjectManager, line 642, in _importObjectFromFile
  Module OFS.ObjectManager, line 358, in _setObject
  Module zope.event, line 31, in notify
  Module zope.component.event, line 24, in dispatch
  Module zope.component._api, line 136, in subscribers
  Module zope.component.registry, line 321, in subscribers
  Module zope.interface.adapter, line 585, in subscribers
  Module zope.component.event, line 32, in objectEventNotify
  Module zope.component._api, line 136, in subscribers
  Module zope.component.registry, line 321, in subscribers
  Module zope.interface.adapter, line 585, in subscribers
  Module OFS.subscribers, line 113, in dispatchObjectMovedEvent
  Module zope.container.contained, line 153, in dispatchToSublocations
  Module zope.component._api, line 136, in subscribers
  Module zope.component.registry, line 321, in subscribers
  Module zope.interface.adapter, line 585, in subscribers
  Module example.conference.program, line 161, in createResourcesFolder
  Module plone.dexterity.content, line 385, in invokeFactory
  Module Products.CMFCore.PortalFolder, line 292, in invokeFactory
  Module Products.CMFCore.TypesTool, line 833, in constructContent
  Module Products.CMFCore.TypesTool, line 311, in constructInstance
  Module Products.CMFCore.TypesTool, line 552, in _constructInstance
  Module Products.ATContentTypes.content.folder, line 3, in addATFolder
  Module plone.app.folder.base, line 45, in __init__
  Module Products.Archetypes.BaseFolder, line 255, in __init__
  Module Products.Archetypes.BaseFolder, line 64, in __init__
  Module Products.Archetypes.BaseFolder, line 149, in Title
  Module Products.Archetypes.BaseObject, line 240, in getField
  Module Products.Archetypes.BaseObject, line 817, in Schema
  Module zope.component.hookable, line 33, in __call__
  Module zope.component.hooks, line 104, in adapter_hook
  Module archetypes.schemaextender.extender, line 125, in cachingInstanceSchemaFactory
AttributeError: 'NoneType' object has no attribute 'aq_acquire'

It appears that it's the getSite() instruction in cachingInstanceSchemaFactory function which is faulty by being not able to find the site object.

Note: See TracTickets for help on using tickets.