title: Flask-Restful error: "as_view" method not inherited
body: <p>I am writting a RESTful API using the Flask framework and the Flask-RESTful plugin. I define my API classes on top of the <code>Resource</code> class that this plugin provides, as in the <a href="http://flask-restful.readthedocs.org/en/latest/quickstart.html#a-minimal-api" rel="noreferrer">examples</a>. However, when I want to register my classes using the <code>add_resource</code> method I get the following error:</p>
  
  <pre><code>AttributeError: type object 'UserAPI' has no attribute 'as_view'
  </code></pre>
  
  <p>The <code>as_view</code> method is part of the <a href="http://flask.pocoo.org/docs/views/" rel="noreferrer">Flask Pluggable Views</a>, this is, the <code>View</code> class. The <code>Resource</code> class is built on top of this class, and my <code>UserAPI</code> class on top of the <code>Resource</code> class. For this reason, the <code>as_view</code> method should be inherited, but it is not.</p>
  
  <p>Any ideas on which could be the problem?</p>
  
  <p>Here you can see how I defined the classes:</p>
  
  <pre><code>from app import api, db
  from flask.ext.restful import Resource, abort
  from models import *
  
  class UserAPI(Resource):
  
      def get(self, user_id):
              user = User.query.filter(User.id == user_id)[0]
              if user is None:
                      abort(404, message="User {} doesn't exist".format(user_id))
  
              else:
                      return {'user' : user}, 201
  
  api.add_resource(UserAPI, '/api/v0.1/users/&lt;int:user_id&gt;', endpoint = 'user')
  </code></pre>
  
  <p>EDIT:</p>
  
  <p>This the full traceback:</p>
  
  <pre><code>Traceback (most recent call last):
    File "/home/app/queries.py", line 35, in &lt;module&gt;
      api.add_resource(UserAPI, '/api/v0.1/users/&lt;int:user_id&gt;', endpoint = 'user')
    File "/home/app_env/local/lib/python2.7/site-packages/flask_restful/__init__.py", line 344, in add_resource
      self._register_view(self.app, resource, *urls, **kwargs)
    File "/home/app_env/local/lib/python2.7/site-packages/flask_restful/__init__.py", line 362, in _register_view
      resource_func = self.output(resource.as_view(endpoint))
  AttributeError: type object 'UserAPI' has no attribute 'as_view'
  </code></pre>
  
  <p>Here you can see how the <code>View</code> and <code>Resource</code> classes have the <code>as_view</code> method, while my <code>UserAPI</code> class has not:</p>
  
  <pre><code>&gt;&gt;&gt; import inspect
  &gt;&gt;&gt; from flask.views import View
  &gt;&gt;&gt; inspect.getmembers(View, predicate=inspect.ismethod)
  [('as_view', &lt;bound method type.as_view of &lt;class 'flask.views.View'&gt;&gt;), ('dispatch_request', &lt;unbound method View.dispatch_request&gt;)]
  &gt;&gt;&gt;
  &gt;&gt;&gt; from flask.ext.restful import Resource
  &gt;&gt;&gt; inspect.getmembers(Resource, predicate=inspect.ismethod)
  [('as_view', &lt;bound method MethodViewType.as_view of &lt;class 'flask_restful.Resource'&gt;&gt;), ('dispatch_request', &lt;unbound method Resource.dispatch_request&gt;)]
  &gt;&gt;&gt;
  &gt;&gt;&gt; from app.queries import UserAPI
  &gt;&gt;&gt; inspect.getmembers(UserAPI, predicate = inspect.ismethod)
  [('__init__', &lt;unbound method UserAPI.__init__&gt;), ('__repr__', &lt;unbound method UserAPI.__repr__&gt;), ('get', &lt;unbound method UserAPI.get&gt;)]
  </code></pre>