def _get_link_details(entity, link_name): """"Lookup the (edge_class, left_edge_id, right_edge_id, node_class) for the given entity and link_name. param entity: The current entity Node subclass :param str link_name: The association proxy name edge_class: The Edge subclass the association is proxied through left_edge_id: The edge.{src,dst}_id right_edge_id: The edge.{dst,src}_id (opposit of left_edge_id) node_class: The target node the association_proxy points to """ # Look for the link_name in OUTBOUND edges from the current # entity for edge in Edge._get_edges_with_src(entity.__name__): if edge.__src_dst_assoc__ == link_name: return (edge, edge.src_id, edge.dst_id, Node.get_subclass_named(edge.__dst_class__)) # Look for the link_name in INBOUND edges from the current # entity for edge in Edge._get_edges_with_dst(entity.__name__): if edge.__dst_src_assoc__ == link_name: return (edge, edge.dst_id, edge.src_id, Node.get_subclass_named(edge.__src_class__)) raise AttributeError( "type object '{}' has no attribute '{}'" .format(entity.__name__, link_name))
def _get_link_details(entity, link_name): """"Lookup the (edge_class, left_edge_id, right_edge_id, node_class) for the given entity and link_name. param entity: The current entity Node subclass :param str link_name: The association proxy name edge_class: The Edge subclass the association is proxied through left_edge_id: The edge.{src,dst}_id right_edge_id: The edge.{dst,src}_id (opposit of left_edge_id) node_class: The target node the association_proxy points to """ # Look for the link_name in OUTBOUND edges from the current # entity for edge in Edge._get_edges_with_src(entity.__name__): if edge.__src_dst_assoc__ == link_name: return (edge, edge.src_id, edge.dst_id, Node.get_subclass_named(edge.__dst_class__)) # Look for the link_name in INBOUND edges from the current # entity for edge in Edge._get_edges_with_dst(entity.__name__): if edge.__dst_src_assoc__ == link_name: return (edge, edge.dst_id, edge.src_id, Node.get_subclass_named(edge.__src_class__)) raise AttributeError("type object '{}' has no attribute '{}'".format( entity.__name__, link_name))