backport of "Check attachment paths for duplicates, not URLs"

Backport of patch to v2.7 branch.  Original patch details:

>As per discussion in issue #660, attachments using alias interpolations
>for the attachment URL mistakenly get flagged as being duplicates,
>although the interpolation expands to a unique location.
>
>This commit (partially) addresses the issue by checking the attachment path
>instead. However, the problem will remain for users who use
>interpolations other than :class to distinguish attachment paths for
>different models.