title: Flask - AttributeError: 'module' object has no attribute 'items'
body: <p>I am using flask-restful and have the following API class:</p>
  
  <p><code>views.py</code></p>
  
  <pre><code>from datetime import date
  from flask import jsonify
  from flask.ext.restful import Resource, reqparse
  from backend import db
  from .models import User, Post, Comment, WorkExperience
  from flask.ext.restful import fields, marshal
  from backend.helpers import AuthRequiredResource, UserMixin
  
  class CommentList(UserMixin, AuthRequiredResource):
      def __init__(self):
          self.fields = {
              'id': fields.Integer,
              'body': fields.String,
              'added_on': fields.DateTime
  
          }
  
          self.parser = reqparse.RequestParser()
          self.parser.add_argument('body')
          super(CommentList, self).__init__()
  
      def get(self, post_id):
          comments = Post.query.get_or_404(post_id).comments.all()
          # APPEARS THAT THE ERROR ARISES HERE
          return marshal(comments, fields)
  
      def post(self, post_id):
          args = self.parser.parse_args()
          user = self.get_user()
          c = Comment(post_id, args['body'], user.id)
          db.session.add(c)
          db.session.commit()
  </code></pre>
  
  <p><code>helper.py</code></p>
  
  <pre><code>from flask import request
  from flask.ext.restful import Resource
  
  from backend.models import User
  
  class UserMixin(object):
      @staticmethod
      def get_user():
          user = User.query.filter_by(
              auth_token=request.headers.environ.get('HTTP_AUTHORIZATION')
          ).first()
          if user is None:
              return {'message': 'Invalid auth token'}, 401
          return user
  
  
  class AuthRequiredResource(Resource):
      def dispatch_request(self, *args, **kwargs):
  
          if request.headers.environ.get('HTTP_AUTHORIZATION', None) is not None:
              return super(AuthRequiredResource, self).dispatch_request(*args,
                                                                        **kwargs)
          else:
              return {'message': 'Auth Token missing'}, 401
  </code></pre>
  
  <p>I'm facing a <code>AttributeError: 'module' object has no attribute 'items'</code>.</p>
  
  <p>The traceback is:</p>
  
  <pre><code>File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1836, in __call__
      return self.wsgi_app(environ, start_response)
    File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1820, in wsgi_app
      response = self.make_response(self.handle_exception(e))
    File "/home/utkbansal/.virtualenvs/cv_backend/lib/python2.7/site-packages/flask_restful/__init__.py", line 271, in error_router
      return original_handler(e)
    File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1403, in handle_exception
      reraise(exc_type, exc_value, tb)
    File "/home/utkbansal/.virtualenvs/cv_backend/lib/python2.7/site-packages/flask_restful/__init__.py", line 268, in error_router
      return self.handle_error(e)
    File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1817, in wsgi_app
      response = self.full_dispatch_request()
    File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1477, in full_dispatch_request
      rv = self.handle_user_exception(e)
    File "/home/utkbansal/.virtualenvs/cv_backend/lib/python2.7/site-packages/flask_restful/__init__.py", line 271, in error_router
      return original_handler(e)
    File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1381, in handle_user_exception
      reraise(exc_type, exc_value, tb)
    File "/home/utkbansal/.virtualenvs/cv_backend/lib/python2.7/site-packages/flask_restful/__init__.py", line 268, in error_router
      return self.handle_error(e)
    File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1475, in full_dispatch_request
      rv = self.dispatch_request()
    File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1461, in dispatch_request
      return self.view_functions[rule.endpoint](**req.view_args)
    File "/home/utkbansal/.virtualenvs/cv_backend/lib/python2.7/site-packages/flask_restful/__init__.py", line 477, in wrapper
      resp = resource(*args, **kwargs)
    File "/usr/local/lib/python2.7/dist-packages/flask/views.py", line 84, in view
      return self.dispatch_request(*args, **kwargs)
    File "/home/utkbansal/PycharmProjects/cv_backend/backend/helpers.py", line 12, in dispatch_request
      **kwargs)
    File "/home/utkbansal/.virtualenvs/cv_backend/lib/python2.7/site-packages/flask_restful/__init__.py", line 587, in dispatch_request
      resp = meth(*args, **kwargs)
    File "/home/utkbansal/PycharmProjects/cv_backend/backend/views.py", line 130, in get
      return marshal(comments, fields)
    File "/home/utkbansal/.virtualenvs/cv_backend/lib/python2.7/site-packages/flask_restful/__init__.py", line 635, in marshal
      if envelope else [marshal(d, fields) for d in data])
    File "/home/utkbansal/.virtualenvs/cv_backend/lib/python2.7/site-packages/flask_restful/__init__.py", line 639, in marshal
      for k, v in fields.items())
  AttributeError: 'module' object has no attribute 'items'
  </code></pre>
  
  <p>Looking at similar questions, this might be a circular dependency problem, but I'm unable to figure it out. So I have included all the imports of both the files above.</p>
  
  <h1>EDIT</h1>
  
  <p>The error may be on the return line of the get method, in using the marshall function.</p>