Moved non-core features to the wsmeext namespace package
--HG-- rename : wsme/cornice.py => wsmeext/cornice.py rename : wsme/pecan.py => wsmeext/pecan.py rename : wsme/sphinxext.py => wsmeext/sphinxext.py rename : wsme/tg1.py => wsmeext/tg1.py rename : wsme/tg11.py => wsmeext/tg11.py rename : wsme/tg15.py => wsmeext/tg15.py
This commit is contained in:
parent
bd184770a3
commit
8736089dc9
@ -39,6 +39,10 @@ packages =
|
||||
wsme
|
||||
wsme.rest
|
||||
wsme.tests
|
||||
wsmeext
|
||||
|
||||
namespace_packages =
|
||||
wsmeext
|
||||
|
||||
extra_files =
|
||||
setup.py
|
||||
|
@ -1,7 +1,7 @@
|
||||
from pecan import expose
|
||||
from webob.exc import status_map
|
||||
from .ws import AuthorsController
|
||||
from wsme.pecan import wsexpose
|
||||
from wsmeext.pecan import wsexpose
|
||||
|
||||
|
||||
class RootController(object):
|
||||
|
@ -4,7 +4,7 @@ from pecan.rest import RestController
|
||||
from wsme.types import Base, text, wsattr
|
||||
|
||||
import wsme
|
||||
import wsme.pecan
|
||||
import wsmeext.pecan
|
||||
|
||||
|
||||
class Author(Base):
|
||||
@ -21,7 +21,7 @@ class Book(Base):
|
||||
|
||||
class BooksController(RestController):
|
||||
|
||||
@wsme.pecan.wsexpose(Book, int, int)
|
||||
@wsmeext.pecan.wsexpose(Book, int, int)
|
||||
def get(self, author_id, id):
|
||||
print repr(author_id), repr(id)
|
||||
book = Book(
|
||||
@ -30,7 +30,7 @@ class BooksController(RestController):
|
||||
author=Author(lastname=u"Proudhon"))
|
||||
return book
|
||||
|
||||
@wsme.pecan.wsexpose(Book, int, int, body=Book)
|
||||
@wsmeext.pecan.wsexpose(Book, int, int, body=Book)
|
||||
def put(self, author_id, id, book=None):
|
||||
print author_id, id
|
||||
print book
|
||||
@ -47,7 +47,7 @@ class AuthorsController(RestController):
|
||||
|
||||
books = BooksController()
|
||||
|
||||
@wsme.pecan.wsexpose([Author], [unicode], [Criterion])
|
||||
@wsmeext.pecan.wsexpose([Author], [unicode], [Criterion])
|
||||
def get_all(self, q=None, r=None):
|
||||
if q:
|
||||
return [
|
||||
@ -63,7 +63,7 @@ class AuthorsController(RestController):
|
||||
Author(id=1, firstname=u'FirstName')
|
||||
]
|
||||
|
||||
@wsme.pecan.wsexpose(Author, int)
|
||||
@wsmeext.pecan.wsexpose(Author, int)
|
||||
def get(self, id):
|
||||
if id == 999:
|
||||
raise wsme.exc.ClientSideError('Wrong ID')
|
||||
|
@ -25,7 +25,7 @@ sys.path.insert(0, os.path.abspath('..'))
|
||||
|
||||
# Add any Sphinx extension module names here, as strings. They can be extensions
|
||||
# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
|
||||
extensions = ['sphinx.ext.autodoc', 'wsme.sphinxext']
|
||||
extensions = ['sphinx.ext.autodoc', 'wsmeext.sphinxext']
|
||||
|
||||
# Add any paths that contain templates here, relative to this directory.
|
||||
templates_path = ['_templates']
|
||||
@ -40,7 +40,7 @@ source_suffix = '.rst'
|
||||
master_doc = 'index'
|
||||
|
||||
# General information about the project.
|
||||
project = u'wsme.sphinxext Test'
|
||||
project = u'wsmeext.sphinxext Test'
|
||||
copyright = u'2011, Christophe de Vienne'
|
||||
|
||||
# The version info for the project you're documenting, acts as replacement for
|
||||
|
@ -3,7 +3,7 @@ import sphinx
|
||||
import os.path
|
||||
|
||||
import wsme.types
|
||||
from wsme import sphinxext
|
||||
from wsmeext import sphinxext
|
||||
|
||||
docpath = os.path.join(
|
||||
os.path.dirname(__file__),
|
||||
|
@ -1,7 +1,7 @@
|
||||
import wsme.tg11
|
||||
import wsmeext.tg11
|
||||
from wsme import WSRoot
|
||||
from wsme.tg11 import wsexpose, wsvalidate
|
||||
import wsme.tg1
|
||||
from wsmeext.tg11 import wsexpose, wsvalidate
|
||||
import wsmeext.tg1
|
||||
|
||||
from turbogears.controllers import RootController
|
||||
|
||||
@ -25,7 +25,7 @@ class Subcontroller(object):
|
||||
|
||||
class Root(RootController):
|
||||
class UselessSubClass:
|
||||
# This class is here only to make sure wsme.tg1.scan_api
|
||||
# This class is here only to make sure wsmeext.tg1.scan_api
|
||||
# does its job properly
|
||||
pass
|
||||
|
||||
@ -36,7 +36,7 @@ class Root(RootController):
|
||||
typenamespace=test_soap.typenamespace,
|
||||
baseURL='/ws/'
|
||||
)
|
||||
ws = wsme.tg11.adapt(ws)
|
||||
ws = wsmeext.tg11.adapt(ws)
|
||||
|
||||
@wsexpose(int)
|
||||
@wsvalidate(int, int)
|
||||
@ -61,7 +61,7 @@ class TestController(unittest.TestCase):
|
||||
def tearDown(self):
|
||||
# implementation copied from turbogears.testutil.stop_server.
|
||||
# The only change is that cherrypy.root is set to None
|
||||
# AFTER stopTurbogears has been called so that wsme.tg11
|
||||
# AFTER stopTurbogears has been called so that wsmeext.tg11
|
||||
# can correctly uninstall its filter.
|
||||
if config.get("cp_started"):
|
||||
cherrypy.server.stop()
|
||||
@ -133,7 +133,7 @@ class TestController(unittest.TestCase):
|
||||
|
||||
root = MyRoot()
|
||||
|
||||
api = list(wsme.tg1._scan_api(root))
|
||||
api = list(wsmeext.tg1._scan_api(root))
|
||||
print(api)
|
||||
|
||||
self.assertEquals(len(api), 0)
|
||||
@ -152,14 +152,14 @@ class TestController(unittest.TestCase):
|
||||
c.sub = subc()
|
||||
c = subc
|
||||
root = ARoot()
|
||||
self.assertRaises(ValueError, list, wsme.tg1._scan_api(root))
|
||||
self.assertRaises(ValueError, list, wsmeext.tg1._scan_api(root))
|
||||
|
||||
def test_templates_content_type(self):
|
||||
self.assertEquals(
|
||||
"application/json",
|
||||
wsme.tg1.AutoJSONTemplate().get_content_type('dummy')
|
||||
wsmeext.tg1.AutoJSONTemplate().get_content_type('dummy')
|
||||
)
|
||||
self.assertEquals(
|
||||
"text/xml",
|
||||
wsme.tg1.AutoXMLTemplate().get_content_type('dummy')
|
||||
wsmeext.tg1.AutoXMLTemplate().get_content_type('dummy')
|
||||
)
|
||||
|
@ -1,4 +1,4 @@
|
||||
import wsme.tg15
|
||||
import wsmeext.tg15
|
||||
from wsme import WSRoot
|
||||
|
||||
from turbogears.controllers import RootController
|
||||
@ -9,14 +9,14 @@ import simplejson
|
||||
|
||||
|
||||
class Subcontroller(object):
|
||||
@wsme.tg15.wsexpose(int, int, int)
|
||||
@wsmeext.tg15.wsexpose(int, int, int)
|
||||
def add(self, a, b):
|
||||
return a + b
|
||||
|
||||
|
||||
class Root(RootController):
|
||||
class UselessSubClass:
|
||||
# This class is here only to make sure wsme.tg1.scan_api
|
||||
# This class is here only to make sure wsmeext.tg1.scan_api
|
||||
# does its job properly
|
||||
pass
|
||||
|
||||
@ -28,10 +28,10 @@ class Root(RootController):
|
||||
typenamespace=test_soap.typenamespace,
|
||||
baseURL='/ws/'
|
||||
)
|
||||
ws = wsme.tg15.adapt(ws)
|
||||
ws = wsmeext.tg15.adapt(ws)
|
||||
|
||||
@wsme.tg15.wsexpose(int)
|
||||
@wsme.tg15.wsvalidate(int, int)
|
||||
@wsmeext.tg15.wsexpose(int)
|
||||
@wsmeext.tg15.wsvalidate(int, int)
|
||||
def multiply(self, a, b):
|
||||
return a * b
|
||||
|
||||
@ -51,7 +51,7 @@ class TestController(testutil.TGTest):
|
||||
# def tearDown(self):
|
||||
# # implementation copied from turbogears.testutil.stop_server.
|
||||
# # The only change is that cherrypy.root is set to None
|
||||
# # AFTER stopTurbogears has been called so that wsme.tg15
|
||||
# # AFTER stopTurbogears has been called so that wsmeext.tg15
|
||||
# # can correctly uninstall its filter.
|
||||
# if config.get("cp_started"):
|
||||
# cherrypy.server.stop()
|
||||
@ -112,7 +112,7 @@ class TestController(testutil.TGTest):
|
||||
|
||||
root = MyRoot()
|
||||
|
||||
api = list(wsme.tg1._scan_api(root))
|
||||
api = list(wsmeext.tg1._scan_api(root))
|
||||
print(api)
|
||||
|
||||
self.assertEquals(len(api), 0)
|
||||
@ -131,14 +131,14 @@ class TestController(testutil.TGTest):
|
||||
c.sub = subc()
|
||||
c = subc
|
||||
root = ARoot()
|
||||
self.assertRaises(ValueError, list, wsme.tg1._scan_api(root))
|
||||
self.assertRaises(ValueError, list, wsmeext.tg1._scan_api(root))
|
||||
|
||||
def test_templates_content_type(self):
|
||||
self.assertEquals(
|
||||
"application/json",
|
||||
wsme.tg1.AutoJSONTemplate().get_content_type('dummy')
|
||||
wsmeext.tg1.AutoJSONTemplate().get_content_type('dummy')
|
||||
)
|
||||
self.assertEquals(
|
||||
"text/xml",
|
||||
wsme.tg1.AutoXMLTemplate().get_content_type('dummy')
|
||||
wsmeext.tg1.AutoXMLTemplate().get_content_type('dummy')
|
||||
)
|
||||
|
30
tox.ini
30
tox.ini
@ -26,8 +26,8 @@ setenv=
|
||||
#commands=nosetests --verbose []
|
||||
commands=
|
||||
{envbindir}/coverage run {envbindir}/nosetests --with-xunit --xunit-file nosetests-{envname}.xml -w ./wsme/tests --verbose {posargs}
|
||||
{envbindir}/coverage xml -o coverage-{envname}.xml wsme/*.py wsme/rest/*.py
|
||||
{envbindir}/coverage report --show-missing wsme/*.py wsme/rest/*.py
|
||||
{envbindir}/coverage xml -o coverage-{envname}.xml wsme/*.py wsme/rest/*.py wsmeext/*.py
|
||||
{envbindir}/coverage report --show-missing wsme/*.py wsme/rest/*.py wsmeext/*.py
|
||||
|
||||
downloadcache=.tox/cache
|
||||
|
||||
@ -45,8 +45,8 @@ deps=
|
||||
[testenv:py32]
|
||||
commands=
|
||||
{envbindir}/coverage run {envbindir}/nosetests --with-xunit --xunit-file nosetests-{envname}.xml -w ./wsme/tests --verbose {posargs}
|
||||
{envbindir}/coverage xml -o coverage-{envname}.xml --omit wsme/sphinxext.py wsme/*.py wsme/rest/*.py
|
||||
{envbindir}/coverage report --show-missing --omit wsme/sphinxext.py wsme/*.py wsme/rest/*.py
|
||||
{envbindir}/coverage xml -o coverage-{envname}.xml --omit wsmeext/sphinxext.py wsme/*.py wsme/rest/*.py wsmeext/*.py
|
||||
{envbindir}/coverage report --show-missing --omit wsmeext/sphinxext.py wsme/*.py wsme/rest/*.py wsmeext/*.py
|
||||
|
||||
[testenv:sphinxext]
|
||||
basepython=python2.5
|
||||
@ -58,8 +58,8 @@ deps=
|
||||
Sphinx
|
||||
commands=
|
||||
{envbindir}/coverage run {envbindir}/nosetests --with-xunit --xunit-file nosetests-{envname}.xml tests/test_sphinxext.py --verbose {posargs}
|
||||
{envbindir}/coverage xml -o coverage-{envname}.xml wsme/*.py wsme/rest/*.py
|
||||
{envbindir}/coverage report --show-missing wsme/*.py wsme/rest/*.py
|
||||
{envbindir}/coverage xml -o coverage-{envname}.xml wsme/*.py wsme/rest/*.py wsmeext/*.py
|
||||
{envbindir}/coverage report --show-missing wsme/*.py wsme/rest/*.py wsmeext/*.py
|
||||
|
||||
[testenv:tg11]
|
||||
basepython=python2.5
|
||||
@ -75,8 +75,8 @@ commands=
|
||||
{envbindir}/easy_install https://bitbucket.org/cdevienne/wsme-soap/get/tip.zip
|
||||
{envbindir}/easy_install -i http://www.turbogears.org/1.1/downloads/current/index/ 'TurboGears<1.1.99'
|
||||
{envbindir}/coverage run {envbindir}/nosetests --with-xunit --xunit-file nosetests-{envname}.xml tests/test_tg1.py --verbose {posargs}
|
||||
{envbindir}/coverage xml -o coverage-{envname}.xml wsme/*.py wsme/rest/*.py
|
||||
{envbindir}/coverage report --show-missing wsme/*.py wsme/rest/*.py
|
||||
{envbindir}/coverage xml -o coverage-{envname}.xml wsme/*.py wsme/rest/*.py wsmeext/*.py
|
||||
{envbindir}/coverage report --show-missing wsme/*.py wsme/rest/*.py wsmeext/*.py
|
||||
|
||||
[testenv:tg15]
|
||||
basepython=python2.5
|
||||
@ -92,8 +92,8 @@ commands=
|
||||
{envbindir}/easy_install https://bitbucket.org/cdevienne/wsme-soap/get/tip.zip
|
||||
{envbindir}/easy_install -i http://www.turbogears.org/1.5/downloads/current/index/ 'TurboGears<1.5.99'
|
||||
{envbindir}/coverage run {envbindir}/nosetests --with-xunit --xunit-file nosetests-{envname}.xml tests/test_tg15.py --verbose {posargs}
|
||||
{envbindir}/coverage xml -o coverage-{envname}.xml wsme/*.py wsme/rest/*.py
|
||||
{envbindir}/coverage report --show-missing wsme/*.py wsme/rest/*.py
|
||||
{envbindir}/coverage xml -o coverage-{envname}.xml wsme/*.py wsme/rest/*.py wsmeext/*.py
|
||||
{envbindir}/coverage report --show-missing wsme/*.py wsme/rest/*.py wsmeext/*.py
|
||||
|
||||
[testenv:tg21]
|
||||
basepython=python2.5
|
||||
@ -106,8 +106,8 @@ commands=
|
||||
{envbindir}/easy_install https://bitbucket.org/cdevienne/wsme-soap/get/tip.zip
|
||||
{envbindir}/easy_install -i http://www.turbogears.org/2.1/downloads/current/index/ 'TurboGears2<2.1.99' webtest
|
||||
{envbindir}/coverage run {envbindir}/nosetests --with-xunit --xunit-file nosetests-{envname}.xml tests/test_tg20.py --verbose {posargs}
|
||||
{envbindir}/coverage xml -o coverage-{envname}.xml wsme/*.py wsme/rest/*.py
|
||||
{envbindir}/coverage report --show-missing wsme/*.py wsme/rest/*.py
|
||||
{envbindir}/coverage xml -o coverage-{envname}.xml wsme/*.py wsme/rest/*.py wsmeext/*.py
|
||||
{envbindir}/coverage report --show-missing wsme/*.py wsme/rest/*.py wsmeext/*.py
|
||||
|
||||
[testenv:pecan]
|
||||
basepython=python2.7
|
||||
@ -125,7 +125,7 @@ setenv=
|
||||
commands=
|
||||
{envbindir}/coverage run --source wsme {envbindir}/nosetests -w tests/pecantest test/tests/test_ws.py --with-xunit --xunit-file nosetests-{envname}.xml --verbose {posargs}
|
||||
{envbindir}/coverage xml -o coverage-{envname}.xml
|
||||
{envbindir}/coverage report --show-missing wsme/*.py wsme/rest/*.py
|
||||
{envbindir}/coverage report --show-missing wsme/*.py wsme/rest/*.py wsmeext/*.py
|
||||
|
||||
[testenv:coverage]
|
||||
basepython=python
|
||||
@ -136,5 +136,5 @@ setenv=
|
||||
commands=
|
||||
{envbindir}/coverage erase
|
||||
{envbindir}/coverage combine
|
||||
{envbindir}/coverage xml wsme/*.py wsme/rest/*.py
|
||||
{envbindir}/coverage report --show-missing wsme/*.py wsme/protocols/*.py
|
||||
{envbindir}/coverage xml wsme/*.py wsme/rest/*.py wsmeext/*.py
|
||||
{envbindir}/coverage report --show-missing wsme/*.py wsme/protocols/*.py wsmeext/*.py
|
||||
|
2
wsmeext/__init__.py
Normal file
2
wsmeext/__init__.py
Normal file
@ -0,0 +1,2 @@
|
||||
import pkg_resources
|
||||
pkg_resources.declare_namespace(__name__)
|
@ -2,8 +2,8 @@ from turbogears import config
|
||||
import cherrypy
|
||||
from cherrypy.filters.basefilter import BaseFilter
|
||||
from turbogears.startup import call_on_startup, call_on_shutdown
|
||||
from wsme.tg1 import wsexpose, wsvalidate
|
||||
import wsme.tg1
|
||||
from wsmeext.tg1 import wsexpose, wsvalidate
|
||||
import wsmeext.tg1
|
||||
|
||||
__all__ = ['adapt', 'wsexpose', 'wsvalidate']
|
||||
|
||||
@ -20,8 +20,8 @@ class WSMECherrypyFilter(BaseFilter):
|
||||
|
||||
|
||||
def adapt(wsroot):
|
||||
wsroot._scan_api = wsme.tg1.scan_api
|
||||
controller = wsme.tg1.Controller(wsroot)
|
||||
wsroot._scan_api = wsmeext.tg1.scan_api
|
||||
controller = wsmeext.tg1.Controller(wsroot)
|
||||
filter_ = WSMECherrypyFilter(controller)
|
||||
|
||||
def install_filter():
|
@ -1,7 +1,7 @@
|
||||
import cherrypy
|
||||
|
||||
from wsme.tg1 import wsexpose, wsvalidate
|
||||
import wsme.tg1
|
||||
from wsmeext.tg1 import wsexpose, wsvalidate
|
||||
import wsmeext.tg1
|
||||
|
||||
|
||||
__all__ = ['adapt', 'wsexpose', 'wsvalidate']
|
||||
@ -10,11 +10,11 @@ __all__ = ['adapt', 'wsexpose', 'wsvalidate']
|
||||
def scan_api(root=None):
|
||||
for baseurl, instance in cherrypy.tree.apps.items():
|
||||
path = [token for token in baseurl.split('/') if token]
|
||||
for i in wsme.tg1._scan_api(instance.root, path):
|
||||
for i in wsmeext.tg1._scan_api(instance.root, path):
|
||||
yield i
|
||||
|
||||
|
||||
def adapt(wsroot):
|
||||
wsroot._scan_api = scan_api
|
||||
controller = wsme.tg1.Controller(wsroot)
|
||||
controller = wsmeext.tg1.Controller(wsroot)
|
||||
return controller
|
Loading…
Reference in New Issue
Block a user