Changeset 6443


Ignore:
Timestamp:
Dec 11, 2008, 9:40:41 PM (16 years ago)
Author:
roland
Message:

Fixed some bugs in forms.py

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/exodus/forms.py

    r6441 r6443  
    3131
    3232    def clean_link(self):
    33         import pdb; pdb.set_trace() ;
    3433        link = self.cleaned_data.get('link')
    3534        # the type of the interface, eth, 11a, 11b, 11g.
    3635        type = self.cleaned_data.get('type')
    3736
    38         try:
    39             # self.instance.pk only exists when this interface has been saved
    40             # before. Primary Keys's always start at 1.
    41             if self.instance.pk:
    42                 edit = True
    43                 # save self.instance for further reference, so that we
    44                 # don't have to try, except instance everytime.
    45                 instance_pk = self.instance.pk
    46                 instance_node_id = self.instance.node_id
    47         except Interface.DoesNotExist:
    48             edit = instance_pk = instance_node_id = None
     37        # self.instance raises DoesNotExist, but self.instance.[pk, ssid, polar, etc] doesn't
     38        # Primary Keys's always start at 1.
     39        if self.instance.pk:
     40            edit = True
     41        else:
     42            edit = False
    4943           
    5044        if link:
    5145            # if link is to self we don't need to check anything else
    52             if instance_pk == link.pk:
     46            if self.instance.pk == link.pk:
    5347                return link
    5448            # Link can't be to same node, unless link is to self,
    5549            # which we checked above.
    56             elif instance_node_id == link.node_id:
     50            elif self.instance.node_id == link.node_id:
    5751                raise forms.ValidationError(
    5852                    "A link can't be to another interface on the same node")
     
    119113        # to itself.
    120114        elif edit:
    121             link = Interface.objects.get(pk=instance_pk)
     115            link = Interface.objects.get(pk=self.instance.pk)
    122116            return link
    123117        # This is a new interface, can't be linked to itself because it hasn't
Note: See TracChangeset for help on using the changeset viewer.