Personal tools
You are here: Home Weblog Archive 2006 October 02 Override __bobo_traverse__ to provide custom URL lookup
Document Actions
  • Send this page to somebody
  • Print this page
  • Add Bookmarklet

Override __bobo_traverse__ to provide custom URL lookup

by tibi last modified 2006-10-02 04:06
Filed Under:

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)
Weblog
Atom
RDF
RSS 2.0
Powered by Quills
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: