OFS.Uninstalled Could not import class

I would like to export a Plone site then import it but i got :

Error Type: ImportError
Error Value: No module named module.content.oldcontenttype

In the log files of the Plone site i can see :

WARNING OFS.Uninstalled Could not import class 'OldContentType' from module 'old.module.content.oldcontenttype'

It's an old addon which is not used anymore, could you tell me how to clean it ?

Thanks

Sounds like you still have some instances of OldContentType in your site. You need to remove them before exporting if you're going to import to a site that no longer has the code for OldContentType.

How to find them ? I used portal_catalog but nothing found

It does not have to be a content type (?)

If that is the case and you are quite stuck, you could try (TAKE BACKUP FIRST):


and

(has worked for me for a similar use case )

Thank you, i already tried it but it didn't fix this issue

Use the advanced search form, e.g. /search_form and you can filter by content type.

I didn't manage to find it :

  • http://myplonesite_url/search_form return page not found

  • bin/instance debug > app.instance.search_form return AttributeError

Plone version is 4.3.9

Maybe it's just /search - you click on the site's Search button. If you leave the search field empty it will show you everything on your site. You should be able to see a way to filter the search results by type.

Thank you i found it, it's @@search but it uses portal_catalog, nothing found ...

I exported my plone site in XML format, then i used grep :

grep old.module site.xml
            <key><string id="17.146" encoding="">_old.module__Add_OldContentType_Permission</string></key>
                        <value><string encoding="">old.module</string></value>
            <key><string id="29.109" encoding="">old.module</string></key>
                  <string id="3933.11" encoding="">old.module</string>
            <value><string id="3933.17" encoding="">old.module</string></value>
            <value><string id="3933.19" encoding="">qi-after-old.module-20130621154718</string></value>
            <value><string id="3933.30" encoding="">qi-before-old.module-20130621154717</string></value>
      <global id="10900.1" name="OldContentType" module="old.module.content.oldcontenttype"/>
                      <string id="1408453.25" encoding="">old.module</string>
                      <string id="1408453.45" encoding="">old.module</string>
                          <string id="14063.6" encoding="">old.module</string>
                          <string id="14063.9" encoding="">old.module</string>
                      <string id="14089.5" encoding="">old.module</string>
                      <string id="14089.7" encoding="">old.module</string>

You should see those old content types listed in /portal_catalog/Indexes/Type/manage_browse

Hard to say what your grep found...

If you showed the full error message (not just one line) it might help. Then again it is just a warning so maybe it's working well enough?

The full error message is : 

Traceback (innermost last):
  Module ZPublisher.Publish, line 138, in publish
  Module ZPublisher.mapply, line 77, in mapply
  Module ZPublisher.Publish, line 48, in call_object
  Module OFS.ObjectManager, line 627, in manage_importObject
  Module OFS.ObjectManager, line 645, 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 175, in _importDuringCommit
ImportError: No module named module.content.oldcontenttype

Thank you for your help

This does seem to me to be something that can be fixed by wildcard.fixpersistentutilities. Beyond that, the only option might be for you to create and include in your buildout a "placeholder" module, but that is what wildcard.fixpersistentutilities does.

I tried @@deactivate-expert-mode-for-fixing-persistent-utilities and @@activate-expert-mode-for-fixing-persistent-utilities but nothing about old.module

I didn't manage to fix this issue, somebody can help me ?

  1. reinstall old.module
  • find all instances of old.module.content.oldcontenttype using the catalog
  • remove them
  • uninstall old.module

you can do 2 and 3 from a debug instance:

  • start your plone using bin/instance debug
  • initialize properly your environment like this:

now do:

catalog = site.portal_catalog
results = catalog(portal_type='OldContentType')
for brain in results:
    obj.getObject()
    if obj is not None:
        obj.aq_parent.manage_delObjects([obj.getId()])

import transaction
transaction.commit()
1 Like

Thank you very much, it's a very old module i don't have the sources anymore

the message in your console is a warning; you may try 2 and 3, without 1 and 4; but you need to know the portal_type for sure.

catalog = site.portal_catalog
results = catalog(portal_type='OldContentType')
for brain in results:
     obj = brain.getObject()
     if obj is not None:
             print obj.__module__

other.module.content.oldcontenttype
2017-03-10 11:07:30 WARNING OFS.Uninstalled Could not import class 'OldContentType' from module 'old.module.content.oldcontenttype'
other.module.content.oldcontenttype
other.module.content.oldcontenttype
other.module.content.oldcontenttype

I have another module which as the same content type name, do you think this is the problem ?

I think you have many problems :slight_smile:

try creating a stub class for the one missing.

Fix it creating an alias somewhere in your python code:

from persistent import Persistent
from plone.app.upgrade.utils import alias_module


class OldContentType(Persistent):
    def wl_isLocked(self):
        return False

alias_module(
    'old.module.content.oldcontenttype',
    OldContentType
)
4 Likes