def __call__(self, *args): # Download the image data from Picnik's servers image_data = self.fetch_image() if not image_data: # Download failed ... this shouldn't happen very often, # but you might want to put some retry logic in your app logger.error("Sorry, the image download failed.") return "image fail to update" # Save the image self.update_context() self.request.response.redirect(self.context.absolute_url()+'/view')
def get_image_url(self): """Extract image url from the request and make some checks""" #Make sure we've been sent an image url image_url = self.request.form.get('file', None) if not image_url: logger.error("No image url has been provide") return '' # Make sure that the image came from picnik. We don't want anyone # sending us data we didn't ask for! image_url = urllib.unquote(image_url) if not image_url.startswith("http://www.picnik.com") and not image_url.startswith("http://www.picnikr.com"): logger.error("Sorry, the image URL doesn't seem right: %s"%image_url) return '' return image_url
def apikey(self): apikey = self.configuration.apikey if not apikey: logger.error('You must provide an api key first') return apikey