launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #05023
[Merge] lp:~lifeless/python-timeline/wsgi into lp:python-timeline
Robert Collins has proposed merging lp:~lifeless/python-timeline/wsgi into lp:python-timeline.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~lifeless/python-timeline/wsgi/+merge/75959
Provide wsgi glue to let wsgi apps use timeline in a consistent fashion.
--
https://code.launchpad.net/~lifeless/python-timeline/wsgi/+merge/75959
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~lifeless/python-timeline/wsgi into lp:python-timeline.
=== added file 'NEWS'
--- NEWS 1970-01-01 00:00:00 +0000
+++ NEWS 2011-09-19 06:54:39 +0000
@@ -0,0 +1,13 @@
+timeline NEWS
++++++++++++++
+
+Changes and improvements to timeline, grouped by release.
+
+NEXT
+----
+
+0.0.2
+-----
+
+Added a WSGI integration module - very simple, just injects a Timeline into
+environ as 'timeline.timeline'.
=== modified file 'README'
--- README 2011-08-09 22:47:47 +0000
+++ README 2011-09-19 06:54:39 +0000
@@ -55,6 +55,15 @@
At this point you can start another action. If you wish to nest actions, pass
allow_nested=True to start().
+One of the things needed when working with timelines in complex applications is
+locating the right one. Timeline provides a helper for WSGI apps:
+
+ >>> from timeline import wsgi
+ >>> app = wsgi.make_app(inner_app)
+
+Calls to app will now inject a 'timeline.timeline' variable which can be used
+by inner_app to record actions.
+
Installation
============
=== modified file 'setup.py'
--- setup.py 2011-08-09 22:51:22 +0000
+++ setup.py 2011-09-19 06:54:39 +0000
@@ -22,7 +22,7 @@
description = file(os.path.join(os.path.dirname(__file__), 'README'), 'rb').read()
setup(name="timeline",
- version="0.0.1",
+ version="0.0.2",
description="Timeline module for modelling a series of actions.",
long_description=description,
maintainer="Launchpad Developers",
=== modified file 'timeline/__init__.py'
--- timeline/__init__.py 2011-08-09 22:47:47 +0000
+++ timeline/__init__.py 2011-09-19 06:54:39 +0000
@@ -25,7 +25,7 @@
# established at this point, and setup.py will use a version of next-$(revno).
# If the releaselevel is 'final', then the tarball will be major.minor.micro.
# Otherwise it is major.minor.micro~$(revno).
-__version__ = (0, 0, 1, 'beta', 0)
+__version__ = (0, 0, 2, 'beta', 0)
__all__ = [
'Timeline',
=== modified file 'timeline/tests/__init__.py'
--- timeline/tests/__init__.py 2011-08-09 22:47:47 +0000
+++ timeline/tests/__init__.py 2011-09-19 06:54:39 +0000
@@ -24,6 +24,7 @@
'timeline',
'timedaction',
'nestingtimedaction',
+ 'wsgi',
]
return TestLoader().loadTestsFromNames(
['timeline.tests.test_' + name for name in test_mod_names])
=== added file 'timeline/tests/test_wsgi.py'
--- timeline/tests/test_wsgi.py 1970-01-01 00:00:00 +0000
+++ timeline/tests/test_wsgi.py 2011-09-19 06:54:39 +0000
@@ -0,0 +1,38 @@
+# Copyright (c) 2010, 2011, Canonical Ltd
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+# GNU Affero General Public License version 3 (see the file LICENSE).
+
+"""Tests of the WSGI integration."""
+
+import testtools
+
+from timeline.timeline import Timeline
+from timeline.wsgi import make_app
+
+
+class TestMakeApp(testtools.TestCase):
+
+ def test_app_passes_through_setting_environ_variable(self):
+ environ = {'foo': 'bar'}
+ expected_start_response = object()
+ expected_result = object()
+ def inner_app(environ, start_response):
+ self.assertIsInstance(environ['timeline.timeline'], Timeline)
+ self.assertEqual(expected_start_response, start_response)
+ self.assertEqual('bar', environ['foo'])
+ return expected_result
+ app = make_app(inner_app)
+ self.assertEqual(
+ expected_result, app(environ, expected_start_response))
=== added file 'timeline/wsgi.py'
--- timeline/wsgi.py 1970-01-01 00:00:00 +0000
+++ timeline/wsgi.py 2011-09-19 06:54:39 +0000
@@ -0,0 +1,32 @@
+# Copyright (c) 2010, 2011, Canonical Ltd
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+# GNU Affero General Public License version 3 (see the file LICENSE).
+
+"""WSGI integration."""
+
+__all__ = ['make_app']
+
+from timeline import Timeline
+
+def make_app(app):
+ """Create a WSGI app wrapping app.
+
+ The wrapper app injects an environ variable 'timeline.timeline' which is a
+ Timeline object.
+ """
+ def wrapper(environ, start_response):
+ environ['timeline.timeline'] = Timeline()
+ return app(environ, start_response)
+ return wrapper
Follow ups