Hello community, here is the log from the commit of package python-WSME for openSUSE:Factory checked in at 2015-01-09 20:50:30 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python-WSME (Old) and /work/SRC/openSUSE:Factory/.python-WSME.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-WSME" Changes: -------- --- /work/SRC/openSUSE:Factory/python-WSME/python-WSME.changes 2014-09-15 18:25:09.000000000 +0200 +++ /work/SRC/openSUSE:Factory/.python-WSME.new/python-WSME.changes 2015-01-09 20:50:35.000000000 +0100 @@ -1,0 +2,19 @@ +Thu Jan 8 13:26:01 UTC 2015 - tbecht...@suse.com + +- Update to version 0.6.4: + * Include tests in the source distribution (so pecan can download and run them + * Disable universal wheels + * Fix passing Dict/Array based UserType as params + * Document next version changes + * Allow non-auto-registered complex type + * Make the flask adapter working with flask.ext.restful + * Avoid Sphinx 1.3x in the tests + * Doc: status= -> status_code= + * Minor documentation edits + * Fix tox configuration + * Add support for manually specifying supported content types in @wsmeexpose + * Fix broken sphinx tests + * fix errors/warnings in tests + * Use APIPATH_MAXLEN from the right module + +------------------------------------------------------------------- Old: ---- WSME-0.6.1.tar.gz New: ---- WSME-0.6.4.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-WSME.spec ++++++ --- /var/tmp/diff_new_pack.iQPbt2/_old 2015-01-09 20:50:35.000000000 +0100 +++ /var/tmp/diff_new_pack.iQPbt2/_new 2015-01-09 20:50:35.000000000 +0100 @@ -1,7 +1,7 @@ # # spec file for package python-WSME # -# Copyright (c) 2014 SUSE LINUX Products GmbH, Nuernberg, Germany. +# Copyright (c) 2015 SUSE LINUX Products GmbH, Nuernberg, Germany. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -17,7 +17,7 @@ Name: python-WSME -Version: 0.6.1 +Version: 0.6.4 Release: 0 Summary: Web Services Made Easy License: MIT ++++++ WSME-0.6.1.tar.gz -> WSME-0.6.4.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/WSME-0.6.1/AUTHORS new/WSME-0.6.4/AUTHORS --- old/WSME-0.6.1/AUTHORS 2014-05-02 15:27:16.000000000 +0200 +++ new/WSME-0.6.4/AUTHORS 2014-11-20 21:22:20.000000000 +0100 @@ -1 +1,24 @@ - +119Vik <vitalij...@ukr.net> +Angus Salkeld <asalk...@redhat.com> +Chad Lung <chad.l...@gmail.com> +Chang Bo Guo <guoc...@cn.ibm.com> +Christophe de Vienne <cdevie...@alphacent.com> +Christophe de Vienne <cdevie...@gmail.com> +Craig McDaniel <craig...@gmail.com> +Doug Hellmann <doug.hellm...@dreamhost.com> +Doug Hellmann <doug.hellm...@gmail.com> +Doug Hellmann <d...@doughellmann.com> +Dustin J. Mitchell <dus...@mozilla.com> +Endre Karlson <endre.karl...@gmail.com> +Ilya Kharin <aksc...@gmail.com> +James Page <james.p...@ubuntu.com> +Julien Danjou <jul...@danjou.info> +Ken'ichi Ohmichi <oomi...@mxs.nes.nec.co.jp> +Lucas Alvares Gomes <lucasago...@gmail.com> +Mehdi Abaakouk <mehdi.abaak...@enovance.com> +Ryan Petrello <li...@ryanpetrello.com> +Sascha Peilicke <speili...@suse.com> +Yuriy Zveryanskyy <yzveryans...@mirantis.com> +arati.mahimane <arati.mahim...@rackspace.com> +aviau <alexandre.v...@savoirfairelinux.com> +gordon chung <g...@live.ca> diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/WSME-0.6.1/ChangeLog new/WSME-0.6.4/ChangeLog --- old/WSME-0.6.1/ChangeLog 2014-05-02 15:27:16.000000000 +0200 +++ new/WSME-0.6.4/ChangeLog 2014-11-20 21:22:20.000000000 +0100 @@ -1,6 +1,32 @@ CHANGES ======= +0.6.4 +----- + +* Include tests in the source distribution (so pecan can download and run them + +0.6.3 +----- + +* Disable universal wheels + +0.6.2 +----- + +* Fix passing Dict/Array based UserType as params +* Document next version changes +* Allow non-auto-registered complex type +* Make the flask adapter working with flask.ext.restful +* Avoid Sphinx 1.3x in the tests +* Doc: status= -> status_code= +* Minor documentation edits +* Fix tox configuration +* Add support for manually specifying supported content types in @wsmeexpose +* Fix broken sphinx tests +* fix errors/warnings in tests +* Use APIPATH_MAXLEN from the right module + 0.6.1 ----- diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/WSME-0.6.1/PKG-INFO new/WSME-0.6.4/PKG-INFO --- old/WSME-0.6.1/PKG-INFO 2014-05-02 15:27:16.000000000 +0200 +++ new/WSME-0.6.4/PKG-INFO 2014-11-20 21:22:20.000000000 +0100 @@ -1,6 +1,6 @@ Metadata-Version: 1.1 Name: WSME -Version: 0.6.1 +Version: 0.6.4 Summary: Simplify the writing of REST APIs, and extend them with additional protocols. Home-page: UNKNOWN Author: "Christophe de Vienne" @@ -12,19 +12,19 @@ Introduction ------------ - Web Service Made Easy (WSME) simplify the writing of REST web services - by providing simple yet powerful typing which removes the need to directly + Web Services Made Easy (WSME) simplifies the writing of REST web services + by providing simple yet powerful typing, removing the need to directly manipulate the request and the response objects. - WSME can work standalone or on top of your favorite python web + WSME can work standalone or on top of your favorite Python web (micro)framework, so you can use both your preferred way of routing your REST requests and most of the features of WSME that rely on the typing system like: - - Alternate protocols, including ones supporting batch-calls + - Alternate protocols, including those supporting batch-calls - Easy documentation through a Sphinx_ extension WSME is originally a rewrite of TGWebServices - with focus on extensibility, framework-independance and better type handling. + with a focus on extensibility, framework-independance and better type handling. How Easy ? ~~~~~~~~~~ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/WSME-0.6.1/README.rst new/WSME-0.6.4/README.rst --- old/WSME-0.6.1/README.rst 2014-05-02 15:27:07.000000000 +0200 +++ new/WSME-0.6.4/README.rst 2014-11-20 21:22:14.000000000 +0100 @@ -4,19 +4,19 @@ Introduction ------------ -Web Service Made Easy (WSME) simplify the writing of REST web services -by providing simple yet powerful typing which removes the need to directly +Web Services Made Easy (WSME) simplifies the writing of REST web services +by providing simple yet powerful typing, removing the need to directly manipulate the request and the response objects. -WSME can work standalone or on top of your favorite python web +WSME can work standalone or on top of your favorite Python web (micro)framework, so you can use both your preferred way of routing your REST requests and most of the features of WSME that rely on the typing system like: -- Alternate protocols, including ones supporting batch-calls +- Alternate protocols, including those supporting batch-calls - Easy documentation through a Sphinx_ extension WSME is originally a rewrite of TGWebServices -with focus on extensibility, framework-independance and better type handling. +with a focus on extensibility, framework-independance and better type handling. How Easy ? ~~~~~~~~~~ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/WSME-0.6.1/WSME.egg-info/PKG-INFO new/WSME-0.6.4/WSME.egg-info/PKG-INFO --- old/WSME-0.6.1/WSME.egg-info/PKG-INFO 2014-05-02 15:27:16.000000000 +0200 +++ new/WSME-0.6.4/WSME.egg-info/PKG-INFO 2014-11-20 21:22:20.000000000 +0100 @@ -1,6 +1,6 @@ Metadata-Version: 1.1 Name: WSME -Version: 0.6.1 +Version: 0.6.4 Summary: Simplify the writing of REST APIs, and extend them with additional protocols. Home-page: UNKNOWN Author: "Christophe de Vienne" @@ -12,19 +12,19 @@ Introduction ------------ - Web Service Made Easy (WSME) simplify the writing of REST web services - by providing simple yet powerful typing which removes the need to directly + Web Services Made Easy (WSME) simplifies the writing of REST web services + by providing simple yet powerful typing, removing the need to directly manipulate the request and the response objects. - WSME can work standalone or on top of your favorite python web + WSME can work standalone or on top of your favorite Python web (micro)framework, so you can use both your preferred way of routing your REST requests and most of the features of WSME that rely on the typing system like: - - Alternate protocols, including ones supporting batch-calls + - Alternate protocols, including those supporting batch-calls - Easy documentation through a Sphinx_ extension WSME is originally a rewrite of TGWebServices - with focus on extensibility, framework-independance and better type handling. + with a focus on extensibility, framework-independance and better type handling. How Easy ? ~~~~~~~~~~ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/WSME-0.6.1/WSME.egg-info/SOURCES.txt new/WSME-0.6.4/WSME.egg-info/SOURCES.txt --- old/WSME-0.6.1/WSME.egg-info/SOURCES.txt 2014-05-02 15:27:16.000000000 +0200 +++ new/WSME-0.6.4/WSME.egg-info/SOURCES.txt 2014-11-20 21:22:20.000000000 +0100 @@ -5,6 +5,7 @@ README.rst setup.cfg setup.py +tests tox-tmpl.ini tox.ini toxgen.py diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/WSME-0.6.1/WSME.egg-info/entry_points.txt new/WSME-0.6.4/WSME.egg-info/entry_points.txt --- old/WSME-0.6.1/WSME.egg-info/entry_points.txt 2014-05-02 15:27:16.000000000 +0200 +++ new/WSME-0.6.4/WSME.egg-info/entry_points.txt 2014-11-20 21:22:20.000000000 +0100 @@ -1,7 +1,7 @@ [wsme.protocols] -restjson = wsme.rest.protocol:RestProtocol extdirect = wsmeext.extdirect:ExtDirectProtocol -restxml = wsme.rest.protocol:RestProtocol rest = wsme.rest.protocol:RestProtocol +restjson = wsme.rest.protocol:RestProtocol +restxml = wsme.rest.protocol:RestProtocol soap = wsmeext.soap:SoapProtocol diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/WSME-0.6.1/WSME.egg-info/top_level.txt new/WSME-0.6.4/WSME.egg-info/top_level.txt --- old/WSME-0.6.1/WSME.egg-info/top_level.txt 2014-05-02 15:27:16.000000000 +0200 +++ new/WSME-0.6.4/WSME.egg-info/top_level.txt 2014-11-20 21:22:20.000000000 +0100 @@ -1,2 +1,2 @@ -wsme wsmeext +wsme diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/WSME-0.6.1/doc/changes.rst new/WSME-0.6.4/doc/changes.rst --- old/WSME-0.6.1/doc/changes.rst 2014-05-02 15:27:08.000000000 +0200 +++ new/WSME-0.6.4/doc/changes.rst 2014-11-20 21:22:14.000000000 +0100 @@ -1,8 +1,17 @@ Changes ======= -0.6.1 ------ +0.6.2 (next) +------------ + +* Flask adapter complex types now supports flask.ext.restful +* Allow disabling complex types auto-register +* Documentation edits +* Various documentation build fixes +* Fix passing Dict and Array based UserType as params + +0.6.1 (2014-05-02) +------------------ * Fix error: variable 'kw' referenced before assignment * Fix default handling for zero values @@ -11,8 +20,8 @@ * pecan: cleanup, use global vars and staticmethod * args_from_args() to work with an instance of UserType -0.6 ---- +0.6 (2014-02-06) +---------------- * Add 'readonly' parameter to wsattr * Fix typos in documents and comments diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/WSME-0.6.1/doc/document.rst new/WSME-0.6.4/doc/document.rst --- old/WSME-0.6.1/doc/document.rst 2014-05-02 15:27:07.000000000 +0200 +++ new/WSME-0.6.4/doc/document.rst 2014-11-20 21:22:14.000000000 +0100 @@ -10,7 +10,7 @@ Here we consider that you already quick-started a sphinx project. -#. In your ``conf.py`` file, add ``'ext'`` to you extensions, +#. In your ``conf.py`` file, add ``'ext'`` to your extensions, and optionally set the enabled protocols. .. code-block:: python @@ -34,7 +34,7 @@ .. confval:: wsme_protocols A list of strings that are WSME protocol names. If provided by an - additionnal package (for example WSME-Soap or WSME-ExtDirect), it must + additional package (for example WSME-Soap or WSME-ExtDirect), that package must be installed. The types and services generated documentation will include code samples @@ -57,10 +57,10 @@ .. rst:directive:: .. root:: <WSRoot full path> - Allow to define the service root controller in one documentation source file. + Define the service root controller for this documentation source file. To set it globally, see :confval:`wsme_root`. - A ``webpath`` option allow to override :confval:`wsme_webpath`. + A ``webpath`` option allows override of :confval:`wsme_webpath`. Example: @@ -80,7 +80,7 @@ .. rst:directive:: .. attribute:: aname Equivalent to the :rst:dir:`py:attribute` directive to document a complex type - attribute. It takes an additionnal ``:type:`` field. + attribute. It takes an additional ``:type:`` field. Example ~~~~~~~ @@ -151,7 +151,7 @@ ~~~~~~~~~~~~~ .. literalinclude:: ../wsmeext/sphinxext.py - :lines: 42-67 + :lines: 69-96 :language: python Documentation source @@ -161,6 +161,10 @@ .. default-domain:: wsmeext + .. type:: int + + An integer + .. autotype:: wsmeext.sphinxext.SampleType :members: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/WSME-0.6.1/doc/functions.rst new/WSME-0.6.4/doc/functions.rst --- old/WSME-0.6.1/doc/functions.rst 2014-05-02 15:27:07.000000000 +0200 +++ new/WSME-0.6.4/doc/functions.rst 2014-11-20 21:22:14.000000000 +0100 @@ -2,18 +2,17 @@ ========= WSME is based on the idea that most of the time the input and output of web -services are actually stricly typed. It uses this fact to ease the +services are actually strictly typed. It uses this idea to ease the implementation of the actual functions by handling those input/output. -It also uses these informations to propose alternate protocols on top of a -proper REST api. +It also proposes alternate protocols on top of a proper REST api. -This chapter explains in details how to 'sign' a function with WSME. +This chapter explains in detail how to 'sign' a function with WSME. The decorators -------------- Depending on the framework you are using, you will have to use either a -@signature decorator, either a @wsexpose decorator. +@\ :class:`wsme.signature` decorator or a @\ :class:`wsme.wsexpose` decorator. @signature ~~~~~~~~~~ @@ -24,23 +23,23 @@ The Flask and Cornice adapters both propose a specific version of it, which also wrap the function so that it becomes suitable for the host framework. -In any case, the use of @signature has the same meaning: tell WSME what is the +In any case, the use of @\ :class:`wsme.signature` has the same meaning: tell WSME what is the signature of the function. @wsexpose ~~~~~~~~~ -The native Rest implementation, and the TG and Pecan adapters add a @wsexpose +The native Rest implementation, and the TG and Pecan adapters add a @\ :class:`wsme.wsexpose` decorator. -It does what @signature does, *and* expose the function in the routing system +It does what @\ :class:`wsme.signature` does, *and* exposes the function in the routing system of the host framework. -This decorator is generally used in object-dispatch routing context. +This decorator is generally used in an object-dispatch routing context. .. note:: - Since both decorators plays the same role function-wise, the rest of this + Since both decorators play the same role, the rest of this document will alway use @signature. Signing a function @@ -57,7 +56,7 @@ In this trivial example, we tell WSME that the 'multiply' function returns an integer, and takes two integer parameters. -WSME will match the argument types by order, and know the exact type of each +WSME will match the argument types by order to determine the exact type of each named argument. This is important since most of the web service protocols don't provide strict argument ordering but only named parameters. @@ -75,13 +74,13 @@ In this example, the caller may omit the 'delta' argument, and no 'MissingArgument' error will be raised. -Additionally this argument will be documented as optional by the sphinx +Additionally, this argument will be documented as optional by the sphinx extension. Body argument ~~~~~~~~~~~~~ -When defining a Rest CRUD api, we generally have a URL on which we POST datas. +When defining a Rest CRUD API, we generally have a URL to which we POST data. For example: @@ -92,9 +91,9 @@ # ... return data -Such a function will take at least one parameter 'data' that is a structured +Such a function will take at least one parameter, 'data', that is a structured type. With the default way of handling parameters, the body of the request -would be like this: +would look like this: .. code-block:: javascript @@ -106,7 +105,7 @@ } } -If you think (and you should) that it has one extra nest level, the 'body' +If you think (and you should) that it has one extra level of nesting, the 'body' argument is here for you:: @signature(Author, body=Author) @@ -123,7 +122,7 @@ "name": "Pierre-Joseph" } -Note that it does not prevent from having multiple parameters, it just requires +Note that this does not prevent the function from having multiple parameters; it just requires the body argument to be the last: .. code-block:: python @@ -139,28 +138,28 @@ Status code ~~~~~~~~~~~ -The default status code returned by WSME are 200, 400 (if the client send wrong +The default status codes returned by WSME are 200, 400 (if the client sends invalid inputs) and 500 (for server-side errors). Since a proper Rest API should use different return codes (201, etc), one can -use the 'status=' option of @signature to do so. +use the 'status_code=' option of @signature to do so. .. code-block:: python - @signature(Author, body=Author, status=201) + @signature(Author, body=Author, status_code=201) def create_author(data): # ... return data -Of course this code will only be used if no error occur. +Of course this code will only be used if no error occurs. -In case the function needs to change the status code on a per-request base, it -can return a :class:`wsme.Response` object, that allow to override the status +In case the function needs to change the status code on a per-request basis, it +can return a :class:`wsme.Response` object, allowing it to override the status code: .. code-block:: python - @signature(Author, body=Author, status=202) + @signature(Author, body=Author, status_code=202) def update_author(data): # ... response = Response(data) @@ -171,15 +170,15 @@ Extra arguments ~~~~~~~~~~~~~~~ -The default behavior of WSME is to reject requests that gives extra/unknown -arguments. In some (rare) cases, it can be unwanted. +The default behavior of WSME is to reject requests that give extra/unknown +arguments. In some (rare) cases, this is undesirable. Adding 'ignore_extra_args=True' to @signature changes this behavior. .. note:: - If using this option seems to solution to your problem, please think twice - before using it ! + If using this option seems to solve your problem, please think twice + before using it! Accessing the request ~~~~~~~~~~~~~~~~~~~~~ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/WSME-0.6.1/doc/integrate.rst new/WSME-0.6.4/doc/integrate.rst --- old/WSME-0.6.1/doc/integrate.rst 2014-05-02 15:27:07.000000000 +0200 +++ new/WSME-0.6.4/doc/integrate.rst 2014-11-20 21:22:14.000000000 +0100 @@ -6,7 +6,7 @@ Using WSME within another framework providing its own REST capabilities is generally done by using a specific decorator to declare the function signature, -in addition to the framework own way of declaring exposed functions. +in addition to the framework's own way of declaring exposed functions. This decorator can have two different names depending on the adapter. @@ -19,18 +19,18 @@ :ref:`adapter-tg1`. ``@signature`` - This decorator only set the function signature and returns a function + This decorator only sets the function signature and returns a function that can be used by the host framework as a REST request target. - Generally this decorator is provided for frameworks that expects functions + Generally this decorator is provided for frameworks that expect functions taking a request object as a single parameter and returning a response - object. This is the case of :ref:`adapter-cornice` and + object. This is the case for :ref:`adapter-cornice` and :ref:`adapter-flask`. -Additionnaly, if you want to enable additionnal protocols, you will need to +If you want to enable additional protocols, you will need to mount a :class:`WSRoot` instance somewhere in the application, generally ``/ws``. This subpath will then handle the additional protocols. In a future -version, a wsgi middleware will probably play this role. +version, a WSGI middleware will probably play this role. .. note:: @@ -39,13 +39,13 @@ WSGI Application ---------------- -The :func:`wsme.WSRoot.wsgiapp` function of WSRoot returns a wsgi +The :func:`wsme.WSRoot.wsgiapp` function of WSRoot returns a WSGI application. Example ~~~~~~~ -The following example assume the REST protocol will be entirely handled by +The following example assumes the REST protocol will be entirely handled by WSME, which is the case if you write a WSME standalone application. .. code-block:: python @@ -164,9 +164,9 @@ .. warning:: - A pecan application is not able to mount another wsgi application on a + A pecan application is not able to mount another WSGI application on a subpath. For that reason, additional protocols are not supported for now, - ie until wsme provides a middleware that can do the same as a mounted + until WSME provides a middleware that can do the same as a mounted WSRoot. :mod:`wsmeext.pecan` -- Pecan adapter diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/WSME-0.6.1/doc/protocols.rst new/WSME-0.6.4/doc/protocols.rst --- old/WSME-0.6.1/doc/protocols.rst 2014-05-02 15:27:07.000000000 +0200 +++ new/WSME-0.6.4/doc/protocols.rst 2014-11-20 21:22:14.000000000 +0100 @@ -10,8 +10,8 @@ .. note:: - This chapter applies also for the different adapters, not only the native - REST implementation. + This chapter applies for all adapters, not just the native REST + implementation. The two REST protocols share common characterics. @@ -19,8 +19,7 @@ root webpath, followed by the controllers names if any, and finally the function name. -For example, the functions exposed functions will be mapped to the -following paths : +The example's exposed functions will be mapped to the following paths: - ``/ws/persons/create`` - ``/ws/persons/get`` @@ -31,10 +30,10 @@ In addition to this trivial function mapping, a `method` option can be given to the `expose` decorator. In such a case, the function name can be omitted by the caller, and the dispatch will look at the -http method used in the request to select the correct function. +HTTP method used in the request to select the correct function. -The function parameters can be transmitted in two ways (is using -the http method to select the function, one way or the other +The function parameters can be transmitted in two ways (if using +the HTTP method to select the function, one way or the other may be usable) : #. As a GET query string or POST form parameters. @@ -49,7 +48,7 @@ #. In a Json or XML encoded POST body (see below) -The result will be return Json or XML encoded (see below). +The result will be returned Json or XML encoded (see below). In case of error, a 400 or 500 status code is returned, and the response body contains details about the error (see below). @@ -63,8 +62,8 @@ This protocol is selected if: -- The request content-type is either text/javascript or application/json -- The request 'Accept' header contains 'text/javascript' or 'application.json' +- The request content-type is either 'text/javascript' or 'application/json' +- The request 'Accept' header contains 'text/javascript' or 'application/json' - A trailing '.json' is added to the path - A 'wsmeproto=restjson' is added in the query string @@ -108,11 +107,11 @@ Return ~~~~~~ -The json encoded result when the response code is 200, OR a json object +The Json encoded result when the response code is 200, or a Json object with error properties ('faulcode', 'faultstring' and 'debuginfo' if -available). +available) on error. -For example, the /ws/person/get result looks like: +For example, the '/ws/person/get' result looks like: .. code-block:: javascript @@ -143,7 +142,7 @@ This protocol is selected if -- The request content-type is text/xml +- The request content-type is 'text/xml' - The request 'Accept' header contains 'text/xml' - A trailing '.xml' is added to the path - A 'wsmeproto=restxml' is added in the query string @@ -245,7 +244,7 @@ A wsdl definition of the webservice is available at the 'api.wsdl' subpath. (``/ws/api.wsdl`` in our example). -The protocol is selected if the request match one of the following condition: +The protocol is selected if the request matches one of the following condition: - The Content-Type is 'application/soap+xml' - A header 'Soapaction' is present diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/WSME-0.6.1/doc/types.rst new/WSME-0.6.4/doc/types.rst --- old/WSME-0.6.1/doc/types.rst 2014-05-02 15:27:07.000000000 +0200 +++ new/WSME-0.6.4/doc/types.rst 2014-11-20 21:22:14.000000000 +0100 @@ -1,13 +1,13 @@ Types ===== -3 kinds of data types can be used as input or output by WSME. +Three kinds of data types can be used as input or output by WSME. Native types ------------ -The native types are a fixed set of standard python types that -the different protocols will map to theirs own basic types. +The native types are a fixed set of standard Python types that +different protocols map to their own basic types. The native types are : @@ -59,7 +59,7 @@ def getlist(self): return ['a', 'b', 'c'] - - Dictionaries -- Statically typed mapping are allowed. When exposing + - Dictionaries -- Statically typed mappings are allowed. When exposing a dictionary datatype, you can specify the key and value types, with a restriction on the key value that must be a 'pod' type. Example:: @@ -67,16 +67,16 @@ class SomeType(object): amap = {str: SomeOthertype} -There are other types that are supported out of the box, see -the :ref:`pre-defined-user-types`. +There are other types that are supported out of the box. See the +:ref:`pre-defined-user-types`. User types ---------- -User types allow to define new almost-native types. +User types allow you to define new, almost-native types. -The idea is that you may have python data that should be transported as native -types by the different protocols, but needs conversion to/from this basetypes, +The idea is that you may have Python data that should be transported as base +types by the different protocols, but needs conversion to/from these base types, or needs to validate data integrity. To define a user type, you just have to inherit from @@ -101,7 +101,7 @@ pre-defined list of values. These types are good examples of how to define user types. Have -a look at their source code ! +a look at their source code! Here is a little example that combines :class:`binary <wsme.types.binary>` and :class:`Enum <wsme.types.Enum>`:: @@ -116,7 +116,7 @@ .. data:: wsme.types.binary The :class:`wsme.types.BinaryType` instance to use when you need to - transfert base64 encoded data. + transfer base64 encoded data. .. autoclass:: wsme.types.BinaryType @@ -126,24 +126,24 @@ Complex types ------------- -Complex types are structured types. They are defined as simple python classes +Complex types are structured types. They are defined as simple Python classes and will be mapped to adequate structured types in the various protocols. -A base class for structured types is proposed, :class:`wsme.types.Base`, -but is not mandatory. The only thing it add is a default constructor. +A base class for structured types is provided, :class:`wsme.types.Base`, +but is not mandatory. The only thing it adds is a default constructor. The attributes that are set at the class level will be used by WSME to discover the structure. These attributes can be: - A datatype -- Any native, user or complex type. - - A :class:`wsattr <wsme.wsattr>` -- Allow to add more information about + - A :class:`wsattr <wsme.wsattr>` -- This allows you to add more information about the attribute, for example if it is mandatory. - - A :class:`wsproperty <wsme.wsproperty>` -- Special typed property. Works - like standard properties with additional properties like + - A :class:`wsproperty <wsme.wsproperty>` -- A special typed property. Works + like standard ``property`` with additional properties like :class:`wsattr <wsme.wsattr>`. -Attributes having a leading '_' in there name will be ignored, as well as the -ones that are none of the above list. It means the type can have functions, +Attributes having a leading '_' in their name will be ignored, as well as the +attributes that are not in the above list. This means the type can have methods, they will not get in the way. Example @@ -177,10 +177,10 @@ (and thus inspected) as soon a they are used in expose or validate, even if they are nested in another complex type. - If for some reasons you need to control when type is inspected, you + If for some reason you need to control when type is inspected, you can use :func:`wsme.types.register_type`. - - The datatype attributes will be replaced + - The datatype attributes will be replaced. When using the 'short' way of defining attributes, ie setting a simple data type, they will be replaced by a wsattr instance. @@ -207,7 +207,7 @@ assert Person.name.key == "name" assert Person.name.mandatory is False - - The default value of instances attributes is + - The default value of instance attributes is :data:`Unset <wsme.Unset>`. :: @@ -218,13 +218,13 @@ p = Person() assert p.name is Unset - This allow the protocol to make a clear distinction between null values + This allows the protocol to make a clear distinction between null values that will be transmitted, and unset values that will not be transmitted. - For input values, it allows the code to know if the values were, or not, + For input values, it allows the code to know if the values were, or were not, sent by the caller. - - When 2 complex types refers to each other, their names can be + - When 2 complex types refer to each other, their names can be used as datatypes to avoid adding attributes afterwards: :: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/WSME-0.6.1/setup.cfg new/WSME-0.6.4/setup.cfg --- old/WSME-0.6.1/setup.cfg 2014-05-02 15:27:16.000000000 +0200 +++ new/WSME-0.6.4/setup.cfg 2014-11-20 21:22:20.000000000 +0100 @@ -37,9 +37,10 @@ extra_files = setup.py README.rst + tests [wheel] -universal = 1 +universal = 0 [egg_info] tag_build = diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/WSME-0.6.1/tests/pecantest/test/controllers/ws.py new/WSME-0.6.4/tests/pecantest/test/controllers/ws.py --- old/WSME-0.6.1/tests/pecantest/test/controllers/ws.py 2014-05-02 15:27:07.000000000 +0200 +++ new/WSME-0.6.4/tests/pecantest/test/controllers/ws.py 2014-11-20 21:22:14.000000000 +0100 @@ -71,6 +71,11 @@ class AuthorsController(RestController): + _custom_actions = { + 'json_only': ['GET'], + 'xml_only': ['GET'] + } + books = BooksController() @wsmeext.pecan.wsexpose([Author], [six.text_type], [Criterion]) @@ -129,3 +134,11 @@ @wsmeext.pecan.wsexpose(Book, int, body=Author) def put(self, author_id, author=None): return author + + @wsmeext.pecan.wsexpose([Author], rest_content_types=('json',)) + def json_only(self): + return [Author(id=1, firstname=u"aname", books=[])] + + @wsmeext.pecan.wsexpose([Author], rest_content_types=('xml',)) + def xml_only(self): + return [Author(id=1, firstname=u"aname", books=[])] diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/WSME-0.6.1/tests/pecantest/test/tests/test_ws.py new/WSME-0.6.4/tests/pecantest/test/tests/test_ws.py --- old/WSME-0.6.1/tests/pecantest/test/tests/test_ws.py 2014-05-02 15:27:07.000000000 +0200 +++ new/WSME-0.6.4/tests/pecantest/test/tests/test_ws.py 2014-11-20 21:22:14.000000000 +0100 @@ -194,6 +194,24 @@ assert a['faultcode'] == 'Server' assert a['debuginfo'].startswith('Traceback (most recent call last):') + def test_json_only(self): + res = self.app.get('/authors/json_only.json') + assert res.status_int == 200 + body = json.loads(res.body.decode('utf-8')) + assert len(body) == 1 + assert body[0]['firstname'] == u"aname" + assert body[0]['books'] == [] + assert body[0]['id'] == 1 + res = self.app.get('/authors/json_only.xml', expect_errors=True) + + def test_xml_only(self): + res = self.app.get('/authors/xml_only.xml') + assert res.status_int == 200 + assert '<id>1</id>' in res.body.decode('utf-8') + assert '<firstname>aname</firstname>' in res.body.decode('utf-8') + assert '<books />' in res.body.decode('utf-8') + res = self.app.get('/authors/xml_only.json', expect_errors=True) + def test_body_parameter(self): res = self.app.put( '/authors/1/books/2.json', diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/WSME-0.6.1/tests/sphinxexample/conf.py new/WSME-0.6.4/tests/sphinxexample/conf.py --- old/WSME-0.6.1/tests/sphinxexample/conf.py 2014-05-02 15:27:07.000000000 +0200 +++ new/WSME-0.6.4/tests/sphinxexample/conf.py 2014-11-20 21:22:14.000000000 +0100 @@ -129,7 +129,7 @@ # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, # so a file named "default.css" will overwrite the builtin "default.css". -html_static_path = ['_static'] +#html_static_path = ['_static'] # If not '', a 'Last updated on:' timestamp is inserted at every page bottom, # using the given strftime format. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/WSME-0.6.1/tests/sphinxexample/document.rst new/WSME-0.6.4/tests/sphinxexample/document.rst --- old/WSME-0.6.1/tests/sphinxexample/document.rst 2014-05-02 15:27:07.000000000 +0200 +++ new/WSME-0.6.4/tests/sphinxexample/document.rst 2014-11-20 21:22:14.000000000 +0100 @@ -4,7 +4,7 @@ Example ~~~~~~~ -.. wsme:root:: wsme.sphinxext.SampleService +.. wsme:root:: wsmeext.sphinxext.SampleService :webpath: /api .. wsme:type:: MyType @@ -26,10 +26,10 @@ An integer -.. autotype:: wsme.sphinxext.SampleType +.. autotype:: wsmeext.sphinxext.SampleType :members: -.. autoservice:: wsme.sphinxext.SampleService +.. autoservice:: wsmeext.sphinxext.SampleService :members: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/WSME-0.6.1/tests/test_flask.py new/WSME-0.6.4/tests/test_flask.py --- old/WSME-0.6.1/tests/test_flask.py 2014-05-02 15:27:07.000000000 +0200 +++ new/WSME-0.6.4/tests/test_flask.py 2014-11-20 21:22:14.000000000 +0100 @@ -1,5 +1,8 @@ +# encoding=utf8 import unittest from flask import Flask, json, abort +from flask.ext import restful + from wsmeext.flask import signature from wsme.api import Response from wsme.types import Base, text @@ -16,6 +19,7 @@ value = text test_app = Flask(__name__) +api = restful.Api(test_app) @test_app.route('/multiply') @@ -78,6 +82,18 @@ return Response(1, status_code=201) +class RestFullApi(restful.Resource): + @signature(Model) + def get(self): + return Model(id=1, name=u"Gérard") + + @signature(int, body=Model) + def post(self, model): + return model.id + +api.add_resource(RestFullApi, '/restful') + + class FlaskrTestCase(unittest.TestCase): def setUp(self): @@ -162,11 +178,35 @@ def test_serversideerror(self): r = self.app.get('/divide_by_zero') assert r.status_code == 500 + data = json.loads(r.data) self.assertEquals( - r.data, - '{"debuginfo": null, "faultcode": "Server", "faultstring": ' - '"integer division or modulo by zero"}' + data, + {"debuginfo": None, + "faultcode": "Server", + "faultstring": "integer division or modulo by zero"} ) + def test_restful_get(self): + r = self.app.get('/restful', headers={'Accept': 'application/json'}) + self.assertEqual(r.status_code, 200) + + data = json.loads(r.data) + + self.assertEqual(data['id'], 1) + self.assertEqual(data['name'], u"Gérard") + + def test_restful_post(self): + r = self.app.post( + '/restful', + data=json.dumps({'id': 5, 'name': u'Huguette'}), + headers={ + 'Accept': 'application/json', + 'Content-Type': 'application/json'}) + self.assertEqual(r.status_code, 200) + + data = json.loads(r.data) + + self.assertEqual(data, 5) + if __name__ == '__main__': test_app.run() diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/WSME-0.6.1/tests/test_sphinxext.py new/WSME-0.6.4/tests/test_sphinxext.py --- old/WSME-0.6.1/tests/test_sphinxext.py 2014-05-02 15:27:07.000000000 +0200 +++ new/WSME-0.6.4/tests/test_sphinxext.py 2014-11-20 21:22:14.000000000 +0100 @@ -20,11 +20,17 @@ def test_buildhtml(self): if not os.path.exists('.test_sphinxext/'): os.makedirs('.test_sphinxext/') - assert sphinx.main(['', - '-b', 'html', - '-d', '.test_sphinxext/doctree', - docpath, - '.test_sphinxext/html']) == 0 + try: + sphinx.main([ + '', + '-b', 'html', + '-d', '.test_sphinxext/doctree', + docpath, + '.test_sphinxext/html' + ]) + assert Exception("Should raise SystemExit 0") + except SystemExit as e: + assert e.code == 0 class TestDataTypeName(unittest.TestCase): diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/WSME-0.6.1/tox-tmpl.ini new/WSME-0.6.4/tox-tmpl.ini --- old/WSME-0.6.1/tox-tmpl.ini 2014-05-02 15:27:07.000000000 +0200 +++ new/WSME-0.6.4/tox-tmpl.ini 2014-11-20 21:22:14.000000000 +0100 @@ -5,14 +5,16 @@ [common] testtools= nose - coverage + coverage < 3.99 pbr webtest basedeps= transaction pecan - Sphinx + cloud_sptheme + Sphinx < 1.2.99 Flask + flask-restful [axes] python=py26,py27,py32,py33,pypy @@ -64,7 +66,7 @@ https://bitbucket.org/bernh/suds-python-3-patches/downloads/suds_patched.zip commands= - {envbindir}/coverage run {envbindir}/nosetests --with-xunit --xunit-file nosetests-{envname}.xml wsme/tests wsmeext/tests tests/pecantest tests/test_sphinxext.py tests/test_flask.py --verbose {posargs} + {envbindir}/coverage run {envbindir}/nosetests --with-xunit --xunit-file nosetests-{envname}.xml wsme/tests wsmeext/tests tests/pecantest tests/test_sphinxext.py --verbose {posargs} {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 @@ -105,7 +107,7 @@ pbr nose webtest < 1.4.99 - coverage + coverage < 3.99 simplejson suds lxml @@ -120,7 +122,7 @@ pbr nose webtest < 1.4.99 - coverage + coverage < 3.99 simplejson suds lxml @@ -134,7 +136,7 @@ deps= pbr nose - coverage + coverage < 3.99 simplejson commands= {envbindir}/easy_install -i http://www.turbogears.org/2.1/downloads/current/index/ 'TurboGears2<2.1.99' webtest @@ -150,7 +152,7 @@ pbr nose webtest - coverage + coverage < 3.99 cornice commands= {envbindir}/nosetests tests/test_cornice.py --with-xunit --xunit-file nosetests-{envname}.xml --verbose --with-coverage --cover-package wsmeext {posargs} @@ -191,7 +193,7 @@ [testenv:coverage] basepython=python deps= - coverage + coverage < 3.99 setenv= COVERAGE_FILE=.coverage commands= @@ -203,7 +205,7 @@ [testenv:doc] deps= cloud_sptheme - Sphinx + Sphinx < 1.2.99 changedir= doc diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/WSME-0.6.1/tox.ini new/WSME-0.6.4/tox.ini --- old/WSME-0.6.1/tox.ini 2014-05-02 15:27:07.000000000 +0200 +++ new/WSME-0.6.4/tox.ini 2014-11-20 21:22:14.000000000 +0100 @@ -4,14 +4,16 @@ [common] testtools = nose - coverage + coverage < 3.99 pbr webtest basedeps = transaction pecan - Sphinx + cloud_sptheme + Sphinx < 1.2.99 Flask + flask-restful [testenv] setenv = @@ -23,7 +25,7 @@ pbr nose webtest < 1.4.99 - coverage + coverage < 3.99 simplejson suds lxml @@ -38,7 +40,7 @@ pbr nose webtest < 1.4.99 - coverage + coverage < 3.99 simplejson suds lxml @@ -52,7 +54,7 @@ deps = pbr nose - coverage + coverage < 3.99 simplejson commands = {envbindir}/easy_install -i http://www.turbogears.org/2.1/downloads/current/index/ 'TurboGears2<2.1.99' webtest @@ -67,7 +69,7 @@ pbr nose webtest - coverage + coverage < 3.99 cornice commands = {envbindir}/nosetests tests/test_cornice.py --with-xunit --xunit-file nosetests-{envname}.xml --verbose --with-coverage --cover-package wsmeext {posargs} @@ -108,7 +110,7 @@ [testenv:coverage] basepython = python deps = - coverage + coverage < 3.99 setenv = COVERAGE_FILE=.coverage commands = @@ -120,7 +122,7 @@ [testenv:doc] deps = cloud_sptheme - Sphinx + Sphinx < 1.2.99 changedir = doc commands = @@ -732,7 +734,7 @@ [testenv:py32-sa6-lxml-json] commands = - {envbindir}/coverage run {envbindir}/nosetests --with-xunit --xunit-file nosetests-{envname}.xml wsme/tests wsmeext/tests tests/pecantest tests/pecantest tests/test_sphinxext.py --verbose {posargs} + {envbindir}/coverage run {envbindir}/nosetests --with-xunit --xunit-file nosetests-{envname}.xml wsme/tests wsmeext/tests tests/pecantest tests/pecantest tests/test_sphinxext.py tests/test_flask.py --verbose {posargs} {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 deps = @@ -745,7 +747,7 @@ [testenv:py32-sa6] commands = - {envbindir}/coverage run {envbindir}/nosetests --with-xunit --xunit-file nosetests-{envname}.xml wsme/tests wsmeext/tests tests/pecantest tests/pecantest tests/test_sphinxext.py --verbose {posargs} + {envbindir}/coverage run {envbindir}/nosetests --with-xunit --xunit-file nosetests-{envname}.xml wsme/tests wsmeext/tests tests/pecantest tests/pecantest tests/test_sphinxext.py tests/test_flask.py --verbose {posargs} {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 deps = @@ -758,7 +760,7 @@ [testenv:py32-sa6-nolxml-json] commands = - {envbindir}/coverage run {envbindir}/nosetests --with-xunit --xunit-file nosetests-{envname}.xml wsme/tests wsmeext/tests tests/pecantest tests/pecantest tests/test_sphinxext.py --verbose {posargs} + {envbindir}/coverage run {envbindir}/nosetests --with-xunit --xunit-file nosetests-{envname}.xml wsme/tests wsmeext/tests tests/pecantest tests/pecantest tests/test_sphinxext.py tests/test_flask.py --verbose {posargs} {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 deps = @@ -770,7 +772,7 @@ [testenv:py32-sa6-nolxml] commands = - {envbindir}/coverage run {envbindir}/nosetests --with-xunit --xunit-file nosetests-{envname}.xml wsme/tests wsmeext/tests tests/pecantest tests/pecantest tests/test_sphinxext.py --verbose {posargs} + {envbindir}/coverage run {envbindir}/nosetests --with-xunit --xunit-file nosetests-{envname}.xml wsme/tests wsmeext/tests tests/pecantest tests/pecantest tests/test_sphinxext.py tests/test_flask.py --verbose {posargs} {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 deps = @@ -782,7 +784,7 @@ [testenv:py32-sa7-lxml-json] commands = - {envbindir}/coverage run {envbindir}/nosetests --with-xunit --xunit-file nosetests-{envname}.xml wsme/tests wsmeext/tests tests/pecantest tests/pecantest tests/test_sphinxext.py --verbose {posargs} + {envbindir}/coverage run {envbindir}/nosetests --with-xunit --xunit-file nosetests-{envname}.xml wsme/tests wsmeext/tests tests/pecantest tests/pecantest tests/test_sphinxext.py tests/test_flask.py --verbose {posargs} {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 deps = @@ -795,7 +797,7 @@ [testenv:py32] commands = - {envbindir}/coverage run {envbindir}/nosetests --with-xunit --xunit-file nosetests-{envname}.xml wsme/tests wsmeext/tests tests/pecantest tests/pecantest tests/test_sphinxext.py --verbose {posargs} + {envbindir}/coverage run {envbindir}/nosetests --with-xunit --xunit-file nosetests-{envname}.xml wsme/tests wsmeext/tests tests/pecantest tests/pecantest tests/test_sphinxext.py tests/test_flask.py --verbose {posargs} {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 deps = @@ -808,7 +810,7 @@ [testenv:py32-sa7-nolxml-json] commands = - {envbindir}/coverage run {envbindir}/nosetests --with-xunit --xunit-file nosetests-{envname}.xml wsme/tests wsmeext/tests tests/pecantest tests/pecantest tests/test_sphinxext.py --verbose {posargs} + {envbindir}/coverage run {envbindir}/nosetests --with-xunit --xunit-file nosetests-{envname}.xml wsme/tests wsmeext/tests tests/pecantest tests/pecantest tests/test_sphinxext.py tests/test_flask.py --verbose {posargs} {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 deps = @@ -820,7 +822,7 @@ [testenv:py32-nolxml] commands = - {envbindir}/coverage run {envbindir}/nosetests --with-xunit --xunit-file nosetests-{envname}.xml wsme/tests wsmeext/tests tests/pecantest tests/pecantest tests/test_sphinxext.py --verbose {posargs} + {envbindir}/coverage run {envbindir}/nosetests --with-xunit --xunit-file nosetests-{envname}.xml wsme/tests wsmeext/tests tests/pecantest tests/pecantest tests/test_sphinxext.py tests/test_flask.py --verbose {posargs} {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 deps = diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/WSME-0.6.1/wsme/api.py new/WSME-0.6.4/wsme/api.py --- old/WSME-0.6.1/wsme/api.py 2014-05-02 15:27:07.000000000 +0200 +++ new/WSME-0.6.4/wsme/api.py 2014-11-20 21:22:14.000000000 +0100 @@ -112,10 +112,11 @@ arg.resolve_type(registry) def set_options(self, body=None, ignore_extra_args=False, status_code=200, - **extra_options): + rest_content_types=('json', 'xml'), **extra_options): self.body_type = body self.status_code = status_code self.ignore_extra_args = ignore_extra_args + self.rest_content_types = rest_content_types self.extra_options = extra_options def set_arg_types(self, argspec, arg_types): diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/WSME-0.6.1/wsme/rest/args.py new/WSME-0.6.4/wsme/rest/args.py --- old/WSME-0.6.1/wsme/rest/args.py 2014-05-02 15:27:07.000000000 +0200 +++ new/WSME-0.6.4/wsme/rest/args.py 2014-11-20 21:22:14.000000000 +0100 @@ -165,6 +165,14 @@ for key in keys)) +@from_params.when_type(UserType) +def usertype_from_params(datatype, params, path, hit_paths): + value = from_params(datatype.basetype, params, path, hit_paths) + if value is not Unset: + return datatype.frombasetype(value) + return Unset + + def args_from_args(funcdef, args, kwargs): newargs = [] for argdef, arg in zip(funcdef.arguments[:len(args)], args): diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/WSME-0.6.1/wsme/tests/test_protocols_commons.py new/WSME-0.6.4/wsme/tests/test_protocols_commons.py --- old/WSME-0.6.1/wsme/tests/test_protocols_commons.py 2014-05-02 15:27:07.000000000 +0200 +++ new/WSME-0.6.4/wsme/tests/test_protocols_commons.py 2014-11-20 21:22:14.000000000 +0100 @@ -14,6 +14,10 @@ basetype = str +class DictBasedUserType(UserType): + basetype = DictType(int, int) + + class TestProtocolsCommons(unittest.TestCase): def test_from_param_date(self): assert from_param(datetime.date, '2008-02-28') == \ @@ -55,6 +59,15 @@ def test_from_params_dict_unset(self): assert from_params(DictType(int, str), {}, 'a', set()) is Unset + def test_from_params_usertype(self): + value = from_params( + DictBasedUserType(), + {'a[2]': '2'}, + 'a', + set() + ) + self.assertEqual(value, {2: 2}) + def test_args_from_args_usertype(self): class FakeType(UserType): diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/WSME-0.6.1/wsme/tests/test_types.py new/WSME-0.6.4/wsme/tests/test_types.py --- old/WSME-0.6.1/wsme/tests/test_types.py 2014-05-02 15:27:07.000000000 +0200 +++ new/WSME-0.6.4/wsme/tests/test_types.py 2014-11-20 21:22:14.000000000 +0100 @@ -629,3 +629,11 @@ TempType.add_attributes(two=int) after = types.list_attributes(TempType) self.assertEqual(len(after), 2) + + def test_non_registered_complex_type(self): + class TempType(types.Base): + __registry__ = None + + self.assertFalse(types.iscomplex(TempType)) + types.registry.register(TempType) + self.assertTrue(types.iscomplex(TempType)) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/WSME-0.6.1/wsme/types.py new/WSME-0.6.4/wsme/types.py --- old/WSME-0.6.1/wsme/types.py 2014-05-02 15:27:07.000000000 +0200 +++ new/WSME-0.6.4/wsme/types.py 2014-11-20 21:22:14.000000000 +0100 @@ -754,7 +754,7 @@ return type.__new__(cls, name, bases, dct) def __init__(cls, name, bases, dct): - if bases and bases[0] is not object: + if bases and bases[0] is not object and cls.__registry__: cls.__registry__.register(cls) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/WSME-0.6.1/wsmeext/flask.py new/WSME-0.6.4/wsmeext/flask.py --- old/WSME-0.6.1/wsmeext/flask.py 2014-05-02 15:27:07.000000000 +0200 +++ new/WSME-0.6.4/wsmeext/flask.py 2014-11-20 21:22:14.000000000 +0100 @@ -3,6 +3,7 @@ import functools import logging import sys +import inspect import wsme import wsme.api @@ -43,12 +44,16 @@ sig = wsme.signature(*args, **kw) def decorator(f): + args = inspect.getargspec(f)[0] + ismethod = args and args[0] == 'self' sig(f) funcdef = wsme.api.FunctionDefinition.get(f) funcdef.resolve_types(wsme.types.registry) @functools.wraps(f) def wrapper(*args, **kwargs): + if ismethod: + self, args = args[0], args[1:] args, kwargs = wsme.rest.args.get_args( funcdef, args, kwargs, flask.request.args, flask.request.form, @@ -62,6 +67,8 @@ dataformat = get_dataformat() try: + if ismethod: + args = [self] + list(args) result = f(*args, **kwargs) # NOTE: Support setting of status_code with default 20 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/WSME-0.6.1/wsmeext/pecan.py new/WSME-0.6.4/wsmeext/pecan.py --- old/WSME-0.6.1/wsmeext/pecan.py 2014-05-02 15:27:07.000000000 +0200 +++ new/WSME-0.6.4/wsmeext/pecan.py 2014-11-20 21:22:14.000000000 +0100 @@ -116,9 +116,11 @@ result=result ) - pecan_xml_decorate(callfunction) - pecan_text_xml_decorate(callfunction) - pecan_json_decorate(callfunction) + if 'xml' in funcdef.rest_content_types: + pecan_xml_decorate(callfunction) + pecan_text_xml_decorate(callfunction) + if 'json' in funcdef.rest_content_types: + pecan_json_decorate(callfunction) pecan.util._cfg(callfunction)['argspec'] = inspect.getargspec(f) callfunction._wsme_definition = funcdef return callfunction diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/WSME-0.6.1/wsmeext/sphinxext.py new/WSME-0.6.4/wsmeext/sphinxext.py --- old/WSME-0.6.1/wsmeext/sphinxext.py 2014-05-02 15:27:07.000000000 +0200 +++ new/WSME-0.6.4/wsmeext/sphinxext.py 2014-11-20 21:22:14.000000000 +0100 @@ -122,7 +122,7 @@ has_functions = True if inspect.isclass(a): continue - if len(path) > wsme.api.APIPATH_MAXLEN: + if len(path) > wsme.rest.APIPATH_MAXLEN: raise ValueError("Path is too long: " + str(path)) for value in scan_services(a, path + [name]): yield value @@ -449,7 +449,9 @@ u'', ]) codesamples.extend(( - u' ' * 12 + line for line in sample.split('\n'))) + u' ' * 12 + line + for line in six.text_type(sample).split('\n') + )) if funcdef.return_type: codesamples.extend([ @@ -467,7 +469,9 @@ u'', ]) codesamples.extend(( - u' ' * 12 + line for line in sample.split('\n'))) + u' ' * 12 + line + for line in six.text_type(sample).split('\n') + )) docstrings[0:0] = [codesamples] return docstrings -- To unsubscribe, e-mail: opensuse-commit+unsubscr...@opensuse.org For additional commands, e-mail: opensuse-commit+h...@opensuse.org