hello friends,
as i wanted to add web services to our website, tgwebservices was missing for me in tg 2.
luckily, before trying to port it, wsme popped in my search, so i ported an active project made for portability.
my port is based on tg1*, but departs in functionality where needed or made sense.
attached are my files with brief explanation on how to integrate.
i have slightly modified the client in order to print the commands before they run.
the demo was slightly modified, so that it is made with stock wsme, not with the adapted commands. thus, the same demo may be imported in various modules, with different adapters.
thank you very much for providing wsme, and please consider my modest contribution.
alex
The main reason is that I don't think it works properly (although I
haven't test it completely).
The thing is that the demo you provide actually use the standalone wsme
WSRoot and its associated decorators, and not the decorators from your
adapter.
Also, your scan_api function takes a WSRoot as its root controller,
where it whould have been the root controller of your application (a TG2
one).
hello christophe,
thanks for your rapid consideration.
let me reply inline:
On Friday, February 28, 2014 11:23:53 AM UTC+2, Christophe de Vienne wrote:The main reason is that I don't think it works properly (although I
haven't test it completely).
well, i'd be glad to help or test anything would be needed.
The thing is that the demo you provide actually use the standalone wsme
WSRoot and its associated decorators, and not the decorators from your
adapter.
the demo is your demo. i have purposely taken a situation not depending on my code.
but now i'm also attaching a new controller, inheriting from wsroot and tgcontroller, that performs the same in native tg2.
so, any wsroot controller can be used directly.
please see my attachment.
Also, your scan_api function takes a WSRoot as its root controller,
where it whould have been the root controller of your application (a TG2
one).
no, you're wrong here.
if you call scan_api() with no controller, the root of my app is being taken. that invoked by index.
all controllers in my solution inherit from tgcontroller, including the wsme wrapping wsgicontroller.
in the scanning process, wsexposed methods of tgcontroller would be yield. these specialized for tg2.
but if a wsme wrapping wsgicontroller would be encountered, the scan would be delegated to it.
thus, all exposed methods, either specific to tg2 or not, would be yield correctly.
i have specifically tried this by the demo in my comment.
besides that demo, some wsexposed entries have been put throughout my controller tree.
Hello Alex,
Le 01/03/2014 16:36, Alex Bodnaru a écrit :
Well, my demo is not relevant at all when embedded in another framework with an adapter.
hello christophe,
thanks for your rapid consideration.
let me reply inline:
On Friday, February 28, 2014 11:23:53 AM UTC+2, Christophe de Vienne wrote:The main reason is that I don't think it works properly (although I
haven't test it completely).
well, i'd be glad to help or test anything would be needed.
The thing is that the demo you provide actually use the standalone wsme
WSRoot and its associated decorators, and not the decorators from your
adapter.
the demo is your demo. i have purposely taken a situation not depending on my code.
but now i'm also attaching a new controller, inheriting from wsroot and tgcontroller, that performs the same in native tg2.
so, any wsroot controller can be used directly.
please see my attachment.
Also, your scan_api function takes a WSRoot as its root controller,
where it whould have been the root controller of your application (a TG2
one).
no, you're wrong here.
if you call scan_api() with no controller, the root of my app is being taken. that invoked by index.
all controllers in my solution inherit from tgcontroller, including the wsme wrapping wsgicontroller.
in the scanning process, wsexposed methods of tgcontroller would be yield. these specialized for tg2.
but if a wsme wrapping wsgicontroller would be encountered, the scan would be delegated to it.
thus, all exposed methods, either specific to tg2 or not, would be yield correctly.
i have specifically tried this by the demo in my comment.
besides that demo, some wsexposed entries have been put throughout my controller tree.
Well, I was confused by line 214, which clearly feeds a sub-controller to the scan_api function. I don't think this function is meant to work this way.
Another thing that is confusing is the way you combine TGController and WSRoot.
This is clearly not needed.
The idea is that unless you want to enable additionnal protocols, you do not need a WSRoot. Only exposing functions with the decorators provided by the adapter is enough.
The scan_api function allows a WSRoot that would be 'mounted' on, say, '/ws', to handle additionnal protocols and still call functions that are not in its own sub-paths.
This make your example (in the module docstrings) incorrect.
A typical TG2 application would not need to "addprotocol" for restjson and restxml, only for soap _if_ additional protocoles are needed only.
Concerning the registration of the renderers, I suggest the adapter provides a function that takes a "config" object as argument and does the job itself.
This way, the environment would only need 2 lines :
import wsmeext.tg2
wsmeext.tg2.setup(base_config)
Still about the renderers, the "mod" parameter and the way you pass it seems odd.
In the exception handler, why is there a try..finally? Do you really expect some exception to occur at this point? And does exception_info really need to be deleted?
About the unittests I need, take a look at the pecan and the TG1 unittests that are in the "test" directory. The basic idea is to set up a test application with unittests inside it. Tox will run them as part of the whole test suite.
Also, note that the adapter should live in "wsmeext/tg2.py".
Is there any reason why you did not use gerrit to submit your patch ? Doing so would make the reviewing process way easier.
Best regards,
Christophe
Le 31/03/2014 19:01, Alex Bodnaru a écrit :
>
> hello christophe, everybody,
>
> attached is my best attempt to organize my code in a patch to stackforge,
> with documentation etc.
Thanks.
> unfortunately, i didn't find a way to join the gerrit group/project in
> order to
> post myself my patch for review.
I think you only need to have a launchpad identity, configure gerrit and
do a gerrit review. Could give it a try ?
> there seems to be a bug with soap in the demos:
>
> class
> Root(controllers.RootController):
> # Having a WSRoot on /ws is only required to enable
> additional
> # protocols. For REST-only services, it can be
> ignored.
> root =
> DemoRoot(webpath='/ws')
>
> root.addprotocol('soap',
>
> tns='http://example.com/demo',
>
> typenamespace='http://example.com/demo/types',
>
> baseURL='http://127.0.0.1:8080/ws/',
>
> )
>
> root.addprotocol('restjson')
> ws =
> WSController(root)
>
> if soap is not the first protocol added, the invokation will fail.
>
> please instruct me how to continue in order that my patch be used.
I see you modified wsmeext/soap/protocol.py, probably to fix the issue
you describe above. If this is indeed a bugfix, it should be a separate
patch.
Your patch should also not touch the demo scripts but rather provides
some unit tests that can be runned with tox and provide a good (if not
complete) coverage of you adapter.
See tox-tmpl.ini, and the framework specific tests in the test directory.
If you have questions on those please ask.
Thanks
Christophe