def deleteUser(self): # We first have to remove the user's image from the blobstore, the Moodstocks DB and his reference in the Datastore image = self.user.imageRef if(image): imageID = str(image.key().id()) # We delete the image from Moodstocks DB moodstocksHandler = Moodstocks() moodstocksHandler.deleteObject(imageID) # We delete the image in the blobstore blobInfo = image.blobKey blobKey = blobInfo.key() blobstore.delete(blobKey) # We can now remove the image reference image.delete() # We first remove the vcard vcard = self.user.vcardRef if(vcard): vcard.delete() self.user.delete() logging.info("User has been removed from Captur.io") path = os.path.join(os.path.dirname(__file__), 'templates/delete/information_removed.html') self.response.out.write(template.render(path, None))
def saveUsertemp(self): # We determine first if some user information was already in the database user_query = User.all().filter("mail", self.usertemp.mail) existingUser = user_query.get() if(existingUser): user = existingUser user.label = self.usertemp.label oldVcardRef = user.vcardRef oldImageRef= user.imageRef if(oldImageRef): oldImageRefID = str(oldImageRef.key().id()) logging.info("User found: %s, %s" % (user.label, user.mail)) else: user = User() oldVcardRef = None oldImageRef = None user.label = self.usertemp.label user.mail = self.usertemp.mail if(self.usertemp.imageRef): # We replace the old image Ref/ (or if not found) add the new image Ref user.imageRef = self.usertemp.imageRef # If there was an old image ref, we have to delete the image in the blobstore, in the Moodstocks DB and the reference in the Datastore if(oldImageRef): # We delete the image from Moodstocks DB moodstocksHandler = Moodstocks() moodstocksHandler.deleteObject(oldImageRefID) # We delete the image in the blobstore blobInfo = oldImageRef.blobKey oldBlobKey = blobInfo.key() blobstore.delete(oldBlobKey) # We delete the existing image Ref oldImageRef.delete() if(self.usertemp.vcardRef): # We replace the old vcard Ref/ (or if not found) by the new vcard Ref user.vcardRef = self.usertemp.vcardRef # If there was an old vcard ref, we have to delete it from to datastore if(oldVcardRef): oldVcardRef.delete() user.put() self.usertemp.delete() path = None if(user.imageRef): if(user.vcardRef): path = os.path.join(os.path.dirname(__file__), 'templates/post/all_set.html') else: path = os.path.join(os.path.dirname(__file__), 'templates/post/almost_set_vcard_missing.html') else: path = os.path.join(os.path.dirname(__file__), 'templates/post/almost_set_image_missing.html') self.response.out.write(template.render(path, None))