예제 #1
0
 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')
예제 #2
0
 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
예제 #3
0
 def apikey(self):
     apikey = self.configuration.apikey
     if not apikey:
         logger.error('You must provide an api key first')
     return apikey