Fixed "No module named _ssl" when using Google API Python Client on App Engine
Since 6d9ba51 less than a week ago, Google API Python Client now works on App Engine out-of-the-box; previously, you had to remember to 'enable' the ssl library (see this) so that it would be available, even though it is part of the Python standard library. (See issue #191 for a detailed description of the problem.)
I ran into this so as to avoid using the Cloud Storage client specific to App Engine, which seems to be the 'official' method to access Cloud Storage according to the App Engine docs. I wanted to avoid the client as it leads to some mental impedance if you are already using Cloud Storage out of App Engine, eg. via the JSON API.
For example, to list a bucket, using the client you would use max_keys
and marker
:
stats = gcs.listbucket(bucket, max_keys=page_size)
while True:
for stat in stats:
# do something...
stats = gcs.listbucket(bucket, max_keys=page_size, marker=stat.filename)
But that's actually maxResults
and (likely) pageToken
in the JSON API.
After some to-and-fro over a couple of days, (no) thanks to timezone differences, my fix, #220, got merged.
I think it's pretty cool that the Python API client involves "discovering" the specific API you want to use, and exposes a function/method-like interface. For example:
res = cs_service.objects().list(...).execute()
res = tq_service.tasks().list(...).execute()
In the first, we're listing objects via the Cloud Storage API. In the second, we're listing tasks via the Task Queue API. The APIs could not be more different, but we're accessing them in a pretty much uniform manner.
(Yes, App Engine's task queues has a REST API, which is useful (in fact, only so) when you are building a consumer for pull queues. More on that next time!)