ComponentLookupError, IStorage, NamedBlobImage, and black magic

Why would I be getting this error?

ComponentLookupError: (<InterfaceClass plone.namedfile.interfaces.IStorage>, 'plone.namedfile.file.NamedBlobImage')

I don't understand why IStorage wouldn't be registered in this case.

I am running a Plone -> CastleCMS import script, which eventually gets down to

The error is occuring at these lines:

The full error trace is

2018-03-28 04:57:53 ERROR castle.cms Error importing object
Traceback (most recent call last):
  File "", line 266, in import_pages
    import_object(filepath, count)
  File "", line 237, in import_object
  File "/home/kim/src/castle.cms/castle/cms/_scripts/", line 284, in post_creation
  File "/home/kim/src/castle.cms/eggs/plone.namedfile-3.0.10.dev0-py2.7.egg/plone/namedfile/", line 433, in __init__
    super(NamedBlobImage, self).__init__(data, filename=filename)
  File "/home/kim/src/castle.cms/eggs/plone.namedfile-3.0.10.dev0-py2.7.egg/plone/namedfile/", line 383, in __init__
  File "/home/kim/src/castle.cms/eggs/plone.namedfile-3.0.10.dev0-py2.7.egg/plone/namedfile/", line 440, in _setData
    super(NamedBlobImage, self)._setData(data)
  File "/home/kim/src/castle.cms/eggs/plone.namedfile-3.0.10.dev0-py2.7.egg/plone/namedfile/", line 400, in _setData
    storable = getUtility(IStorage, name=dottedName)
  File "/home/kim/src/castle.cms/eggs/zope.component-3.9.5-py2.7.egg/zope/component/", line 169, in getUtility
    raise ComponentLookupError(interface, name)
ComponentLookupError: (<InterfaceClass plone.namedfile.interfaces.IStorage>, 'plone.namedfile.file.NamedBlobImage')

The module in plone.namedfile contains various IStorage utilities which handle storing file data from various sources. They are looked up as named utilities where the name is the dotted class name of the data object that was passed to the NamedBlobImage constructor. Looks like there is no IStorage utility for storing data from another instance of NamedBlobImage. Maybe if your importer has a NamedBlobImage instance to begin with it can just use it rather than trying to create a new one.

Thx @davisagli. Your solution worked, which was to just use the NamedBlobImage instance instead of trying to set another one's data from it.