﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
746	refactor models/__init__.py so fields themselves add their own get_XXXX_count/list functions	Ian@…	rjwittams	"currently in {{{ models/__init__.py }}} there is a big for loop which goes over all the installed modules
and creates the foreign key relationships (oneTomany,manytomany and one to one) with a big if/else/elif statement.

I propose we move the if/elif logic to the actual field code itself. so a field 'knows' what functions it has to create, and field writers could override this functionality to add their own relationships if they choose

from
{{{
for related in klass._meta.get_all_related_objects():
 if foo:
   ....
 elsif blah:
   ....

}}}

to
{{{
 for related in klass._meta.get_all_related_objects():
    related.create_relationships( klass, meta )
}}}
and 
{{{
class OneToOne:
  def create_relationships( klass,meta )
    func = curry(....)
    ...
    klass.setattr(...)

}}}

I think this change would be backwards compatible. and could allow me to define a 'TagField' which creates special functions."	defect	closed	Core (Other)		normal	invalid			Unreviewed	0	0	0	0	0	0
