Package schrodinger :: Package application :: Package msv :: Package gui :: Module undoable_alignment :: Class ProteinAlignment :: Class __metaclass__
[hide private]
[frames] | no frames]

Type __metaclass__

 object --+        
          |        
       type --+    
              |    
sip.wrappertype --+
                  |
                 gui.undoable_alignment.ProteinAlignment.__metaclass__

This metaclass makes it easy to create a class that wraps another one.

In general, if class A wraps class B, then:

* Every static method, class method, and property on B is accessible from A, unless A already has attributes with the same name defined

* Every method on B decorated by @const will be available from A, unless A already has attributes with the same name defined

* Every instance attribute on B named in instance_attrs will be available from A.

This may sound like a clumsy reinvention of classical inheritance. But it can be useful to use a wrapper when we want the wrapped class to be able to call any of its own methods without any danger of the wrapper methods being called, while at the same time ensuring that we can conveniently provide the same interface from the wrapped class. For example, we have a ProteinAlignment class that encapsulates operations on structured collections of protein sequences. We use this metaclass to create an undoable ProteinAlignment that presents an identical interface but that can safely perform redo and undo operations by manipulating the protein alignment it wraps.

Instance Methods [hide private]

Inherited from sip.wrappertype: __delattr__, __getattribute__, __init__, __setattr__

Inherited from type: __call__, __eq__, __ge__, __gt__, __hash__, __instancecheck__, __le__, __lt__, __ne__, __repr__, __subclasscheck__, __subclasses__, mro

Inherited from object: __format__, __reduce__, __reduce_ex__, __sizeof__, __str__, __subclasshook__

Class Methods [hide private]
 
_maybeCopyDocString(cls, wrapped, wrapper)
Copies the doc string from the wrapped to the wrapper, if appropriate
 
makeMethodDelegate(cls, meth_name)
Returns a method that delegates method calls to the wrapped instance
property
makeProperty(cls, prop_name, getter, setter)
Returns a property that delegates property access to the wrapped instance
bool
shouldMakeMethodDelegate(cls, attr)
Given an attribute on the wrapped class indicates whether it should be wrapped
Static Methods [hide private]
a new object with type S, a subtype of T
__new__(cls, clsname, bases, dct)
Properties [hide private]

Inherited from type: __abstractmethods__, __base__, __bases__, __basicsize__, __dictoffset__, __flags__, __itemsize__, __mro__, __name__, __weakrefoffset__

Inherited from object: __class__

Method Details [hide private]

__new__(cls, clsname, bases, dct)
Static Method

 
Returns: a new object with type S, a subtype of T
Overrides: object.__new__
(inherited documentation)

_maybeCopyDocString(cls, wrapped, wrapper)
Class Method

 

Copies the doc string from the wrapped to the wrapper, if appropriate

We only copy the doc string if both attributes are methods and copying a doc string wouldn't overwrite one already present on the wrapper.

makeMethodDelegate(cls, meth_name)
Class Method

 

Returns a method that delegates method calls to the wrapped instance

Parameters:
  • meth_name (str) - The name of the method to wrap

makeProperty(cls, prop_name, getter, setter)
Class Method

 

Returns a property that delegates property access to the wrapped instance

Parameters:
  • prop_name (str) - The name of the property
  • getter (bool) - Whether to add a getter
  • setter (bool) - Whether to add a setter
Returns: property
A property which delegates to the wrapped object

shouldMakeMethodDelegate(cls, attr)
Class Method

 

Given an attribute on the wrapped class indicates whether it should be wrapped

Parameters:
  • attr - The attribute to inspect
Returns: bool
Whether the attribute on the wrapped class should be wrapped