<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">Hi,</div><div class=""><br class=""></div>I traced the WSME code and found a place [0] where it tries to get arguments from request body based on different mimetype. So looks like WSME supports only json, xml and “application/x-www-form-urlencoded”.<div class=""><br class=""></div><div class="">So my question is: <b class="">Can we fix WSME to also support “text/plain” mimetype?</b> I think the first snippet that Nikolay provided is valid from WSME standpoint.</div><div class=""><br class=""></div><div class="">Or if we don’t understand something in WSME philosophy then it’d nice to hear some explanations from WSME team. Will appreciate that.</div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">Another issue that previously came across is that if we use WSME then we can’t pass arbitrary set of parameters in a url query string, as I understand they should always correspond to WSME resource structure. So, in fact, we can’t have any dynamic parameters. In our particular use case it’s very inconvenient. Hoping you could also provide some info about that: how it can be achieved or if we can just fix it.</div><div class=""><br class=""></div><div class="">If you need help with contribution let us know pls.</div><div class=""><br class=""></div><div class="">Thanks</div><div class=""><div class=""><br class=""></div><div class="">[0] <a href="https://github.com/stackforge/wsme/blob/master/wsme/rest/args.py#L215" class="">https://github.com/stackforge/wsme/blob/master/wsme/rest/args.py#L215</a></div><div class=""><br class=""><div class=""><div class="">
<div class="">Renat Akhmerov</div><div class="">@ Mirantis Inc.</div><div class=""><br class=""></div><br class="Apple-interchange-newline">

</div>
<br class=""><div><blockquote type="cite" class=""><div class="">On 25 Nov 2014, at 23:06, Nikolay Makhotkin <<a href="mailto:nmakhotkin@mirantis.com" class="">nmakhotkin@mirantis.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">Hi, folks! <br class=""><br class="">I try to create a controller which should receive one http content-type in request but it should be another content-type in response. I tried to use pecan and wsme decorators for controller's methods.<div class=""><br class=""></div><div class="">I just want to receive text on server and send json-encoded string from server (request has text/plain and response - application/json) </div><div class=""><br class=""></div><div class="">I tried: <br class=""><br class="">class MyResource(resource.Resource):<div class="">    id = wtypes.text</div><div class="">    name = wtypes.text</div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">class MyResourcesController(rest.RestController):</div><div class="">    @wsexpose(MyResource, body=wtypes.text)</div><div class="">    def put(self, text):</div><div class="">        return MyResource(id='1', name=text)</div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">According to WSME documentation (<a href="http://wsme.readthedocs.org/en/latest/integrate.html#module-wsmeext.pecan" class="">http://wsme.readthedocs.org/en/latest/integrate.html#module-wsmeext.pecan</a>) signature wsexpose method as following: <br class=""><br class="">  <tt class="" style="font-family: 'Droid Sans Mono', monospace; font-weight: bold; line-height: 19.6000003814697px;">wsexpose</tt><big style="font-family: 'Open Sans', sans-serif; line-height: 19.6000003814697px;" class="">(</big><em style="font-family: 'Open Sans', sans-serif; line-height: 19.6000003814697px;" class="">return_type</em><span style="font-family: 'Open Sans', sans-serif; line-height: 19.6000003814697px;" class="">, </span><em style="font-family: 'Open Sans', sans-serif; line-height: 19.6000003814697px;" class="">*arg_types</em><span style="font-family: 'Open Sans', sans-serif; line-height: 19.6000003814697px;" class="">, </span><em style="font-family: 'Open Sans', sans-serif; line-height: 19.6000003814697px;" class="">**options</em><big style="font-family: 'Open Sans', sans-serif; line-height: 19.6000003814697px;" class="">)</big></div><div class=""><big style="font-family: 'Open Sans', sans-serif; line-height: 19.6000003814697px;" class=""><br class=""></big></div><div class=""><font face="Open Sans, sans-serif" class=""><span style="line-height:19.6000003814697px" class="">Ok, I just set MyResource as return_type and body to text type. But it didn't work as expected: </span><br class=""><span style="line-height:19.6000003814697px" class=""><a href="http://paste.openstack.org/show/138268/" class="">http://paste.openstack.org/show/138268/</a></span></font><span style="font-family: 'Open Sans', sans-serif;" class=""> </span></div><div class=""><font face="Open Sans, sans-serif" class=""><br class="">I looked at pecan documentation at <a href="https://media.readthedocs.org/pdf/pecan/latest/pecan.pdf" class="">https://media.readthedocs.org/pdf/pecan/latest/pecan.pdf</a> but I didn't find anything that can fit to my case.<br class=""><br class="">Also, I tried: <br class=""><br class=""></font>class MyResource(resource.Resource):<div class="">    id = wtypes.text</div><div class="">    name = wtypes.text</div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">class MyResourcesController(rest.RestController):</div><div class="">    @expose('json')</div><div class="">    @expose(content_type="text/plain")</div><div class="">    def put(self):</div><div class="">        text = pecan.request.text</div><div class="">        return MyResource(id='1', name=text).to_dict()</div></div><div class=""><br class=""></div><div class="">It worked just in case if request and response have the same content-type. (application/json<->application/json, text/plain<->text/plain)</div><div class=""><br class=""></div><div class="">I also tried a lot of combination of parameters but it is still not worked.</div><div class=""><br class=""></div><div class="">Does anyone know what the problem is?</div><div class=""><span style="font-family: 'Open Sans', sans-serif;" class="">How it can be done using WSME and/or Pecan?</span><br class=""></div><div class=""><br class=""></div><div class="">Sorry if I misunderstand something.</div>-- <br class=""><div class="gmail_signature"><div dir="ltr" class=""><div class=""><font class="">Best Regards,</font></div><div class=""><font class="">Nikolay</font></div></div></div>
</div></div>
_______________________________________________<br class="">OpenStack-dev mailing list<br class=""><a href="mailto:OpenStack-dev@lists.openstack.org" class="">OpenStack-dev@lists.openstack.org</a><br class="">http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev<br class=""></div></blockquote></div><br class=""></div></div></div></body></html>