AttributeError: 'module' object has no attribute 'NavigationViewlet' - plone

here is my traceback from a Plone 4.2.1 installation (on SuSE Linux):
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 638, in _importObjectFromFile
Module ZODB.ExportImport, line 92, in importFile
Module transaction._transaction, line 260, in savepoint
Module transaction._transaction, line 257, in savepoint
Module transaction._transaction, line 690, in __init__
Module ZODB.Connection, line 1123, in savepoint
Module ZODB.Connection, line 587, in _commit
Module ZODB.ExportImport, line 176, in _importDuringCommit
AttributeError: 'module' object has no attribute 'NavigationViewlet'
The strange thing, that I do not understand is, why only one Plone Site shows this error during import into an instance newer than Plone 4.1.5?
The Plone site has only the following additional plugins/products installed (as others too, but they all work fine):
LinguaPlone
PloneFormGen
Products.ZSyncer
collective.quickupload
So, where is my mistake/error?
Thanx for any help, because the site is too big now to "rebuild" it in a new Plone instance from scratch :-(

The plone.app.layout.viewlets.links.NavigationViewlet was removed in plone.app.layout version 2.2 (see this entry into the HTML5 PLIP and this commit).
ZEXP imports into different version stacks are generally fraught with problems, exactly because of changing persistent object locations. You'll have to import to an earlier version of the software stack, then follow the regular Plone upgrade path to bring yourself up to a more recent version of Plone.
The upgrade scripts take care of removing references to removed viewlets like these, for example.

Related

Upgrade Plone 3.3.6 to either Plone 4.3.7 or Plone 5 (Error: 'tuple' object has no attribute 'remove')

I'm attempting an upgrade of an existing site from Plone 3.3.6 to Plone 4.3.7, and then on to Plone 5.0.
The existing site is very small, and has no add-on Products installed (vanilla Plone, vanilla template, etc.) It did have CacheFu installed, but after some earlier obvious errors with that, I removed it prior to the upgrade. I'm simply copying the contents of var/filestorage (Data.fs, etc) from v3 site to v4 site and re-running buildout.
In Plone 4.3.7, when running the UPGRADE option, I see a lot of successful activity, and then the following error at the bottom:
Upgrade aborted. Error:
Traceback (most recent call last):
File "/usr/local/Plone4_migration/buildout-cache/eggs/Products.CMFPlone-4.3.7-py2.7.egg/Products/CMFPlone/MigrationTool.py", line 259, in upgrade
step['step'].doStep(setup)
File "/usr/local/Plone4_migration/buildout-cache/eggs/Products.GenericSetup-1.7.7-py2.7.egg/Products/GenericSetup/upgrade.py", line 160, in doStep
self.handler(tool)
File "/usr/local/Plone4_migration/buildout-cache/eggs/plone.app.upgrade-1.3.18-py2.7.egg/plone/app/upgrade/v40/betas.py", line 99, in beta3_beta4
value.remove('Large Plone Folder')
AttributeError: 'tuple' object has no attribute 'remove'
If I skip Plone 4.x and jump right to Plone 5.0, I can't even run the UPGRADE feature, and just get the following error trace on the console:
2015-10-09 01:14:21 ERROR Zope.SiteErrorLog 1444371261.060.792132208718 http://www.example.com/example
Traceback (innermost last):
Module ZPublisher.Publish, line 127, in publish
Module ZPublisher.BaseRequest, line 444, in traverse
Module ZPublisher.BeforeTraverse, line 97, in __call__
Module Products.CMFCore.PortalObject, line 75, in __before_publishing_traverse__
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 plone.app.theming.plugins.hooks, line 33, in onRequest
Module plone.app.theming.policy, line 90, in isThemeEnabled
AttributeError: 'NoneType' object has no attribute 'enabled'
This is a known bug which has a fix that was not released yet: https://github.com/plone/Products.CMFPlone/issues/1134

PicklingError after upgrading to Plone 4.3

Site with Plone 4.2.5 was upgraded to Plone 4.3.4.
When doing a check-out of an object, the following error is shown:
2015-04-22T01:18:16 ERROR Zope.SiteErrorLog 1429676296.560.86437176197 http://localhost:8181/Plone/capa/##content-checkout
Traceback (innermost last):
Module ZPublisher.Publish, line 146, in publish
Module Zope2.App.startup, line 301, in commit
Module transaction._manager, line 89, in commit
Module transaction._transaction, line 329, in commit
Module transaction._transaction, line 443, in _commitResources
Module ZODB.Connection, line 559, in commit
Module ZODB.Connection, line 1123, in savepoint
Module ZODB.Connection, line 623, in _commit
Module ZODB.Connection, line 658, in _store_objects
Module ZODB.serialize, line 422, in serialize
Module ZODB.serialize, line 431, in _dump
PicklingError: Can't pickle <class 'plone.app.kss.interfaces.IPortalObject'>: import of module plone.app.kss.interfaces failed
No objects on the catalog provide plone.app.kss.interfaces.IPortalObject.
Any idea?
You should always read the Plone upgrade guide before doing a migration:
https://plone.org/documentation/manual/upgrade-guide/version/upgrading-plone-4.2-to-4.3/referencemanual-all-pages
plone.app.kss is no longer shipped with Plone 4.3.x. You have to re-add it to your buildout.cfg:
eggs =
...
plone.app.kss
Though, I would suggest that you clean up your ZODB after the upgrade. Otherwise you will run into problems since plone.app.kss is unmaintained.

Can't create Dexterity content type programatically in Plone 4.3.1

I created a new content type using the Dexterity manager in Site Setup. I'm able to successfully add content through the Plone user interface, but I've come to a point where I need to create the same object with a python script.
My first attempt was with invokeFactory:
context.invokeFactory("mycontenttype", id="test", Title="Test")
This same code works for "Folder" objects, but fails with my Dexterity type:
Traceback (innermost last):
Module ZPublisher.Publish, line 60, in publish
Module ZPublisher.mapply, line 77, in mapply
Module ZPublisher.Publish, line 46, in call_object
Module Shared.DC.Scripts.Bindings, line 322, in __call__
Module Products.PloneHotfix20130618.spamProtect, line 35, in _patched_bindAndExec
Module Shared.DC.Scripts.Bindings, line 359, in _bindAndExec
Module Products.PythonScripts.PythonScript, line 344, in _exec
Module script, line 7, in test
- <PythonScript at /three-year-plan/test>
- Line 7
TypeError: invokeFactory() takes at least 3 arguments (2 given)
After doing some more searching, I found several places referring to the following function:
from plone.dexterity.utils import createContentInContainer
Any attempt to import from plone.dexterity.utils in my python scripts ends up with a permissions error:
Traceback (innermost last):
Module ZPublisher.Publish, line 60, in publish
Module ZPublisher.mapply, line 77, in mapply
zModule ZPublisher.Publish, line 46, in call_object
Module Shared.DC.Scripts.Bindings, line 322, in __call__
Module Products.PloneHotfix20130618.spamProtect, line 35, in _patched_bindAndExec
Module Shared.DC.Scripts.Bindings, line 359, in _bindAndExec
Module Products.PythonScripts.PythonScript, line 344, in _exec
Module script, line 1, in test
- <PythonScript at /my-site/test>
- Line 1
Module AccessControl.ZopeGuards, line 305, in guarded_import
Unauthorized: import of 'plone.dexterity.utils' is unauthorized
Any help in resolving the errors above or alternative methods would be greatly appreciated. Version details are posted below for reference.
Version Overview
Plone 4.3.1 (4306)
CMF 2.2.7
Zope 2.13.19
Python 2.7.3 (default, Aug 1 2012, 05:14:39) [GCC 4.6.3]
PIL 1.7.8 (Pillow)
Dexterity Content Types 2.0.8
You should be able to use "invokeFactory" for this purpose. You call it on the container and pass it the type name as a string.
I'm not sure where your attempt to use the invokeFactory method went awry, but it does work. See http://developer.plone.org/reference_manuals/external/plone.app.dexterity/reference/manipulating-content-objects.html?highlight=invokefactory#adding-an-object-to-a-container for details.
Your guess is right: you have to use createContentInContainer.
But you cannot use it in a Python script because only the so called restricted Python is allowed [1]. Put it in a view [2].
As a reference have a look to:
http://developer.plone.org/reference_manuals/active/helloworld/extend/view.html
http://plone.org/documentation/faq/restricted-python-scripts

Issue upgrading PloneFormGen on a Plone 3.3.1 migration

I'm migrating a website from Plone 3.3.1 to Plone 4.3. The migration actually worked fine with no errors, but when I tried to update PloneFormGen to the current version (1.7.8), I get this:
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 Products.CMFQuickInstallerTool.QuickInstallerTool, line 580, in installProducts
Module Products.CMFQuickInstallerTool.QuickInstallerTool, line 512, in installProduct
- __traceback_info__: ('PloneFormGen',)
Module Products.GenericSetup.tool, line 350, in runAllImportStepsFromProfile
- __traceback_info__: profile-Products.PloneFormGen:default
Module Products.GenericSetup.tool, line 1100, in _runImportStepsFromContext
Module Products.GenericSetup.tool, line 1015, in _doRunImportStep
- __traceback_info__: pleonformgen
Module Products.PloneFormGen.setuphandlers, line 79, in importVarious
Module Products.PloneFormGen.setuphandlers, line 34, in update_kupu_resources
AttributeError: getPortalTypesForResourceType
Any thoughts? I saw something about Kupu having old references to linkable types, but I think this might be a different problem. I checked through my linkable resource types and they all seem to be the standard ones.
Thanks!
I suggest you check the "Resource Types" in the Visual Editor configlet on the Plone 3.3 side. Make sure it doesn't refer to any types that are either not installed or won't be available in 4.3. You may be able to eliminate the uninstalled types simply by saving the config.
And, make sure that PFG you upgrade to is 1.7.11+. There's a security advisory covering 1.7.8 and earlier.

Problem with a local utility used as a dependency in a product

Here's the problem. I have mynamespace.mypackage that has as a dependency mynamespace.mydependencypackage, that is a local utility. It's registered using component registry.
In config.py from mynamespace.mypackage, I have
DEPENDENCIES = ['mynamespace.mydependencypackage']
And in my mynamespace.mypackage's setuphandlers.py this dependency is installed if not already installed.
Problem is: if I reinstall mynamespace.mypackage through ZMI, everything seems to perfectly install (since no errors are shown) but I keep getting a ComponentLookupError when using methods in mynamespace.mypackage that gets the utility:
Module zope.component._api, line 207, in getUtility
ComponentLookupError: (<InterfaceClass MY_UTILITY_INTERFACE, '')
I can 'fix' this problem, by reinstalling the mynamespace.mydependencypackage in my setuphandlers.py or through the ZMI as well when reinstalling mynamespace.mypackage, but this doesn't seem the best solution for me.
What am I missing about Generic Setup here? I didn't make this utility persist any value on ZODB whatsoever. I can just forget about all these problems and create a BrowserView with utilities methods, but I want to understand first why am I having these problems.
EDIT: Now, I have a bigger problem. The TypeError: ('object.__new__(MyClass) is not safe, use Persistence.Persistent.__new__()', <function _reconstructor at 0xb7783e9c>, (<class 'mynamespace.mydependencypackage.package.MyClass'>, <type 'object'>, None)) is being shown. Full traceback:
Traceback (innermost last):
Module ZPublisher.Publish, line 110, in publish
Module ZPublisher.BaseRequest, line 429, in traverse
Module ZPublisher.BeforeTraverse, line 99, in __call__
Module Products.CMFCore.PortalObject, line 94, in __before_publishing_traverse__
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 zope.component.event, line 33, in objectEventNotify
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 zope.app.component.site, line 375, in threadSiteSubscriber
Module zope.app.component.hooks, line 61, in setSite
Module Products.CMFCore.PortalObject, line 75, in getSiteManager
Module ZODB.Connection, line 761, in setstate
Module ZODB.Connection, line 819, in _setstate
Module ZODB.serialize, line 604, in setGhostState
Module ZODB.serialize, line 597, in getState
Module copy_reg, line 48, in _reconstructor
TypeError: ('object.__new__(MyClass) is not safe, use Persistence.Persistent.__new__()', <function _reconstructor at 0xb7783e9c>, (<class 'mynamespace.mydependencypackage.package.MyClass'>, <type 'object'>, None))
It sounds like you have custom Python code in your setuphandlers.py file to install the dependency. Is there a reason you don't note the dependency in the metadata.xml file? Or can you show us that code?
When activating an add-on in Plone, it does a before/after comparison of various entities to support deactivation. Among these are local persistent utilities, as defined by the componentregistry.xml file. Note: anything defined in GenericSetup xml files results in persistent changes - if you want non-persistent utilities, use ZCML files to register them.
So when you have custom code to add a local utility in your setuphandlers.py code, Plone thinks this utility belongs to your main add-on. If you reinstall that add-on the utility gets removed alongside anything else and then everything is installed again.
I'm guessing your "is it already installed" check fails after the reinstall and the utility isn't added again.
You can avoid all of this, by simple giving both the dependency and main add-on their own GenericSetup profiles and than noting a dependency in the main's metadata.xml, like:
<?xml version="1.0"?>
<metadata>
<version>1</version>
<dependencies>
<dependency>profile-my.dependency:default</dependency>
</dependencies>
</metadata>
Once you do that the dependencies profile will be activated independently and Plone keeps track of it on its own. If you then decide to reinstall the main add-on, the dependency won't be touched at all and remains intact.

Resources