def create_mapping(self, mapped_class, configuration=None):
        """
        Creates a new mapping for the given mapped class and representer
        configuration.

        :param configuration: configuration for the new data element class.
        :type configuration: :class:`RepresenterConfiguration`
        :returns: newly created instance of :class:`Mapping`
        """
        cfg = self.__configuration.copy()
        if not configuration is None:
            cfg.update(configuration)
        provided_ifcs = provided_by(object.__new__(mapped_class))
        if IMemberResource in provided_ifcs:
            base_data_element_class = self.member_data_element_base_class
        elif ICollectionResource in provided_ifcs:
            base_data_element_class = self.collection_data_element_base_class
        elif IResourceLink in provided_ifcs:
            base_data_element_class = self.linked_data_element_base_class
        else:
            raise ValueError('Mapped class for data element class does not '
                             'implement one of the required interfaces.')
        name = "%s%s" % (mapped_class.__name__,
                         base_data_element_class.__name__)
        de_cls = type(name, (base_data_element_class,), {})
        mp = self.mapping_class(self, mapped_class, de_cls, cfg)
        # Set the data element class' mapping.
        # FIXME: This looks like a hack.
        de_cls.mapping = mp
        return mp
def create_mapping ( self , mapped_class , configuration = None ) : cfg = self . __configuration . copy ( ) if not configuration is None : cfg . update ( configuration ) provided_ifcs = provided_by ( object . __new__ ( mapped_class ) ) if IMemberResource in provided_ifcs : base_data_element_class = self . member_data_element_base_class elif ICollectionResource in provided_ifcs : base_data_element_class = self . collection_data_element_base_class elif IResourceLink in provided_ifcs : base_data_element_class = self . linked_data_element_base_class else : raise ValueError ( 'Mapped class for data element class does not ' 'implement one of the required interfaces.' ) name = "%s%s" % ( mapped_class . __name__ , base_data_element_class . __name__ ) de_cls = type ( name , ( base_data_element_class , ) , { } ) mp = self . mapping_class ( self , mapped_class , de_cls , cfg ) de_cls . mapping = mp return mp
Creates a new mapping for the given mapped class and representer
        configuration.

        :param configuration: configuration for the new data element class.
        :type configuration: :class:`RepresenterConfiguration`
        :returns: newly created instance of :class:`Mapping`