Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
amcgregor committed Sep 25, 2016
2 parents 22a3577 + 80f297b commit 0ff72c1
Show file tree
Hide file tree
Showing 37 changed files with 2,056 additions and 387 deletions.
34 changes: 14 additions & 20 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,36 +1,30 @@
*.py[co]

# Packages
*.egg
# Packaging
*.egg-info
dist
build
eggs
.eggs
parts
.packaging

# Virtual Environment Pseudo-Chroot
bin
lib
usr
var
sdist
develop-eggs
.installed.cfg

# Installer logs
pip-log.txt
include
share
tmp

# Unit test / coverage reports
.coverage
# Unit Test / Coverage Reports
coverage.xml
.coverage
.tox
.cagoule.db
.cache/

# Translations
*.mo
htmlcov/

# Mac
.DS_Store

# Extras
thirdparty/
htmlcov/
# Completion Integration
.ropeproject

Empty file added .packaging/keep
Empty file.
17 changes: 12 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
language: python
sudo: false
cache: pip

branches:
except:
- /^[^/]+/.+$/

branches:
except:
Expand All @@ -13,13 +18,15 @@ python:
- "3.4"
- "3.5"

env:
- PYTHONOPTIMIZE=0
- PYTHONOPTIMIZE=1
install:
- travis_retry pip install --upgrade setuptools pip pytest pytest-cov codecov
- pip install -e '.[development]'

install: travis_retry .travis/install.sh
script:
python setup.py test

script: .travis/run.sh
after_script:
bash <(curl -s https://codecov.io/bash)

notifications:
irc:
Expand Down
10 changes: 0 additions & 10 deletions .travis/install.sh

This file was deleted.

8 changes: 0 additions & 8 deletions .travis/run.sh

This file was deleted.

27 changes: 16 additions & 11 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -362,20 +362,25 @@ Version History
Version 2.0
-----------

* A complete modernization rewrite of WebCore, from the ground up.
* Features multiple extension interfaces to extend registered view handlers and provide a uniform callback mechanism.
* Standard usage makes use of no superglobals or "thread locals", instead relying on a context object collaboratively
- A complete modernization rewrite of WebCore, from the ground up.
- Features multiple extension interfaces to extend registered view handlers and provide a uniform callback mechanism.
- Standard usage makes use of no superglobals or "thread locals", instead relying on a context object collaboratively
populated by extensions.
* WebCore's former "dialect" system is now dispatch.
- WebCore's former "dialect" system is now dispatch.

Version 2.0.1
-------------

* Corrected argument specification for ``transform`` extension callbacks, fixing ``AnnotationExtension`` usage as per
`#163 <https://github.com/marrow/WebCore/issues/163>`_..
* Additional source-level documentation and expanded examples.
* An excessively large number of additional WSGI server adapters; now supported are: `waitress
<http://s.webcore.io/aIou>`_, `tornado <http://s.webcore.io/aIaN>`_, `fcgi <http://s.webcore.io/fhVY>`_,
- Thanks Pypi.

Version 2.0.2
-------------

- Corrected argument specification for ``transform`` extension callbacks, fixing ``AnnotationExtension`` usage as per
`#163 <https://github.com/marrow/WebCore/issues/163>`_.
- Additional source-level documentation and expanded examples.
- An excessively large number of additional WSGI server adapters; now supported are: waitress
`tornado <http://s.webcore.io/aIaN>`_, `fcgi <http://s.webcore.io/fhVY>`_,
`cherrypy <http://s.webcore.io/aIoF>`_, `appengine <http://s.webcore.io/aIic>`_, `paste <http://s.webcore.io/aIdT>`_,
`eventlet <http://s.webcore.io/aIaa>`_, `gevent <http://s.webcore.io/aIpU>`_, `diesel <http://s.webcore.io/aIg2>`_,
and `bjoern <http://s.webcore.io/aIne>`_. Each is available as an ``extras_require`` by the same name which will
Expand Down Expand Up @@ -447,12 +452,12 @@ OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
:target: https://github.com/marrow/WebCore/issues
:alt: Github Issues

.. |ghsince| image:: https://img.shields.io/github/commits-since/marrow/WebCore/2.0.0.svg
.. |ghsince| image:: https://img.shields.io/github/commits-since/marrow/WebCore/2.0.2.svg
:target: https://github.com/marrow/WebCore/commits/develop
:alt: Changes since last release.

.. |ghtag| image:: https://img.shields.io/github/tag/marrow/WebCore.svg
:target: https://github.com/marrow/WebCore/tree/1.0
:target: https://github.com/marrow/WebCore/tree/2.0.2
:alt: Latest Github tagged release.

.. |latestversion| image:: http://img.shields.io/pypi/v/WebCore.svg?style=flat
Expand Down
2 changes: 1 addition & 1 deletion example/basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ def basic(context, name="world"):
if __name__ == '__main__':
from web.core import Application

Application(basic).serve('waitress')
Application(basic).serve('waitress', threads=16)

2 changes: 1 addition & 1 deletion example/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,5 +100,5 @@ def index(self):
if __name__ == '__main__':
from web.core.application import Application

Application(Root, logging={'level': 'debug'})
Application(Root, logging={'level': 'info'}).serve('waitress', threads=15)

1 change: 1 addition & 0 deletions example/debugger.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@


def basic(context, name="world"):
1/0
return "Hello {name}.".format(name=name)


Expand Down
83 changes: 81 additions & 2 deletions example/extension.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
# encoding: utf-8


# Standard Logger object.
log = __import__('logging').getLogger(__name__)


# Example extensions.

class Extension(object):
"""A template of a WebCore 2 extension.
Expand Down Expand Up @@ -127,11 +133,14 @@ def before(self, context):
def after(self, context):
"""Executed after dispatch has returned and the response populated, prior to anything being sent to the client.
Similar to middleware, the first extension registered has its `after` method called last.
Similar to middleware, the first extension registered has its `after` method called last. Additionally, if
there is an internal exception, even if that exception will propagate, this callback will be run. Inspect
`context.response.status` to see if the response was successful. (Executed in the context of processing an
exception in most cases where one would be raised.)
"""
pass

def mutate(self, context, handler, args, kw):
def mutate(self, context, handler, bound, args, kw):
"""Inspect and potentially mutate the given handler's arguments.
The args list and kw dictionary may be freely modified, though invalid arguments to the handler will fail.
Expand All @@ -142,6 +151,16 @@ def transform(self, context, handler, result):
"""Transform outgoing values prior to view lookup."""
pass

def done(self, context):
"""Executed after the entire response has completed generating.
This might seem to duplicate the purpose of `after`; the distinction is with iterable or generator WSGI bodies
whose processing is deferred until after WebCore has returned. This callback will be executed once iteration
of the body is complete whereas `after` is executed prior to iteration of the body, but after endpoint
execution.
"""
pass

def interactive(self):
"""Populate an interactive shell."""
return dict()
Expand All @@ -150,3 +169,63 @@ def inspect(self, context):
"""Return an object conforming to the inspector panel API."""

pass


class TransactionalExtension(object):
"""A more targeted extension example focusing on transaction behaviour within WebCore.
The TransactionExtension must be present in the Application prior to use.
"""

needs = {'transaction'}

# New! These are callbacks only executed if the TransactionExtension has been configured.

def begin(self, context):
"""Do the work nessicary to begin a transaction.
This happens during the `prepare` stage if automatic behaviour is indicated, prior to any extensions
dependency graphed to `need` or `use` yours executing, otherwise, it is only optionally begun upon
request during the endpoint and response generation lifecycle.
{move:OtM}, committed prior to the final WSGI application (WebOb) being executed and returned from our own.
"""

pass

def vote(self, context):
"""Called to ask extensions if the transaction is still valid."""

pass

def finish(self, context):
"""Called to complete a transaction, but only if the transaction is valid."""

pass

def abort(self, context):
"""Called if the vote failed, and the transaction is not valid at time of completion."""

pass

# Understanding behaviour, automatic transaction interactions with existing extension callbacks.

def prepare(self, context):
"""At this point the underlying machinery has been prepared.
Code may be running under a transaction if automatic behaviour was indicated by configuration of the
`TransactionExtension`; currently the default is to automatically start a transaction during `prepare` and
commit on successful HTTP status codes, prior to final delivery of the response content.
{move:TrEx}This has the consequence that in streaming usage, a failure in delivery, or failure in generation (i.e. by
template engine) of that streamed content, is not an error in the processing of the endpoint itself. If the
original endpoint indicated success, the transaction is committed.
"""

pass

def done(self, context):
"""The last chance to perform any work within an automatic managed transaction."""
pass



19 changes: 17 additions & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
[pytest]
addopts = --flakes --spec --cov-report term-missing --cov-report html --cov-report xml --no-cov-on-fail --cov web -l --durations=5 -r fEsxw --color=yes test/
[aliases]
test = pytest

[check]
metadata = 1

[install]
optimize = 1

[register]
strict = 1

[tool:pytest]
addopts =
-l -r fEsxw --flakes --cov web --no-cov-on-fail --durations=5 --color=yes
--cov-report term-missing --cov-report html --cov-report xml
test

; Recommended methods of execution: py.test, py.test --cagoule-capture, py.test --diff, py.test --diff --stepwise

Expand Down
Loading

0 comments on commit 0ff72c1

Please sign in to comment.