On Sun 2006-09-24 (03:45), kerinin wrote:
> 
> I'm trying to overload the __getattr__ method in one of my model
> classes so that i can do something like this:
> 
> class sample(SQLObject):
>     property1 = StringCol()
>     property2 = StringCol()
>     boolean = BoolCol()
> 
>     def __getattr__(self,attr):
>         if attr = 'random attribute':
>             { more code in here }...
>        else:
>              return SQLObject.__getattr__(self,attr)
> 
> i want to do this to simplify the use of some of my classes.

It's probably easier to use SQLObject's existing _get_foo support, or to
use property directly than to do things this way.

> unfortunately, when i do this i'm told "AttributeError: type object
> 'SQLObject' has no attribute '__getattr__'"
> 
> is there no way to pass method calls to superclasses?

        return super(sample, self).__getattr(attr)

But rather try the other ways.

Neil
-- 
Neil Blakey-Milner
[EMAIL PROTECTED]
http://mithrandr.moria.org/

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"TurboGears" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/turbogears
-~----------~----~----~----~------~----~------~--~---

Reply via email to