def validate(self, value): """Color validator""" is_valid = False if isinstance(value, basestring): if value.startswith("#"): rgb = HTMLColors.get_rgb(value) # will raise if the color is invalid is_valid = True else: # This must be a color name, see if we know about it! is_valid = HTMLColors.htmlcolors.has_key(value.lower()) if not is_valid: raise Exception("%s is not a valid Color" % ( value, )) return super(Color, self).validate(value)