def save(self, *args, **kwargs):
if not self.type:<EOL><INDENT>if self.interface_a.type == INTERFACE_TYPES.get('<STR_LIT>'):<EOL><INDENT>self.type = LINK_TYPES.get('<STR_LIT>')<EOL><DEDENT>elif self.interface_a.type == INTERFACE_TYPES.get('<STR_LIT>'):<EOL><INDENT>self.type = LINK_TYPES.get('<STR_LIT>')<EOL><DEDENT>else:<EOL><INDENT>self.type = LINK_TYPES.get('<STR_LIT>')<EOL><DEDENT><DEDENT>if self.interface_a_id:<EOL><INDENT>self.interface_a = Interface.objects.get(pk=self.interface_a_id)<EOL><DEDENT>if self.interface_b_id:<EOL><INDENT>self.interface_b = Interface.objects.get(pk=self.interface_b_id)<EOL><DEDENT>if self.node_a is None and self.interface_a is not None:<EOL><INDENT>self.node_a = self.interface_a.node<EOL><DEDENT>if self.node_b is None and self.interface_b is not None:<EOL><INDENT>self.node_b = self.interface_b.node<EOL><DEDENT>if self.layer is None:<EOL><INDENT>self.layer = self.node_a.layer<EOL><DEDENT>if not self.line:<EOL><INDENT>self.line = LineString(self.node_a.point, self.node_b.point)<EOL><DEDENT>if self.data.get('<STR_LIT>', None) is None:<EOL><INDENT>self.data['<STR_LIT>'] = self.node_a.name<EOL>self.data['<STR_LIT>'] = self.node_b.name<EOL><DEDENT>if self.data.get('<STR_LIT>', None) is None or self.data.get('<STR_LIT>', None) is None:<EOL><INDENT>self.data['<STR_LIT>'] = self.node_a.slug<EOL>self.data['<STR_LIT>'] = self.node_b.slug<EOL><DEDENT>if self.interface_a and self.data.get('<STR_LIT>', None) is None:<EOL><INDENT>self.data['<STR_LIT>'] = self.interface_a.mac<EOL><DEDENT>if self.interface_b and self.data.get('<STR_LIT>', None) is None:<EOL><INDENT>self.data['<STR_LIT>'] = self.interface_b.mac<EOL><DEDENT>if self.data.get('<STR_LIT>') != self.layer.slug:<EOL><INDENT>self.data['<STR_LIT>'] = self.layer.slug<EOL><DEDENT>super(Link, self).save(*args, **kwargs)<EOL>
Custom save does the following:
    * determine link type if not specified
    * automatically fill 'node_a' and 'node_b' fields if necessary
    * draw line between two nodes
    * fill shortcut properties node_a_name and node_b_name