Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit baf9069
Showing
12 changed files
with
537 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
.idea/ | ||
venv35/ | ||
*.pyc | ||
__pycache__ | ||
test1.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
sudo: false | ||
cache: | ||
- pip | ||
language: python | ||
python: | ||
- '3.5' | ||
env: | ||
- SANIC=0.6.0 | ||
install: | ||
- pip install -U setuptools pep8 coverage docutils pygments sanic==$SANIC aiohttp | ||
script: | ||
- coverage erase | ||
- nosetests --with-coverage --cover-package=spf | ||
- python setup.py clean build install | ||
after_success: | ||
- pep8 spf.py | ||
deploy: | ||
provider: pypi | ||
user: ashleysommer | ||
distributions: sdist bdist_wheel | ||
on: | ||
tags: true | ||
repo: ashleysommer/sanic-plugins-framework | ||
password: | ||
secure: cnwEYQjhEx0BOP1tdFBeFnKHUpDfZWLKkXf7N36+AOOEjBgK72D03DCsKcCt1iZJPv7KcUIK84vZzmTPBmdvGyxJNTBTJRyPpPXw1TkokxFVwVutIrMCPJB6Nchd0ZLY8tarTNdEnR3y24AWfqP6EyD0Z4mRHHX9jwnNqxQi2aMsh2tVYMPk8IlfMSyxBM6R0rlh2Ahx5GWahuvHgmJBBovp9EED9vBHOUUIREI9rU0O2SPN1hxFXH5g6QFze3iaNKsxeXO02RfWSoK3dGCa5AYnwWeraX4nTCRA6t8l7mFKdwzjpUdklFm102StQGo4h+EqXsBEGVFhrwb/SSdPcwG/pdJsfiHBLeoPhb5amI1US68OBLVYz9m4p3fH/PSB6PjMER6WYc3dxtVjfSc8+8PSKwLeN3N5ucjZJ9OtcIiRt+yiOoh+HYfTpSCEeZpG6G+TnAhUD/WDFBTt8aQxjw2wTHdyY+D9+B8a5VHm2PvNr7tEUFW/JfpFSBM02pFc0I01Gvxn67sXDzx+6ccrtVCSs/QP8AfsYLTHu3tAYHE52appYPMQ+EkIHiQB7tKfVLr1FtvQNbJcN4q7OCS7v+R0lE08KcZ3COGK66jpKg9gORjrk6Uw7drGrW3fs1vB8cLXOeQAxz9NYJuhSl5FYww+0oGJ3QjzcK/ABxMVtB8= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
Copyright (c) 2017 Cory Dolphin, Olin College | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
Sanic Plugins Framework | ||
========== | ||
|
||
|Build Status| |Latest Version| |Supported Python versions| | ||
|License| | ||
|
||
TODO: About | ||
|
||
Installation | ||
------------ | ||
|
||
Install the extension with using pip, or easy\_install. | ||
|
||
.. code:: bash | ||
$ pip install -U sanic-plugins-framework | ||
Usage | ||
----- | ||
|
||
Contributing | ||
------------ | ||
|
||
Questions, comments or improvements? Please create an issue on | ||
`Github <https://github.com/ashleysommer/sanicpluginsframework>`__ | ||
Credits | ||
------- | ||
|
||
|
||
.. |Build Status| image:: https://api.travis-ci.org/ashleysommer/sanic-cors.svg?branch=master | ||
:target: https://travis-ci.org/ashleysommer/sanic-cors | ||
.. |Latest Version| image:: https://img.shields.io/pypi/v/Sanic-Cors.svg | ||
:target: https://pypi.python.org/pypi/Sanic-Cors/ | ||
.. |Supported Python versions| image:: https://img.shields.io/pypi/pyversions/Sanic-Cors.svg | ||
:target: https://img.shields.io/pypi/pyversions/Sanic-Cors.svg | ||
.. |License| image:: http://img.shields.io/:license-mit-blue.svg | ||
:target: https://pypi.python.org/pypi/Sanic-Plugins-Framework/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
from sanic import Sanic | ||
from sanic.response import text | ||
|
||
from spf.plugin import SanicPluginsFramework | ||
from my_plugin import my_plugin | ||
from logging import DEBUG | ||
|
||
app = Sanic(__name__) | ||
spf = SanicPluginsFramework(app) | ||
my_plugin = spf.register_plugin(my_plugin) | ||
|
||
|
||
@app.route('/') | ||
def index(request): | ||
return text("hello world") | ||
|
||
if __name__ == "__main__": | ||
app.run("127.0.0.1", port=8098, debug=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
from logging import DEBUG | ||
from spf.plugin import SanicPlugin | ||
from sanic.response import text | ||
|
||
class MyPlugin(SanicPlugin): | ||
pass | ||
|
||
my_plugin = MyPlugin() | ||
|
||
@my_plugin.middleware(priority=6, with_context=True) | ||
def mw1(request, context): | ||
context['test1'] = "test" | ||
print("Hello world") | ||
|
||
|
||
@my_plugin.middleware(priority=7, with_context=True) | ||
def mw2(request, context): | ||
assert 'test1' in context and context['test1'] == "test" | ||
context['test2'] = "testb" | ||
print("Hello world") | ||
|
||
|
||
@my_plugin.middleware(priority=8, kind='response', relative='pre', with_context=True) | ||
def mw3(request, response, context): | ||
assert 'test1' in context and context['test1'] == "test" | ||
assert 'test2' in context and context['test2'] == "testb" | ||
print("Hello world") | ||
|
||
|
||
@my_plugin.middleware(priority=2, with_context=True) | ||
def mw4(request, context): | ||
print(context) | ||
my_plugin.log(DEBUG, "Hello Middleware") | ||
|
||
@my_plugin.route('/test_plugin', with_context=False) | ||
def t1(request): | ||
c = my_plugin.context | ||
return text('from plugin!') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
sanic>=0.6.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[bdist_wheel] | ||
universal = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# -*- coding: utf-8 -*- | ||
""" | ||
setup | ||
~~~~ | ||
TODO: About | ||
:copyright: (c) 2017 by Ashley Sommer. | ||
:license: MIT, see LICENSE for more details. | ||
""" | ||
|
||
from setuptools import setup | ||
from os.path import join, dirname | ||
|
||
with open(join(dirname(__file__), 'spf/version.py'), 'r') as f: | ||
exec(f.read()) | ||
|
||
with open(join(dirname(__file__), 'requirements.txt'), 'r') as f: | ||
install_requires = f.read().split("\n") | ||
|
||
setup( | ||
name='Sanic-Cors', | ||
version=__version__, | ||
url='https://github.com/ashleysommer/sanicpluginsframework', | ||
license='MIT', | ||
author='Ashley Sommer', | ||
author_email='ashleysommer@gmail.com', | ||
description="TODO: desc", | ||
long_description=open('README.rst').read(), | ||
packages=['sanic_cors'], | ||
zip_safe=False, | ||
include_package_data=True, | ||
platforms='any', | ||
install_requires=install_requires, | ||
tests_require=[ | ||
'nose' | ||
], | ||
test_suite='nose.collector', | ||
classifiers=[ | ||
'Environment :: Web Environment', | ||
'Intended Audience :: Developers', | ||
'License :: OSI Approved :: MIT License', | ||
'Operating System :: OS Independent', | ||
'Programming Language :: Python', | ||
'Programming Language :: Python :: 3', | ||
'Programming Language :: Python :: Implementation :: CPython', | ||
'Programming Language :: Python :: Implementation :: PyPy', | ||
'Topic :: Internet :: WWW/HTTP :: Dynamic Content', | ||
'Topic :: Software Development :: Libraries :: Python Modules' | ||
] | ||
) |
Empty file.
Oops, something went wrong.