Package twisted :: Package python :: Module reflect :: Class AccessorType
[show private | hide private]
[frames | no frames]

Class AccessorType

object --+    
         |    
      type --+
             |
            AccessorType


Metaclass that generates properties automatically.

This is for Python 2.2 and up.

Using this metaclass for your class will give you explicit accessor methods; a method called set_foo, will automatically create a property 'foo' that uses set_foo as a setter method. Same for get_foo and del_foo.

Note that this will only work on methods that are present on class creation. If you add methods after the class is defined they will not automatically become properties. Likewise, class attributes will only be used if they are present upon class creation, and no getter function was set - if a getter is present, the class attribute will be ignored.

This is a 2.2-only alternative to the Accessor mixin - just set in your class definition:
   __metaclass__ = AccessorType

Method Summary
  __init__(self, name, bases, dict)
  __call__(x, ...)
Return x(...) (inherited from type)
  __cmp__(x, y)
Return cmp(x,y) (inherited from type)
  __delattr__(...)
x.__delattr__('name') <==> del x.name (inherited from type)
  __getattribute__(...)
x.__getattribute__('name') <==> x.name (inherited from type)
  __hash__(x)
Return hash(x) (inherited from type)
  __new__(T, S, ...)
Return a new object with type S, a subtype of T (inherited from type)
  __reduce__(...)
helper for pickle (inherited from object)
  __repr__(x)
Return repr(x) (inherited from type)
  __setattr__(...)
x.__setattr__('name', value) <==> x.name = value (inherited from type)
  __str__(x)
Return str(x) (inherited from object)
list of immediate subclasses __subclasses__()
(inherited from type)
list mro()
(inherited from type)

Generated by Epydoc 1.2 prerelease on Wed Jan 29 06:25:57 2003 http://epydoc.sf.net