code: def transaction(self, session=None):
          
          local_session = None
          if session is None:
              local_session = session = self.create_scoped_session()
          try:
              yield session
          finally:
              # Since ``local_session`` was created locally, close it here itself
              if local_session is not None:
                  # but wait!
                  # http://groups.google.com/group/sqlalchemy/browse_thread/thread/7c1eb642435adde7
                  # To workaround this issue with sqlalchemy, we can either:
                  #  1) pass the session object explicitly
                  #  2) do not close the session at all (bad idea - could lead to memory leaks)
                  #
                  # Till pypm implements atomic transations in client.installer,
                  # we retain this hack (i.e., we choose (2) for now)
                  pass
docs: Start a new transaction based on the passed session object. If session
          is not passed, then create one and make sure of closing it finally.