Skip to content

Commit

Permalink
Removes ability to provide a SQLAlchemy Session class when initializi…
Browse files Browse the repository at this point in the history
…ng APIManager; now only instances of Session are allowed.
  • Loading branch information
jfinkels committed Jan 16, 2013
1 parent 995754a commit 90f24b5
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 23 deletions.
3 changes: 3 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ Version 0.9.0-dev

Not yet released.

- Removed ability to provide a :class:`~sqlalchemy.orm.session.Session` class
when initializing :class:`APIManager`; provide an instance of the class
instead.
- Changes some dynamically loaded relationships used for testing and in
examples to be many-to-one instead of the incorrect one-to-many. Versions of
SQLAlchemy after 0.8.0b2 raise an exception when the latter is used.
Expand Down
7 changes: 0 additions & 7 deletions docs/basicusage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -110,13 +110,6 @@ instead::

manager = APIManager(app, session=mysession)

You may also provide the session class (as returned by
:class:`sqlalchemy.orm.sessionmaker`); in this case Flask-Restless will
instantiate a new :class:`sqlalchemy.orm.scoped_session` from the provided
class::

manager = APIManager(app, session=Session)

Third, create the API endpoints which will be accessible to web clients::

person_blueprint = manager.create_api(Person,
Expand Down
2 changes: 0 additions & 2 deletions flask_restless/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,6 @@ def init_app(self, app, session=None, flask_sqlalchemy_db=None):
"""
self.app = app
self.session = session or getattr(flask_sqlalchemy_db, 'session', None)
if isinstance(self.session, type):
self.session = scoped_session(self.session)

def create_api_blueprint(self, model, methods=READONLY_METHODS,
url_prefix='/api', collection_name=None,
Expand Down
14 changes: 0 additions & 14 deletions tests/test_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -380,20 +380,6 @@ def test_different_urls(self):
response = self.app.get('/get/person/1')
self.assertEqual(response.status_code, 404)

def test_session_class(self):
"""Test for providing a session class instead of a sesssion instance.
"""
manager = APIManager(self.flaskapp, session=self.Session)
manager.create_api(self.Person, methods=['GET', 'POST'])
response = self.app.get('/api/person')
self.assertEqual(response.status_code, 200)
response = self.app.post('/api/person', data=dumps(dict(name='foo')))
self.assertEqual(response.status_code, 201)
response = self.app.get('/api/person/1')
self.assertEqual(response.status_code, 200)
self.assertEqual(loads(response.data)['id'], 1)

def test_max_results_per_page(self):
"""Test for specifying the ``max_results_per_page`` keyword argument.
Expand Down

0 comments on commit 90f24b5

Please sign in to comment.