New issue 68 by guitar...@vt.edu: ReferenceTransform fails with None values
http://code.google.com/p/contentmirror/issues/detail?id=68
What steps will reproduce the problem?
1. Get an old Plone (3.2.3) with crazy data from users (sorry, I have no
idea why my Data is so bad)
2. Run 'bin/instance run /path/to/bulk.py /'
3. It outputs tons of SQLAlchemy stuff, then bombs with this traceback:
{{{
Traceback (most recent call last):
File "<string>", line 1, in ?
File "parts/productdistros/ContentMirror/eggs/ore.contentmirror-0.4.1-py2.4.egg/ore/contentmirror/bulk.py",
line 87, in ?
main( app = app )
File "parts/productdistros/ContentMirror/eggs/ore.contentmirror-0.4.1-py2.4.egg/ore/contentmirror/bulk.py",
line 69, in main
serializer.update()
File "/var/plone/infocenters/parts/productdistros/ContentMirror/eggs/ore.contentmirror-0.4.1-py2.4.egg/ore/contentmirror/serializer.py",
line 40, in update
return self.add()
File "/var/plone/infocenters/parts/productdistros/ContentMirror/eggs/ore.contentmirror-0.4.1-py2.4.egg/ore/contentmirror/serializer.py",
line 34, in add
self._copy( peer )
File "/var/plone/infocenters/parts/productdistros/ContentMirror/eggs/ore.contentmirror-0.4.1-py2.4.egg/ore/contentmirror/serializer.py",
line 54, in _copy
peer.transformer.copy( self.context, peer )
File "/var/plone/infocenters/parts/productdistros/ContentMirror/eggs/ore.contentmirror-0.4.1-py2.4.egg/ore/contentmirror/transform.py",
line 52, in copy
transformer.copy( instance, peer )
File "/var/plone/infocenters/parts/productdistros/ContentMirror/eggs/ore.contentmirror-0.4.1-py2.4.egg/ore/contentmirror/transform.py",
line 285, in copy
t_oid = ob.UID()
AttributeError: 'NoneType' object has no attribute 'UID'
}}}
What version of the product are you using? On what operating system?
OK, so I found this with ContentMirror-0.4.1, but the source code is the
same in 0.6.0rc2.
I've hacked ReferenceTransform.copy() in transforms.py for myself:
{{{
def copy( self, instance, peer ):
value = self.context.getAccessor( instance )()
if not value:
return
if not isinstance( value, (list, tuple)):
value= [ value ]
#my hack - remove None values.
goods = [x for x in value where x is not None]
if len(goods) < 1:
return
value = goods
for ob in value:
t_oid = ob.UID()
}}}
Oops! The line should read:
goods = [x for x in value if x is not None]
NOTE: "if" instead of "where"
Comment #2 on issue 68 by kapilt: ReferenceTransform fails with None values
http://code.google.com/p/contentmirror/issues/detail?id=68
yeah.. contentmirror should try and be nice with 'bad' data and do the
right thing. its not clear why the reference value would contain a None.
I've added filtering of reference values on the trunk (rev 137).
incidentally, the minimal idiomatic python to do this is.
my_list = filter(None, my_list)
Comment #3 on issue 68 by kapilt: ReferenceTransform fails with None values
http://code.google.com/p/contentmirror/issues/detail?id=68
(No comment was entered for this change.)