title: Decorators: flask/flask_login, using login_required
body: <p>I want to use my rendering function both with and without the flask <code>login_required</code> decorator.  My attempt was as follows:  define the basic function, then assign to a new variable, wrapped with <code>login_required</code>:</p>
  
  <pre><code>import pymongo
  from flask import render_template
  from flask_login import login_required
  
  def base_page(collection='posts'):
      db = pymongo.MongoClient().www
      title = collection.capitalize()
      page = db[collection].find().sort("created", pymongo.DESCENDING)
      return render_template('home/home.html', **locals())
  
  base_page_login_required = login_required(base_page)
  </code></pre>
  
  <p>I then use these in my <code>app.add_url_rule</code> calls:</p>
  
  <pre><code>app.add_url_rule('/blog', view_func=base_page, defaults={'collection': 'posts'})
  app.add_url_rule('/users', view_func=base_page_login_required, defaults={'collection': 'users'})
  </code></pre>
  
  <p>But obviously I've got something wrong:</p>
  
  <pre><code>Traceback (most recent call last):\r, referer: http://localhost/
     File "C:/www/flask/wsgi.py", line 26, in &lt;module&gt;\r, referer: http://localhost/
       app.add_url_rule('/users', view_func=base_page_login_required, defaults={'collection': 'users'})\r, referer: http://localhost/
     File "C:\\bin\\Python34\\lib\\site-packages\\flask\\app.py", line 62, in wrapper_func\r, referer: http://localhost/
       return f(self, *args, **kwargs)\r, referer: http://localhost/
     File "C:\\bin\\Python34\\lib\\site-packages\\flask\\app.py", line 984, in add_url_rule\r, referer: http://localhost/
       'existing endpoint function: %s' % endpoint)\r, referer: http://localhost/
   AssertionError: View function mapping is overwriting an existing endpoint function: base_page\r, referer: http://localhost/
  </code></pre>
  
  <p>Can anyone help me understand this error?  I assume this is specific to flask and <code>add_url_rule</code>.  I know I could just copy the first function code to a second and use the decorator normally, but I want to follow DRY.</p>