On 07/24/2013 05:12 AM, Ozgur Susoy wrote:
Hi Ozgur, thanks for your interest!
how can i
access payloads passed in as get parameters or url variables? as examples:
http://some.url/something/search?a=b&c=d (a and c are the search
parameters the service needs)
http://some.url/something/1234 (1234 is an identifier needed by the
service and as such a variable component of the url)
Query string is part of the HTTP WSGI environment and can accessed as below
from urlparse import parse_qs
from zato.server.service import Service
qs = parse_qs(self.wsgi_environ[‘QUERY_STRING’])
If you’re wondering why it’s not directly accessed through self.request,
this is simply because I didn’t have time to add GET to the
’data_format’ select list when creating a new HTTP channel like here
I mean to add it along with CSV in addition to already JSON and XML and
then it will be possible to access it through
self.request.payload.foo # read from ?foo=baz
I just don’t feel conceptually something like self.request.qs is the
right place - not everything is HTTP. WSGI on the other hand is a
well-established means to convey such information hence maybe in
addition to what I wrote above (HTTP channel with GET data_format) the
same information could be put into
self.wsgi_environ[‘zato.http.qs’].foo # read from ?foo=baz
Would do you think?
In that way, if your service operates on GET parameters /only/ you’d set
its data_format to GET.
If on the other hand the service receives both, say, JSON in POST
payload along with some additional GET parameters, the latter would be
accessible through self.wsgi_environ[‘zato.http.qs’].
Unless of course you always receive both POST and GET parameters so in
that situation the GUI can be given a ‘Merge GET’ checkbox and they
could all be merged into self.request.payload, sure, why not.
I’m just not sure what is the most common scenario you’re dealing with?
Me, I’ve always had either POST or GET but not both though I understand
others may have different approaches.
get parameters seem to vanish altogether (request.raw_string is blank)
and i haven’t been able to find an example of how to do the latter with
I’m travelling today and won’t be able to do it but it sure needs to be
added to usage examples at
you’re absolutely right!