@@ -202,19 +202,33 @@ def __init__(self, solr_types, global_unique_fields, gen_factory,
202202 arg become the id strings you use to create and access
203203 records using each profile in the other object methods.
204204 """
205- self .profiles = {}
206- self .records = {}
207205 self .gen_factory = gen_factory
208- for rectype , pdef in profile_definitions .items ():
209- profile = sf .SolrProfile (
210- rectype , pdef ['conn' ], user_fields = pdef ['user_fields' ],
211- inclusive = pdef .get ('inclusive' , True ),
212- unique_fields = global_unique_fields , solr_types = solr_types ,
213- gen_factory = gen_factory ,
214- default_field_gens = pdef .get ('field_gens' , tuple ())
215- )
216- self .profiles [rectype ] = profile
217- self .records [rectype ] = tuple ()
206+ self .default_solr_types = solr_types
207+ self .default_unique_fields = global_unique_fields
208+ self .records = {}
209+ self .profiles = {
210+ rectype : self .make_profile (rectype , ** profile_def )
211+ for rectype , profile_def in profile_definitions .items ()
212+ }
213+
214+ def make_profile (self , rectype , conn = None , user_fields = None ,
215+ inclusive = True , unique_fields = None , gen_factory = None ,
216+ solr_types = None , field_gens = None ):
217+ """
218+ Generate a solr_factories.SolrProfile object using the
219+ provided kwargs.
220+ """
221+ unique_fields = unique_fields or self .default_unique_fields
222+ gen_factory = gen_factory or self .gen_factory
223+ solr_types = solr_types or self .default_solr_types
224+ field_gens = field_gens or tuple ()
225+ profile = sf .SolrProfile (
226+ rectype , conn , user_fields = user_fields , inclusive = inclusive ,
227+ unique_fields = unique_fields , solr_types = solr_types ,
228+ gen_factory = gen_factory , default_field_gens = field_gens
229+ )
230+ self .records [rectype ] = self .records .get (rectype , tuple ())
231+ return profile
218232
219233 def make (self , rectype , number , context = None , ** field_gens ):
220234 """
@@ -288,7 +302,7 @@ def load_static_test_data(self, rectype, test_data, id_field='id',
288302 """
289303 context = context or tuple ()
290304 records = tuple ()
291- gens = self .gen_factory
305+ gens = self .profiles [ rectype ]. gen_factory
292306 for rec_id , record in test_data :
293307 datagens = {k : gens .static (v ) for k , v in record .items ()}
294308 datagens [id_field ] = gens .static (rec_id )
0 commit comments