On Mar 25, 2006, at 6:13 AM, Michael Carter wrote:

Unfortunately, that function was looking for keys like 'type' and 'id' without the 'tests_' prefix, but it was getting the same row with the 'tests_' prefixes. When I threw a quick hack in mapper.py to have the new key be table.name + '_' + c.key, there were some more complicated issues that are over my head at this point.

I was also wondering about two things in this area of the code:
1) What is the translate boolean that populate_inventory takes supposed to signify? I tried giving it both False and True and I just ended up with slightly different tracebacks.


The boolean is this new thing I tried to give the populate_instance method a clue that the incoming row is from another mapper, and some translation needs to happen on the column names in the row.  The column name translation in the incoming rows, between two mappers that are created against different tables, is the thorny part.  I committed a slightly different way of accomplishing this in rev 1212, so your populate_instance now looks like:

    def populate_instance(self, mapper, instance, row, identitykey, imap, isnew):
        if row['tests_type'] =='test1':
            Test1.mapper.populate_instance(instance, row, identitykey, imap, isnew, frommapper=mapper)
            return False
        if row['tests_type'] =='test2':
            Test2.mapper.populate_instance(instance, row, identitykey, imap, isnew, frommapper=mapper)
            return False
       
        return True   

the "frommapper" is giving it more clues on how to translate the row between the incoming mapper and the mapper used to populate the instance.  Im still not very confident in what its doing; i think it will work for the kinds of examples we are doing here but im not sure about more exotic conditions.

2) the populate_inventory function on the mapper extension from the polymorph2 example returned False or True. What does this mean?


theres a pydoc for this in there also, the general MapperExtension thing is that a method which returns True says, "I havent done anything here, you should do your default operation", whereas False means "dont do your default operation, I already took care of it".




Reply via email to