title: Instantiating SQLAlchemy Base object with session query methods
body: <p>Here's the simplest description of my SQLAlchemy model:</p>
  
  <p>A Host object (subclass of Base), and a Network object (also Base). Host has a 1:Many relationship with the Network, and the Network object to be associated with the Host can be directly identified with the information given to the Host object as part of its initilization. (i.e. Host's <code>__init__()</code> is supplied with all the necessary information to be able to find the Network object with an SQLAlchemy session.</p>
  
  <p>What I was considering doing was to pass the sqlalchemy session into the Host object so that <code>Host.__init__()</code> can query the database and find the proper Network object, i.e. </p>
  
  <pre><code>new_host = Host(sqlalchemy_sb_session, ip_address)
  </code></pre>
  
  <p>and make the association directly in <code>__init__()</code>. That seems very ugly to me, but I can't think of any other way to have the Host object be able to associate itself to a Network object.</p>
  
  <p>I know this would work, but there must be a better way. How would anyone else solve this problem?</p>