Package pyperry :: Module association :: Class Has
[frames] | no frames]

Class Has

source code

 object --+    
          |    
Association --+
              |
             Has
Known Subclasses:

Builds the association scope for a has association. This is the superclass for HasOne and HasMany associations. The only difference between a has one and has many relation, is that .first() is called on the has one association's scope but not on the has many association's scope. See the Association class for more details on how associations work.

Instance Methods
 
get_foreign_key(self) source code
 
set_foreign_key(self, value) source code
 
polymorphic(self) source code
 
polymorphic_type(self) source code
 
scope(self, obj_or_list)
Returns a scope on the source class containing this association
source code

Inherited from Association: __call__, __init__, collection, eager_loadable, finder_options, primary_key, source_klass, type

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties
  foreign_key

Inherited from object: __class__

Method Details

get_foreign_key(self)

source code 
Overrides: Association.get_foreign_key

set_foreign_key(self, value)

source code 
Overrides: Association.set_foreign_key

polymorphic(self)

source code 
Overrides: Association.polymorphic

scope(self, obj_or_list)

source code 

Returns a scope on the source class containing this association

Builds conditions on top of the base_scope generated from any finder options set with the association:

   has_many('widgets', klass=Widget, foreign_key='widget_id')
   has_many('comments', as_='parent')

In addition to any finder options included with the association options the following will be added:

   where('widget_id = %s ' % target['id'])

Or for the polymorphic :comments association:

   where('parent_id = %s AND parent_type = %s' % (target['id'],
   target.class))
Overrides: Association.scope

Property Details

foreign_key

Get Method:
get_foreign_key(self)
Set Method:
set_foreign_key(self, value)