Personal tools
You are here: Home Zope & Plone tips Override __bobo_traverse__ to provide custom URL lookup
Navigation
 
Document Actions
  • Send this page to somebody
  • Print this page
  • Add Bookmarklet

Override __bobo_traverse__ to provide custom URL lookup

by tibi last modified 2007-04-09 14:28

A snippet lifted from ATContentTypes/content/image.py that shows what it's all about:

    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)
Creative Commons License
This work is licensed under a Creative Commons Attribution 3.0 License.
 

Powered by Plone CMS, the Open Source Content Management System

This site conforms to the following standards: