title: Inheritance Issue: AttributeError: 'str' object has no attribute '_sa_instance_state'
body: <p><strong>Issue:</strong> inheritance class is not checking for strings because it is being passed as <code>None</code>. </p>
  
  <p>The parent class (<em>object.py</em>) of the retrieve method was designed to retrieve  objects from the database (e.g. id or user/assessment combo). The child class (<em>convenience.py</em>) is designed to accept the <code>str</code>s of those objects. </p>
  
  <p><strong>object.py</strong></p>
  
  <pre><code>def retrieve_assessment_result(self, *args):
      id, owner, assessment = None, None, None
      if len(args) == 1:
          id, = args # or id = args[0]
      elif len(args) == 2:
          owner, assessment = args
          print 'testa', owner, assessment, id
      else:
          raise ValueError('Value being passed is an object')
      if id is not None:
          print 'testi', id
          return self.session.query(Assessment_Result).\
          filter(Assessment_Result.id == id).one()
      elif owner is not None:
          print 'testo', owner
          return self.session.query(Assessment_Result).\
          filter(Assessment_Result.owner == owner).one()
      elif assessment is not None:
          print 'testa', assessment
          return self.session.query(Assessment_Result).\
          filter(Assessment_Result.assessment == assessment).one()
  </code></pre>
  
  <p><strong>convenience.py</strong> </p>
  
  <pre><code>def retrieve_assessment_result(self, *args):
      id, owner, assessment = None, None, None
      if len(args) == 1:
          id, = args # or id = args[0]
          print " args = ", args
      elif len(args) == 2:
          username, name = args
          print "api args = ", args
          print 'type args', type(args)
          print 'owner: ', owner
          print 'assessment: ', assessment
      if owner is not None:
          owner = self.retrieve_user(username)
      if assessment is not None:
          assessment = self.retrieve_assessment(name)
      return super(ConvenienceAPI, self).retrieve_assessment_result(*args)
  </code></pre>
  
  <p><strong>test.py</strong> </p>
  
  <pre><code>api.retrieve_assessment_result('baseball', 'Becoming a Leader')
  </code></pre>
  
  <p>Traceback Error:</p>
  
  <pre><code>Traceback (most recent call last):
    File "/usr/local/lib/python2.7/site-packages/nose/case.py", line 197, in runTest
      self.test(*self.arg)
    File "/Users/ack/code/venv/NotssDB/notssdb/test/test.py", line 133, in test1
      api.retrieve_assessment_result('baseball', 'Becoming a Leader')
    File "/Users/ack/code/venv/NotssDB/notssdb/api/convenience.py", line 42, in retrieve_assessment_result
      return super(ConvenienceAPI, self).retrieve_assessment_result(*args)
    File "/Users/ack/code/venv/NotssDB/notssdb/api/object.py", line 327, in retrieve_assessment_result
      filter(Assessment_Result.owner == owner).one()
    File "/usr/local/lib/python2.7/site-packages/sqlalchemy/sql/operators.py", line 301, in __eq__
      return self.operate(eq, other)
    File "/usr/local/lib/python2.7/site-packages/sqlalchemy/orm/attributes.py", line 175, in operate
      return op(self.comparator, *other, **kwargs)
    File "/usr/local/lib/python2.7/site-packages/sqlalchemy/orm/relationships.py", line 1011, in __eq__
      other, adapt_source=self.adapter))
    File "/usr/local/lib/python2.7/site-packages/sqlalchemy/orm/relationships.py", line 1338, in _optimized_compare
      state = attributes.instance_state(state)
  AttributeError: 'str' object has no attribute '_sa_instance_state'
  ------output--------
  &lt;Assessment_Result(owner='&lt;User(username ='bambam', firstname ='Sean', lastname ='Cargo', email='car@gmail.com')&gt;', assessment='&lt;Assessment(name='Foo', text='this is foo')&gt;')&gt;
  api args =  ('baseball', 'Becoming a Leader')
  type args &lt;type 'tuple'&gt;
  owner:  None
  assessment:  None
  testa baseball Becoming a Leader None
  testo baseball
  </code></pre>
  
  <p><em>-----updates after comment/suggestions:</em><br>
  <strong>object.py</strong> Updated:</p>
  
  <pre><code>def retrieve_assessment_result(self, id=None, owner=None, assessment=None):
      print 'test_all_objects', owner, assessment, id
      if id is not None:
          print 'test_id_object', id
          return self.session.query(Assessment_Result).\
          filter(Assessment_Result.id == id).one()
      elif owner is not None:
          print 'test_owner_object', owner
          return self.session.query(Assessment_Result).\
          filter(Assessment_Result.owner.has(User.username == username)).one()
      elif assessment is not None:
          print 'test_assessment_object', assessment
          return self.session.query(Assessment_Result).\
          filter(Assessment_Result.assessment.has(Assessment.name == name)).one()
  </code></pre>
  
  <p><strong>Convenience.py</strong> (inherited from <strong>object.py</strong>) change: </p>
  
  <pre><code>def retrieve_assessment_result(self, id=None, owner=username, assessment=name):
      if owner is not None:
          owner = self.retrieve_user(username)
      if assessment is not None:
          assessment = self.retrieve_assessment(name)
      return super(ConvenienceAPI, self).retrieve_assessment_result(id=None, owner=owner, assessment=assessment)
  </code></pre>
  
  <p>Traceback: </p>
  
  <pre><code>  File ".../api/convenience.py", line 6, in &lt;module&gt;
      class ConvenienceAPI(BaseAPI):
    File "../api/convenience.py", line 37, in ConvenienceAPI
      def retrieve_assessment_result(self, id=None, owner=username, assessment=name):
  NameError: name 'username' is not defined
  </code></pre>