Re: [pylons-discuss] Suggested way to issue requests from inside a view callable

2018-05-01 Thread Michael Merickel
requests is great and is what I use. There is a little-known feature in
webob that probably deserves a mention though. You can build a
webob.Request object and call send() or get_response() on it to get back a
webob.Response object from the third party. It uses the stdlib http.client
under the hood.

https://docs.pylonsproject.org/projects/webob/en/stable/api/request.html#webob.request.BaseRequest.get_response
https://docs.pylonsproject.org/projects/webob/en/stable/api/client.html

❯ env/bin/ipython
Python 3.6.4 (default, Feb 25 2018, 17:42:04)
Type 'copyright', 'credits' or 'license' for more information
IPython 6.2.1 -- An enhanced Interactive Python. Type '?' for help.

In [1]: from webob import Request

In [2]: req = Request.blank('https://httpbin.org/get')

In [3]: resp = req.send()

In [4]: resp.json_body
Out[4]:
{'args': {},
 'headers': {'Accept-Encoding': 'identity',
  'Connection': 'close',
  'Host': 'httpbin.org'},
 'origin': '173.20.144.105',
 'url': 'https://httpbin.org/get'}

In [5]: list(resp.headers.items())
Out[5]:
[('Connection', 'keep-alive'),
 ('Server', 'gunicorn/19.7.1'),
 ('Date', 'Tue, 01 May 2018 14:14:29 GMT'),
 ('Content-Type', 'application/json'),
 ('Access-Control-Allow-Origin', '*'),
 ('Access-Control-Allow-Credentials', 'true'),
 ('X-Powered-By', 'Flask'),
 ('X-Processed-Time', '0'),
 ('Content-Length', '196'),
 ('Via', '1.1 vegur')]


On Tue, May 1, 2018 at 12:23 AM,  wrote:

> Hello,
>
> I guess following up on the thread on Pyramid’s sub-requests, what is the
> recommended way to issue a (synchronous) request to an external server from
> within a view callable? Using the requests
>  package, or are there
> Pyramid plugins available (didn’t find any at first glance).
>
> Thank you for recommendations…
> Jens
>
> --
> You received this message because you are subscribed to the Google Groups
> "pylons-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to pylons-discuss+unsubscr...@googlegroups.com.
> To post to this group, send email to pylons-discuss@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/pylons-discuss/75f3cb8f-7984-445a-b0fc-e7ffda1a7768%
> 40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to pylons-discuss+unsubscr...@googlegroups.com.
To post to this group, send email to pylons-discuss@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/pylons-discuss/CAKdhhwHinnHKB7oqjWedRGaYqjUmhkwF0Xm0gyAgoOJ7HrSEzg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [pylons-discuss] Suggested way to issue requests from inside a view callable

2018-05-01 Thread Steve Piercy
On 4/30/18 at 10:23 PM, jens.troe...@gmail.com pronounced:

> I guess following up on the thread on Pyramid’s sub-requests 
> , what is the recommended way to issue a 
> (synchronous) request to an external server from within a view callable? 
> Using the requests  package, or 
> are there Pyramid plugins available (didn’t find any at first glance).

Requests, even though it is for humans.

--steve


Steve Piercy, Eugene, OR

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to pylons-discuss+unsubscr...@googlegroups.com.
To post to this group, send email to pylons-discuss@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/pylons-discuss/r473Ps-10126i-1ED3EF811EE24635859E7D84AD00DF6F%40Steves-iMac.local.
For more options, visit https://groups.google.com/d/optout.


[pylons-discuss] Suggested way to issue requests from inside a view callable

2018-04-30 Thread jens . troeger
Hello,

I guess following up on the thread on Pyramid’s sub-requests 
, what is the recommended way to issue a 
(synchronous) request to an external server from within a view callable? 
Using the requests  package, or 
are there Pyramid plugins available (didn’t find any at first glance).

Thank you for recommendations…
Jens

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to pylons-discuss+unsubscr...@googlegroups.com.
To post to this group, send email to pylons-discuss@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/pylons-discuss/75f3cb8f-7984-445a-b0fc-e7ffda1a7768%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.