def lookup_proxy(*args, **kwargs):
    '''
    usage:
        lookup_proxy('page_groups', lookup='Page_Group.group')
    or:
        lookup_proxy('page_groups', 'Page_Group.group')
    is a shortcut to
        lookup_proxy('page_groups', 'group', creator = lambda _val: Page_Group(group = _val))

    example:

    class Page(DB_Model):
        __session__ = session
        page_groups = relationship("Page_Group", foreign_keys="Page_Group.fk_page")
        groups      = lookup_proxy(page_groups, lookup='Page_Group.group')

    class Page_Group(DB_Model):
        __session__ = session
        fk_page     = Column(Integer, ForeignKey("page._real_id"))
        fk_group    = Column(Integer, ForeignKey("group._real_id"))
        page        = relationship("Page", foreign_keys="Page_Groups.fk_page")
        group       = relationship("Group", foreign_keys="Page_Groups.fk_group")

    class Group(DB_Model):
        __session__ = session
        name        = Column(String(20))
    '''
    args = list(args)
    if 'lookup' in kwargs:
        lookup = kwargs.pop("lookup",'')
    elif len(args) > 1:
        lookup = args.pop() 
    else:
        lookup = ''   
    lookup_part = lookup.split('.')
    relation_name = lookup_part[-1]
    class_name = '.'.join(lookup_part[0:-1])
    kwargs['creator'] = creator_maker(class_name, relation_name)    
    if len(args) == 1:
        args.append(relation_name)
    return association_proxy(*args, **kwargs)
dataset/ETHPy150Open goFrendiAsgard/kokoropy/kokoropy/model.py/lookup_proxy/original