PMXBOT Log file Viewer

Help | Karma | Search:

#dcpython logs for Wednesday the 8th of February, 2012

(Back to #dcpython overview) (Back to channel listing) (Animate logs)
[14:52:29] <ajsmith> morning
[15:13:23] <aclark> morning
[15:13:28] <aclark> richleland: how'd it go?
[15:13:55] <richleland> I think it went really well
[15:13:57] <richleland> had a blast
[15:14:03] <richleland> lots of great questions/discussion
[15:14:11] <aclark> awesome!
[15:14:14] <aclark> glad to hear
[15:27:22] <MattBowen> richleland: excellent presentation
[15:27:25] <MattBowen> richleland: how was the bar?
[15:31:49] <aclark> MattBowen: joshfinnie tweeted it was crowded IIRC
[15:31:51] <richleland> MattBowen thanks! Bar was good!
[15:32:02] <richleland> lots of good conversations
[15:32:46] <richleland> talked with a couple of guys in from the Atlantic, a guy from SpanishDict.com (one of my favorite sites), so had a lot of fun
[15:34:56] <aclark> hah awesome
[22:10:31] <richleland> kennethreitz ping
[22:10:48] <kennethreitz> richleland pong
[22:10:59] <richleland> is there a quick 'n dirty way to take a request that's been made, modify its query params, and then re-request?
[22:11:05] <richleland> (using requests, of course)
[22:11:23] <kennethreitz> richleland: make your changes to the request object then use request.send(anyway=True)
[22:11:30] <kennethreitz> and it'll send it anyway ;)
[22:11:51] <richleland> awesome
[22:12:17] <richleland> this makes abstracting my api client chaining SOOOO much easier
[22:12:55] <richleland> like response = api.get(someurl).embed('pages.body').fields('title')
[22:13:01] <aclark> if only there was requests for PHP… oh wait!
[22:13:03] <richleland> each chain modifying the query params
[22:13:07] <richleland> haha
[22:13:21] <richleland> actually we're prob gonna use that
[22:13:38] <richleland> our front-end code for each site is going to connect to this massive content api
[22:13:46] <MattBowen> richleland: does you example generate 3 api calls? or does it defer until the last one?
[22:13:47] <richleland> some of the front-ends are PHP, some are Python
[22:14:03] <richleland> MattBowen I want to defer, just not sure how to do that yet
[22:14:07] <MattBowen> richleland: :)
[22:14:16] <MattBowen> .end()
[22:14:19] <MattBowen> (terrible)
[22:14:29] <MattBowen> or, funnier, .stop()
[22:14:31] <MattBowen> like a telegram!
[22:15:24] <richleland> .makemysandwichnow()
[22:15:28] <MattBowen> exactly
[22:26:06] <richleland> that's a really interesting problem - is there a way in Python to defer a set of chained methods like that?
[22:26:42] <MattBowen> richleland: like to know you're at the end of a chain?
[22:26:50] <richleland> yeah
[22:26:53] <MattBowen> richleland: off cuff, I almost feel like you need something like .send()
[22:27:06] <MattBowen> because like, what if I want to prepare my request in a few steps so I can use a conditional?
[22:27:30] <MattBowen> richleland: i think it's lazy about getting results until you actually demand them
[22:27:31] <richleland> different use case
[22:27:40] <MattBowen> so the django ORM just preps a query until you ask for a result
[22:27:53] <richleland> ah... hmm
[22:28:11] <richleland> right so it doesn't actually make the call until you access one of the QuerySet's methods
[22:28:17] <MattBowen> right
[22:28:23] <MattBowen> so I guess you could do it that way
[22:28:26] <richleland> in which case it's already got the SQL it needs
[22:28:28] <richleland> cool cool yeah
[22:30:10] <MattBowen> now that we say it, it seems so simple
[22:30:29] <richleland> yeah it really does
[22:30:50] <MattBowen> what would people be expecting response to be though?
[22:30:51] <MattBowen> a string?
[22:31:10] <MattBowen> I guess even then, you can just have it be an object where the __str__() method makes the request and returns the results
[22:31:13] <MattBowen> <3 python
[22:31:29] <richleland> in my case I'm going to be returning a response from the API provider
[22:31:42] <MattBowen> so like an http response?
[22:32:46] <richleland> yeah - I'm using requests under the hood, so I'm going to have a DWSConnection class that has attributes like original_response (the requests Response class), and other things like data, etc.
[22:33:35] <richleland> so in Django code we can do something like response = api.get(someurl).embed('modules')
[22:33:58] <richleland> then do shit like response.data, response.original_response, response.data.modules, etc.
[22:34:17] <richleland> it's just a wrapper to make working with this crazy ass API easier
[22:35:11] <MattBowen> cool -- so yeah, data and original_response would be @properties that triggered a request
[22:35:19] <MattBowen> now i kinda want to wrap an API
[22:35:26] <richleland> yeah
[22:35:57] <richleland> embed just sets up (or modifies) the URL that needs to get called (the Request that needs to be made)
[23:25:49] <j00bar> anybody use fabric?
[23:25:58] <j00bar> or feel confident in their fabric-fu?
[23:26:11] <aclark> o/
[23:26:21] <aclark> i like my chances with fabric…
[23:26:26] <aclark> for basic stuff
[23:26:30] <j00bar> i want a function that takes an argument that is a host name
[23:26:41] <j00bar> then i want fabric to do a procedure on that hostname
[23:26:45] <j00bar> and this isn't command-line run
[23:26:50] <j00bar> so i don't get -H here
[23:29:31] <aclark> j00bar: hmmm can you change env.host on the fly maybe?
[23:29:42] <j00bar> i've tried setting env.hosts within the function
[23:29:52] <j00bar> i've tried using with settings(hosts=[host])
[23:30:08] <j00bar> i keep getting: No hosts found. Please specify (single) host string for connection:
[23:30:48] <aclark> hmmm, there is: http://docs.fabfile.org/en/1.3.4/usage/env.html#host-string
[23:31:33] <j00bar> hmm
[23:31:35] <j00bar> trying that
[23:32:37] <j00bar> w00tw00t
[23:34:59] <aclark> grrr, i can't believe so many people use the word "leverage" instead of "use" e.g. http://docs.fabfile.org/en/1.3.4/usage/fab.html?highlight=leverage#arbitrary-remote-shell-commands
[23:50:54] <papna> I edited "leveraging" to "using" in an email I wrote earlier.
[23:50:59] <papna> Be the change you want to see.
[23:52:28] <aclark> papna: thanks! :-)
[23:54:36] <papna> There's something nice about a term like "leverage".
[23:54:56] <papna> It implies that your use makes it sound like you're magnifying value.
[23:55:54] <aclark> i don't think i've seen leverage used properly in the last 15 years
[23:56:23] <papna> aclark: Bah.