def _embed_component(self, resource, record=None):
        """
            Renders the right key constraint in a link table as
            S3EmbeddedComponentWidget and stores the postprocess hook.

            @param resource: the link table resource
        """

        link = None

        component = resource.linked
        if component is not None and component.actuate == "embed":

            ctablename = component.tablename
            attr = {"link": resource.tablename,
                    "component": ctablename,
                    }

            autocomplete = component.autocomplete
            if autocomplete and autocomplete in component.table:
                attr["autocomplete"] = autocomplete

            if record is not None:
                attr["link_filter"] = "%s.%s.%s.%s.%s" % (
                                      resource.tablename,
                                      component.lkey,
                                      record,
                                      component.rkey,
                                      component.fkey)

            rkey = component.rkey
            if rkey in resource.table:
                field = resource.table[rkey]
                field.widget = S3EmbeddedComponentWidget(**attr)
                field.comment = None

            callback = self._postprocess_embedded
            postprocess = lambda form, key=rkey, component=ctablename: \
                                 callback(form, key=key, component=component)
            link = Storage(postprocess=postprocess)

        return link

    # -------------------------------------------------------------------------
dataset/ETHPy150Open sahana/eden/modules/s3/s3crud.py/S3CRUD._embed_component/original