Package pyperry :: Module base :: Class BaseMeta
[frames] | no frames]

Type BaseMeta

source code

object --+    
         |    
      type --+
             |
            BaseMeta

The Metaclass for Base

This allows for tracking all models defined using perry.Base as well as dynamic class level methods. Class methods are delegated to an instance of pyperry.relation.Relation if it knows how to handle them.

Instance Methods
 
__getattr__(cls, key)
Allow delegation to Relation or raise AttributeError
source code
 
resolve_name(cls, name)
Lookup class by the given name
source code

Inherited from type: __call__, __cmp__, __delattr__, __eq__, __ge__, __getattribute__, __gt__, __hash__, __init__, __le__, __lt__, __ne__, __repr__, __setattr__, __subclasses__, mro

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

Static Methods
a new object with type S, a subtype of T
__new__(mcs, name, bases, dict_)
Called any time a new Base class is created using this metaclass
source code
Class Variables
  defined_models = {'Base': [<class 'pyperry.base.Base'>]}
Properties

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

Inherited from object: __class__

Method Details

__new__(mcs, name, bases, dict_)
Static Method

source code 

Called any time a new Base class is created using this metaclass

Models names are tracked in order to allow quick lookup of the model's class by its name.

Returns: a new object with type S, a subtype of T
Overrides: object.__new__

resolve_name(cls, name)

source code 

Lookup class by the given name

Returns all models that match the given name. To avoid ambiguous matches you can pass any section of the preceding namespace or a full absolute path name to the class. For example, to find the class foo.bar.Baz you could specify:

   # Matches all models named 'Baz'
   Base.resolve_name('Baz')
   # Matches all models named 'Baz' in a 'bar' namespace
   Base.resolve_name('bar.Baz')
   # Or specify absolutely
   Base.resolve_name('foo.bar.Baz')
Parameters:
  • name - string representation of a class with or without the partial or full namespace in dot notation
Returns:
a list of classes matching name