View Single Post
Old 03-11-2011, 04:50 PM   #7
chaley
Grand Sorcerer
chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.
 
Posts: 11,787
Karma: 7029971
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
I wonder if it makes sense to give get_metadata a new parameter which is the class to instantiate? That would eliminate the smart_update in cases where a Metadata subclass is being used.

It would look something like:
Code:
def get_metadata(self, idx, index_is_id=False, get_cover=False, 
                 metadata_class=Metadata):
        '''
        Convenience method to return metadata as a :class:`Metadata` object.
        Note that the list of formats is not verified.
        '''
        row = self.data._data[idx] if index_is_id else self.data[idx]
        fm = self.FIELD_MAP
        mi = metadata_class(None)
chaley is offline   Reply With Quote