Override __bobo_traverse__ to provide custom URL lookup

This technique is lifted from ATContentTypes/content/image.py

    def __bobo_traverse__(self, REQUEST, name):
"""Transparent access to image scales
"""
if name.startswith('image'):
field = self.getField('image')
image = None
if name == 'image':
image = field.getScale(self)
else:
scalename = name[len('image_'):]
if scalename in field.getAvailableSizes(self):
image = field.getScale(self, scale=scalename)
if image is not None and not isinstance(image, basestring):
# image might be None or '' for empty images
return image

return ATCTFileContent.__bobo_traverse__(self, REQUEST, name)

Comments