Pubsub example on front page fails if topic does not already exist
The pubsub example throws an exception if the specified topic does not already exist. Example:
>>> from gcloud import pubsub >>> client = pubsub.Client(project=MY_PROJECT_ID) >>> topic = client.topic('my-new-custom-topic') >>> topic.publish('Ping!') Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/local/lib/python2.7/dist-packages/gcloud/pubsub/topic.py", line 186, in publish method='POST', path='%s:publish' % (self.path,), data=data) File "/usr/local/lib/python2.7/dist-packages/gcloud/connection.py", line 419, in api_request error_info=method + ' ' + url) gcloud.exceptions.NotFound: 404 Resource not found (resource=my-custom-topic). (POST https://pubsub.googleapis.com/v1/projects/lee-cloud/topics/my-custom-topic:publish)
The code sample will resume working if you create the topic and re-run the sample, but it would be nice if the code sample included a line or two demonstrating how to create a topic if it doesn't exist.