'If we have an Attribute, then we\'ll prepopulate our instance with the fields we\'d expect it
to have based on the Attribute. attr_key, attr_category, attr_value, attr_strvalue, attr_type,
and attr_lockstring all refer to the corresponding Attribute fields. The initial data of the form fields will
similarly be populated.'

def __init__(self, *args, **kwargs):

    super(AttributeForm, self).__init__(*args, **kwargs)
    attr_key = None
    attr_category = None
    attr_value = None
    attr_strvalue = None
    attr_type = None
    attr_lockstring = None
    if hasattr(self.instance, 'attribute'):
        attr_key = self.instance.attribute.db_key
        attr_category = self.instance.attribute.db_category
        attr_value = self.instance.attribute.db_value
        attr_strvalue = self.instance.attribute.db_strvalue
        attr_type = self.instance.attribute.db_attrtype
        attr_lockstring = self.instance.attribute.db_lock_storage
        self.fields['attr_key'].initial = attr_key
        self.fields['attr_category'].initial = attr_category
        self.fields['attr_type'].initial = attr_type
        self.fields['attr_value'].initial = attr_value
        self.fields['attr_strvalue'].initial = attr_strvalue
        self.fields['attr_lockstring'].initial = attr_lockstring
    self.instance.attr_key = attr_key
    self.instance.attr_category = attr_category
    self.instance.attr_value = attr_value
    self.instance.deserialized_value = from_pickle(attr_value)
    self.instance.attr_strvalue = attr_strvalue
    self.instance.attr_type = attr_type
    self.instance.attr_lockstring = attr_lockstring
