Ejemplo n.º 1
0
    def get(self, email_id):
        logging.info('MailDetailsPage processing')
        logging.info('email_id: ' + email_id)
        email_id = str(email_id).strip()
        if email_id and email_id != '':
            logging.info('valid email_id')

        user = users.get_current_user()

        email = Email.get(email_id)
        if email:
            logging.info('attachments')
            email._files = None
            if email.attachments:
                if len(email.attachments) > 0:
                    email._files = []
                for i in range(len(email.attachments)):
                    file = Files.get(email.attachments[i])
                    email._files.append(file)
                    logging.info('file.name : ' + file.name)

        template_values = {
            'home_url': '/home',
            'email_url': '/mail',
            'nickname': user.nickname(),
            'logout_url': users.create_logout_url("/"),
            'email': email
        }

        self.template_values = template_values
        self.render('mail_details.html')
Ejemplo n.º 2
0
    def get(self, emailid):
        logging.info('downloading zip file for email: ' + emailid)
        emailid = str(emailid).strip()
        if emailid and emailid != '':
            email = Email.get(emailid)
            if email:
                logging.info('email attachments count: ' + str(len(email.attachments)))
                
                # create the zip stream
                zipstream=StringIO()
                zfile = zipfile.ZipFile(zipstream,"w")

                for attachment in email.attachments:
                    file_attachment = Files.get(attachment)
                    if file_attachment:
                        zfile = self.addFile(zfile, file_attachment.name, file_attachment.content)
                
                zfile.close()
                zipstream.seek(0)
                
                self.response.headers['Content-Type'] = 'application/zip'
                self.response.headers['Content-Disposition'] = 'attachment; filename="attachments.zip"'
                #self.response.out.write(zfile.content)
                while True:
                    buf = zipstream.read(2048)
                    if buf == "":
                        break
                    self.response.out.write(buf)
Ejemplo n.º 3
0
    def get(self, email_id):
        logging.info('MailDetailsPage processing')
        logging.info('email_id: ' + email_id)
        email_id = str(email_id).strip()
        if email_id and email_id != '':
            logging.info('valid email_id')
        
        user = users.get_current_user()
        
        email = Email.get(email_id)
        if email:
            logging.info('attachments')
            email._files = None
            if email.attachments:
                if len(email.attachments) > 0:
                    email._files = []
                for i in range(len(email.attachments)):
                    file = Files.get(email.attachments[i])
                    email._files.append(file)
                    logging.info('file.name : ' + file.name)

        template_values = {
                           'home_url' : '/home',
                           'email_url' : '/mail',
                           'nickname' : user.nickname(),
                           'logout_url': users.create_logout_url("/"),
                           'email': email
                }
        
        self.template_values = template_values
        self.render('mail_details.html')
Ejemplo n.º 4
0
    def get(self, emailid):
        logging.info('downloading zip file for email: ' + emailid)
        emailid = str(emailid).strip()
        if emailid and emailid != '':
            email = Email.get(emailid)
            if email:
                logging.info('email attachments count: ' +
                             str(len(email.attachments)))

                # create the zip stream
                zipstream = StringIO()
                zfile = zipfile.ZipFile(zipstream, "w")

                for attachment in email.attachments:
                    file_attachment = Files.get(attachment)
                    if file_attachment:
                        zfile = self.addFile(zfile, file_attachment.name,
                                             file_attachment.content)

                zfile.close()
                zipstream.seek(0)

                self.response.headers['Content-Type'] = 'application/zip'
                self.response.headers[
                    'Content-Disposition'] = 'attachment; filename="attachments.zip"'
                #self.response.out.write(zfile.content)
                while True:
                    buf = zipstream.read(2048)
                    if buf == "":
                        break
                    self.response.out.write(buf)
Ejemplo n.º 5
0
 def get(self, fileid):
     logging.info('downloading: ' + fileid)
     fileid = str(fileid).strip()
     if fileid and fileid != '':
         file = Files.get(fileid)
         if file:
             self.response.headers['Content-Type'] = 'application/octet-stream'
             self.response.headers['Content-Disposition'] = 'attachment; filename="' + file.name + '"'
             self.response.out.write(file.content)
Ejemplo n.º 6
0
 def get(self, fileid):
     logging.info('downloading: ' + fileid)
     fileid = str(fileid).strip()
     if fileid and fileid != '':
         file = Files.get(fileid)
         if file:
             self.response.headers[
                 'Content-Type'] = 'application/octet-stream'
             self.response.headers[
                 'Content-Disposition'] = 'attachment; filename="' + file.name + '"'
             self.response.out.write(file.content)