78 Commits

Author SHA1 Message Date
Stephen Finucane
2be89e587c sphinxext: Fix Sphinx 3.0 compatibility
Sphinx is currently issuing the following warnings for projects using
this extension.

  RemovedInSphinx30Warning: sphinx.locale.l_() is deprecated.  Please
  use `_()` instead.

Head this off before it becomes an issue.

Change-Id: I108d36ab909a7afd4fd28bfb565812f69ae02118
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
2019-11-18 22:00:02 +00:00
Stephen Finucane
993d8a06d5 Undo rename of 'wsme.rest.json', 'wsme.rest.xml' modules
Use absolute imports to ensure we import the standard library 'json'
module and not our module that shadows it.

Change-Id: I7b55aad974a0145934069f14c91ce03e41bccef3
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
2019-05-15 12:24:22 +01:00
Stephen Finucane
6f6dbfadef Remove simplejson support
This was allegedly included back when simplejson was more performant
that the 'json' library in Python's library. It's additional complexity
that we simple don't need. Remove it. This also allows us to clean up
the tox file significantly.

Note that we must also rename the 'json' module to 'json_utils', as this
was shadowing a built-in library. This is a latent issue that was
highlighted by removing of 'simplejson' imports.

Change-Id: Id9faa9859993e598e2fd08133de576b740790bf3
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
2019-05-02 10:58:12 -06:00
Stephen Finucane
4ea5f92704 Remove support for SQLAlchemy protocol
Change-Id: I3b6ea08bd4ab626a15a6a16248d609668db7fbab
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
2019-05-02 10:56:49 -06:00
Stephen Finucane
4c5c051fcb Remove support for SOAP protocol
This also allows us to removal lxml as an optional dependency.

Change-Id: I7ce0418012070677e36e41236487f3fabc0763a8
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
2019-05-02 10:54:56 -06:00
Stephen Finucane
3fb55f7f4f Remove support for Ext Direct protocol
I didn't even know this was a thing. Needless to say, we can safely
remove this now.

Change-Id: I92c9c0fe99af61c438ab92a61bd8dd8bb192054b
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
2019-05-02 09:41:00 -06:00
Stephen Finucane
21dadaef0e Remove cornice integration
As with turbogears, no one was using this in OpenStack and therefore we
can and should remove this adaptor.

Change-Id: I0d3942680c1156e57d70f334caea6b89590b46c7
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
2019-05-02 09:41:00 -06:00
Stephen Finucane
a9faca002b Remove turbogears integration
No one in OpenStack that's still using this is using turbogears. Kill
it.

Change-Id: Ifeff1f40834289093dd997ce34fc3b42c3abbc13
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
2019-05-02 09:41:00 -06:00
Vladyslav Drok
f36a607124 Improve handling of :module: in wsme documenters
It appears that in newer sphinx versions the index of :module:
directive in the resulting documenter object array has changed,
it is not the last element anymore. Apart from that, it is
possible to have several :module: entries in class for example.

This change fixes the issue for service, function and type
wsme documenters.

Change-Id: Icf44f8af0c1e6e70d8e921615efe03b845885be7
2018-06-27 10:34:05 +03:00
Chris Dent
1440eeb13b Fix (some) tests for modern flask and pep8
Somewhere along the way, WSME and flask/werkzeug have got out of sync
and tests have started failing. Since there aren't regular contributions
to WSME we don't catch these changes, so this may have happened months
or years ago.

I have adjusted tests to attempt to account for what I can, but one test
fails to work so I have marked it as an xfail. It works correctly with
werkzeug 1.13.x but not later. Since WSME is in something worse than
maintenance mode, I'm not inclined to fix this.

pep8/flake8 in python3 is more strict than python. The gate now
runs the pep8 jobs using python3 by default, so the local jobs
should as well. This changes the job and also fixes the new problems it
points out.

There are other failures, but they are present in master as well, so
leaving that for other changes.

Change-Id: I57ae0405e0d6ddba0bb1dac93020fb08a0fc7c89
2018-04-09 13:24:20 +01:00
Sanu Madhavan
9f84e4c7c5 Remove white space between print ()
There was a white space between print and ()

Change-Id: I6793e52c441728e991fe61afb73227e16368d758
2017-01-20 15:38:05 +05:30
Lucas Alvares Gomes
7e96104e7b Fix: Sphinx extension on Python3
This patch is fixing the WSME Sphinx extension to work with Python 3.
The patch just checks the return value from the find_service_path()
method before it tries to do anything with it.

Change-Id: I5a4cfa42a8768ce35a1c1a999431e842c7dde020
Closes-Bug: #1657435
2017-01-18 12:08:57 +00:00
Vladyslav Drok
ecaf3aa40f Fix pep8 issues and switch to py35 in tox.ini
This change also adds cornice-py3 environment to tox-tmpl.ini,
as previously it was added manually directly in tox.ini.

Change-Id: I6c0924ca4cc7a42b57af01312da21b94ed1efa85
2016-12-23 14:02:33 +02:00
Stéphane Bisinger
32456d3e47 Replace deprecated assertEquals with assertEqual
Unit tests were still using the deprecated assertEquals instead of
assertEqual. This removes all mentions of assertEquals to use the new name and
be compatible with the OpenStack Style Guidelines.

Closes-Bug: #1454766
Partial-Bug: #1446692
Change-Id: Ieb90a334a0d0e91845d20a3e4ea4697307ed3f2a
2015-05-13 18:35:41 +02:00
Stéphane Bisinger
d2f8f8fb1c Ensure UserType objects are converted to basetype
Add some tests to verify that UserType objects are correctly converted
to the specified basetype. Bug #1228040 was based on a wrong usage of
the UserType base class, so these also stand as a further example of
correct usage.

Related-Bug: #1228040
Change-Id: I7d50164930c2ae7abeddcade4f876eef5b273b6b
2015-05-07 17:05:09 +02:00
Stéphane Bisinger
9a0d3c1461 Convert built-in types when passed as strings
If on a service exposed with some arguments with a built-in type among
int, long, bool or float a request is made passing a JSON with string
values instead of the intended type, the called function would have
strings as parameters instead of the expected types. This also means
that invalid strings would still be passed without error, leading to
unexpected failures. This patch tries to convert the string to the
intended type before failing with an InvalidInput exception if the
string can't be converted. This is to try and be as nice as possible
with whatever input is thrown at wsme.

Closes-Bug: 1450544
Change-Id: I705c183bb68457d539074b78ce81339b9464e1e0
2015-05-06 23:04:18 +02:00
Chris Dent
78d6b89d18 Enable real testing of python 3.4
The gate 34 tests were not running any tests because there was no
tox target. This changes tox-tmpl.ini (and the resulting tox.ini) to
add support for python 34 and remove support for anything that is
not py34 or py27-based.

To make the python3 tox environments work, the remote zip of a suds
fork has been replaced with suds-jurko, a relatively modern fork of
the original suds that supports python2 and 3.

Some tests needed to be fixed to deal with two main problems:

* reponse bodies being bytes
* Exceptions not having a .message attribute (.args[0] is used
  instead)
* the test_flask tests were not being run for python3, they are now
* wsmeext/sphinxext.py intermittently fails due to the dictionary
  changing size in flight, getting the keys prior to iteration fixes
  it

Both 27 and 34 should be running 420 tests as of this commit.

Change-Id: I837c249714fd957790ea84aa2fd9ad994a39c5ea
2015-04-28 14:59:33 +01:00
Jenkins
f9ecdd10d3 Merge "Pecan: Make it possible to use the Response to return a non-default return type" 2015-04-20 10:47:30 +00:00
Stéphane Bisinger
c4d39865d4 Converts prints to logging.debug calls
Some print calls were polluting the standard output with debugging
information. These prints are now converted to logging.debug calls
so that they are disabled by default.

Closes-Bug: #1426439
Change-Id: I42f3ca62b55a980839cc0cb481f33fea3cd22afe
2015-04-16 08:56:13 +02:00
Lucas Alvares Gomes
de877d2cc8 Pecan: Make it possible to use the Response to return a non-default return type
This patch is extending the Response object and the Pecan extension
to make it possible to return a non-default return type (just like it
already supports retuning a non default status code).

This is useful when the return code of a function is 204 (No Response) for
that case we automatically set the return_type to be None and guarantee
that the response body is empty and the content-lentgh is 0. Which if
not done can cause tools consuming the API to misbehave.

Change-Id: I629c3e2d5dc169154e5af044f1b8f804e4b87e23
2015-04-01 14:44:46 +01:00
Chris Dent
8710dabb65 Improve Accept and Content-Type handling
Originally, if WSME received an Accept or Content-Type header that
was not aligned with what it was prepared to handle it would error
out with a 500 status code. This is not good behavior for a web
service.

In the process of trying to fix this it was discovered that the
content-negotiation code within WSME (the code that, in part,
looks for a suitable protocol handler for a request) and tests of
that code are incorrect, violating expected HTTP behaviors. GET
requests are passing Content-Type headers to declare the desired
type of representation in the response. This is what Accept is for.

Unfortunately the server-side code was perfectly willing to accept
this behavior. These changes correct that.

Closes-Bug: 1419110
Change-Id: I2b5c0075611490c047b27b1b43b0505fc5534b3b
2015-02-18 14:11:35 +00:00
Chris Dent
bad1c3edfb Fix pep8 w503 errors
W503 doesn't allow binary ops at start of line, so this fixes
it.

Change-Id: I945950f8cb457414fe7d7b4638e99412275b3a06
2015-02-18 14:09:59 +00:00
Chris Dent
da67a34cc7 Correct pep8 errors from imports in weird places.
If there are side effects associated with the location of these
imports, the tests don't cover it, so we can only hope.

Change-Id: I86e9754ff96ed881515fb0c8f9997acff740471d
2015-02-09 15:19:02 +00:00
Sławek Ehlert
b4ef065a4c several fixes for SOAP protocol
* fixed a small issue with binding
* fix for python2.6 when iterating over input msg
  (if the processed element is a comment - skip it)
* import print function (because it is used
  here in this form)
* fix minOccurs for non mandatory arguments
* operation namespace fix

    - https://bugs.launchpad.net/wsme/+bug/1235238
    - https://groups.google.com/forum/#!topic/python-wsme/gVzogTZlC7w

Change-Id: I2d237e04f27f8acd912cc8e2eb27d12ff72ebd04
2015-01-05 10:33:01 +01:00
Christophe de Vienne
292c556808 Make the flask adapter working with flask.ext.restful
Change-Id: I71d875f6579799b2881f76859fa88226dfea9b2b
2014-11-11 09:45:09 +01:00
Ryan Petrello
26a6acdadd Add support for manually specifying supported content types in @wsmeexpose.
Closes-bug: #1271317
Change-Id: Ia28a912f4444a6ff77b1feaf2ea6440b0c738e86
2014-09-24 21:04:52 -04:00
Dustin J. Mitchell
2e1863db6c Use APIPATH_MAXLEN from the right module
This fixes an AttributeError.

Change-Id: Ic76f42d7fbd6c0dd0fbdf2ccf464e8fff80b11cd
2014-06-20 17:13:58 -04:00
Julien Danjou
8e6077e270 Fix pep8 errors
The recent pep8 upgrade is triggering new errors.

Change-Id: I73b1de3afed0a6979e0542e4c90cdb0bdb8b1122
2014-04-25 14:57:05 +02:00
Julien Danjou
d69a287ba4 pecan: cleanup, use global vars and staticmethod
Change-Id: If5a7c1b4b71380053ed650ddc8e9928422869807
2014-01-10 14:17:33 +01:00
Jenkins
3b52161a60 Merge "Enable and fix Sphinx tests" 2013-10-11 15:50:16 +00:00
Yuriy Zveryanskyy
9546c10250 Add custom error code to ClientSideError
Added custom error status code for ClientSideError
exception instead of hardcoded value 400.
Fixed case when user exception with client error code
formatted as server error.
Pecan extension fixed.

Change-Id: I2663db0aa88538b722eb2783d130585b0fc2335b
2013-10-09 16:59:40 +03:00
Julien Danjou
71c8bcf5d0 Enable and fix Sphinx tests
This remove the Sphinx environment and makes sure we run its test for
all Python version. This therefore fixes the test for Python 3.3.

Change-Id: Iba431e837d2b23761905155ff65ae909774ce0b2
2013-10-07 14:53:08 +02:00
Mehdi Abaakouk
664c214dbf Handle [] {} for body in rest protocols
This change allow to use [] or {} for the definition of the body in rest
protocols.

Fixes bug #1233219

Change-Id: Ib96f0487dd7d78bd657f6d4b3facbd8b611f8702
2013-10-04 15:55:39 +02:00
Julien Danjou
abcdd7affa Include Pecan tests in default Python environment
- Makes sure we always run Pecan test and that there's no regression.
  There's no real need to split them out as they are not invasive.
  Also that reduces the number of environment a bit.
- This also fixes Pecan tests on python2.6
- This also fixes Pecan tests on python3.3
- This also enables Pecan tests on python3.2

Change-Id: I57070b0bd785fb3d445f432973f15825abccbdd5
2013-09-26 17:37:03 +02:00
Jenkins
4fd56a3f1a Merge "Minor code cleanups" 2013-09-23 10:01:56 +00:00
Jenkins
dae6299157 Merge "Remove various usage of sys.exc_info()" 2013-09-22 14:31:54 +00:00
Julien Danjou
1c37ea475e Remove various usage of sys.exc_info()
Change-Id: I7454264b82e808c68dd182e7ce43db756651a00b
2013-09-18 16:52:03 +02:00
Julien Danjou
a04748e868 Minor code cleanups
Change-Id: I338656e8f131b36aae342af94f1c2cedad14ae2b
2013-09-18 11:30:18 +02:00
Ryan Petrello
62725bb773 Add improved support for HTTP response codes in cornice apps.
Change-Id: I35efe85794e761877edd06722952292a3cac5d85
2013-09-16 12:07:55 -04:00
Ryan Petrello
0aba00b1ef Add improved support for HTTP response codes in TG 1.x apps.
Change-Id: I829ab360e13ae88a47e810079c739eac1d925139
2013-09-06 15:06:35 -04:00
Ryan Petrello
d8a70a300e Add improved support for HTTP response codes in flask apps.
Change-Id: If9894b262c58c597d7f7ae0cf6cb5de6783d364d
2013-09-06 12:59:31 -04:00
Ryan Petrello
f91767bf1e pep8 fixes, including a declaration in tox.ini for running flake8
Change-Id: I2adc6a5cbd76edd16e6079046b67b8fc10bf1671
2013-09-05 11:15:27 -04:00
119Vik
651ad18bdd Fix for returned status code and .gitignore
For this purposes I added addiitional processing of original
exceptions at wsme/wsmeext/pecan.py. For exception's validation
special validator was added to wsme/wsmeext/utils.py. Also
functionality was reworked to be compatible with python3.3

Fixes bug#1214073
Change-Id: Ib1cd0b274bda11f62298848ebcd55b3f6641757c
2013-08-28 18:03:30 +03:00
Christophe de Vienne
f9fe028eff Fix issue #11 in the pecan adapter 2013-08-02 14:04:43 +02:00
Christophe de Vienne
579772807e The Response object can now carry error details. Not sure about this though, it needs refinements 2013-06-21 00:22:23 +02:00
Christophe de Vienne
82d97971fc Fix inner null objects in the extdirect protocol 2013-05-13 18:57:54 +02:00
Christophe de Vienne
d05fb583eb Fix returning objects with object attributes set to 'None' 2013-05-13 18:14:11 +02:00
Christophe de Vienne
cab152874c Use assertEquals so we see what is the wrong value if any 2013-05-04 18:25:29 +02:00
Angus Salkeld
6ff590844e pecan: Make it possible to use the Response to return non-default status codes.
This is copied from the flask extension.
2013-04-24 13:48:28 +10:00
Christophe de Vienne
6b1a94b092 wsmeext.cornice now handle errors properly 2013-04-17 17:51:44 +02:00