title: Pyramid error: AttributeError: No session factory registered
body: <p>I'm trying to learn Pyramid and having problems getting the message flash to work.  I'm totally new but read the documentation and did the tutorials.</p>
  
  <p>I did the tutorial on creating a wiki(<a href="http://docs.pylonsproject.org/projects/pyramid/en/1.3-branch/tutorials/wiki2/index.html" rel="nofollow">tutorial here</a>, <a href="https://github.com/Pylons/pyramid/tree/1.3-branch/docs/tutorials/wiki2/src" rel="nofollow">Code here</a> ). It worked great and was pretty easy so I decided to try to apply the flash message I saw in todo list tutorial I did(<a href="http://docs.pylonsproject.org/projects/pyramid_tutorials/en/latest/single_file_tasks/single_file_tasks.html" rel="nofollow">tutorial here</a>, full code is in a single file at the bottom of the page). Basically when a todo list is created, the page is refreshed with a message saying 'New task was successfully added!'. I wanted to do that everytime someone updated a wiki article in the wiki tutorial.</p>
  
  <p>So I re-read the session section in the documentaion and it says I really just need to do this:</p>
  
  <pre><code>from pyramid.session import UnencryptedCookieSessionFactoryConfig
  my_session_factory = UnencryptedCookieSessionFactoryConfig('itsaseekreet')
  from pyramid.config import Configurator
  config = Configurator(session_factory = my_session_factory)
  </code></pre>
  
  <p>then in my code I need to add: <code>request.session.flash('New wiki was successfully added!')</code> but I get a error everytime: Pyramid error: AttributeError: No session factory registered</p>
  
  <p>Here's my function(its the exact same from the tutorial except for the request.session.flash part):</p>
  
  <pre><code>@view_config(route_name='edit_page', renderer='templates/edit.pt', permission='edit')
  def edit_page(request):
      name = request.matchdict['pagename']
      page = DBSession.query(Page).filter_by(name=name).one()
      if 'form.submitted' in request.params:
          page.data = request.params['body']
          DBSession.add(page)
          request.session.flash('page was successfully edited!')
          return HTTPFound(location = request.route_url('view_page',
                                                        pagename=name))
  
      return dict(
          page=page,
          save_url = request.route_url('edit_page', pagename=name),
          logged_in=authenticated_userid(request),
          )
  </code></pre>
  
  <p>(note: One thing that I think I could be doing wrong is in the todo example, all the data is in one file, but in the wiki example there are several files..I added my session imports in the view.py file because the flash message is being generated by the view itself).</p>
  
  <p>What am I doing wrong?  Any suggestions?</p>