old_contents: """
  run.py: A simple example app for using the Annotator Store blueprint
  
  This file creates and runs a Flask[1] application which mounts the Annotator
  Store blueprint at its root. It demonstrates how the major components of the
  Annotator Store (namely the 'store' blueprint, the annotation model and the
  auth and authz helper modules) fit together, but it is emphatically NOT
  INTENDED FOR PRODUCTION USE.
  
  [1]: http://flask.pocoo.org
  """
  
  from __future__ import print_function
  
  import os
  import sys
  
  from flask import Flask, g, current_app
  from annotator import es, annotation, auth, authz, store
  from tests.helpers import MockUser, MockConsumer, MockAuthenticator
  from tests.helpers import mock_authorizer
  
  here = os.path.dirname(__file__)
  
  def main():
      app = Flask(__name__)
  
      try:
          app.config.from_pyfile(os.path.join(here, 'annotator.cfg'))
      except IOError:
          print("Please copy example config from annotator.cfg.example to annotator.cfg", file=sys.stderr)
          sys.exit(1)
  
      es.init_app(app)
  
      with app.test_request_context():
          annotation.Annotation.create_all()
  
      @app.before_request
      def before_request():
          # In a real app, the current user and consumer would be determined by
          # a lookup in either the session or the request headers, as described
          # in the Annotator authentication documentation[1].
          #
          # [1]: https://github.com/okfn/annotator/wiki/Authentication
          g.user = MockUser('alice')
  
          # By default, this test application won't do full-on authentication
          # tests. Set AUTH_ON to True in the config file to enable (limited)
          # authentication testing.
          if current_app.config['AUTH_ON']:
              g.auth = auth.Authenticator(lambda x: MockConsumer('annotateit'))
          else:
              g.auth = MockAuthenticator()
  
          # Similarly, this test application won't prevent you from modifying
          # annotations you don't own, deleting annotations you're disallowed
          # from deleting, etc. Set AUTHZ_ON to True in the config file to
          # enable authorization testing.
          if current_app.config['AUTHZ_ON']:
              g.authorize = authz.authorize
          else:
              g.authorize = mock_authorizer
  
      app.register_blueprint(store.store)
  
      host = os.environ.get('HOST', '127.0.0.1')
      port = int(os.environ.get('PORT', 5000))
      app.run(host=host, port=port)
  
  if __name__ == '__main__':
      main()
  
new_contents: """
  run.py: A simple example app for using the Annotator Store blueprint
  
  This file creates and runs a Flask[1] application which mounts the Annotator
  Store blueprint at its root. It demonstrates how the major components of the
  Annotator Store (namely the 'store' blueprint, the annotation model and the
  auth and authz helper modules) fit together, but it is emphatically NOT
  INTENDED FOR PRODUCTION USE.
  
  [1]: http://flask.pocoo.org
  """
  
  from __future__ import print_function
  
  import os
  import sys
  
  from flask import Flask, g, current_app
  from annotator import es, annotation, auth, authz, document, store
  from tests.helpers import MockUser, MockConsumer, MockAuthenticator
  from tests.helpers import mock_authorizer
  
  here = os.path.dirname(__file__)
  
  def main():
      app = Flask(__name__)
  
      try:
          app.config.from_pyfile(os.path.join(here, 'annotator.cfg'))
      except IOError:
          print("Please copy example config from annotator.cfg.example to annotator.cfg", file=sys.stderr)
          sys.exit(1)
  
      es.init_app(app)
  
      with app.test_request_context():
          annotation.Annotation.create_all()
          document.Document.create_all()
  
      @app.before_request
      def before_request():
          # In a real app, the current user and consumer would be determined by
          # a lookup in either the session or the request headers, as described
          # in the Annotator authentication documentation[1].
          #
          # [1]: https://github.com/okfn/annotator/wiki/Authentication
          g.user = MockUser('alice')
  
          # By default, this test application won't do full-on authentication
          # tests. Set AUTH_ON to True in the config file to enable (limited)
          # authentication testing.
          if current_app.config['AUTH_ON']:
              g.auth = auth.Authenticator(lambda x: MockConsumer('annotateit'))
          else:
              g.auth = MockAuthenticator()
  
          # Similarly, this test application won't prevent you from modifying
          # annotations you don't own, deleting annotations you're disallowed
          # from deleting, etc. Set AUTHZ_ON to True in the config file to
          # enable authorization testing.
          if current_app.config['AUTHZ_ON']:
              g.authorize = authz.authorize
          else:
              g.authorize = mock_authorizer
  
      app.register_blueprint(store.store)
  
      host = os.environ.get('HOST', '127.0.0.1')
      port = int(os.environ.get('PORT', 5000))
      app.run(host=host, port=port)
  
  if __name__ == '__main__':
      main()
  
subject: use Document in run.py