bret at pectopah
Jul 15, 2011, 9:44 AM
More fun with find_or_create_alternate()
I've just been fiddling with the fun parts of the
find_or_create_alternate() method to fix a bug. I've found a fix, but
thought I should add this to the list anyhow.
Here's the bug:
When the source image and target thumbnail image are in different OCs
with different URI formats, calling find_or_create_alternate() will
throw a URI-not-unique error.
This is because the URI generated for the initial find uses the source
image OC URI format, not the destination URI format.
Here's an example:
The original image is of type "Infrastructure image." That type is in
the "Includes" OC, with fixed URI. Here are the URI formats:
So the starting URI of my image is this:
The element type for my thumbnail is "Auto-generated image." Which is in
the Web OC, with non-fixed URI, like this:
I'm expecting the thumbnail to have a URI like this:
...but the lookup inside the find_or_create_alternate comes up with this
target URI instead:
No image with this URI exists, so it goes on to create one. This one has
the correct URI, and because the template has run once in the past, it
collides with a previously-created version of the same image.
I've opened bug #274 and a pull request for my patch.
Pectopah Productions Inc.
bret [at] pectopah