view roundup/cgi/ComputedAttribute.py @ 1073:cf30c6cdca02

More documentation. Simplified the "klass", "item" and "*classname*" variables into "context.
author Richard Jones <richard@users.sourceforge.net>
date Mon, 09 Sep 2002 00:45:06 +0000
parents 55ab0c5b49f9
children
line wrap: on
line source

class ComputedAttribute:
    def __init__(self, callable, level):
        self.callable = callable
        self.level = level
    def __of__(self, *args):
        if self.level > 0:
            return self.callable
        if isinstance(self.callable, type('')):
            return getattr(args[0], self.callable)
        return self.callable(*args)


Roundup Issue Tracker: http://roundup-tracker.org/