Example #1
0
    def processUnixMailbox(self, input, start=None, end=None):
        mbox = ArchiverMailbox(input, self.maillist)
        if start is None:
            start = 0
        counter = 0
        if start:
            mbox.skipping(True)
        while counter < start:
            try:
                m = mbox.next()
            except Errors.DiscardMessage:
                continue
            if m is None:
                return
            counter += 1
        if start:
            mbox.skipping(False)
        patch_export = False
        while 1:
            try:
                pos = input.tell()
                m = mbox.next()
            except Errors.DiscardMessage:
                continue
            except Exception:
                syslog('error', 'uncaught archiver exception at filepos: %s',
                       pos)
                raise
            if m is None:
                break
            if m == '':
                # It was an unparseable message
                continue
            msgid = m.get('message-id', 'n/a')
            self.message(_('#%(counter)05d %(msgid)s'))
            a = self._makeArticle(m, self.sequence)
            self.sequence += 1
            self.add_article(a)

            url = self.maillist.GetBaseArchiveURL() + self.archive + '/' + a.filename
            
            report_submission(msgid, 'Post accepted and <a href="%s">published</a>!' % url)
            if db_add_archive_info(self.maillist, m, url):
                patch_export = True

            if end is not None and counter >= end:
               break
            counter += 1

        if patch_export:
            db_export(self.maillist)
Example #2
0
    attnum = 1
    while attnum < 99:
        try:
            att = cgidata["attachment%02d" % attnum]
        except KeyError:
            break
        if att.filename:
            #Browser should send right mimetypes
            (maintype, subtype) = att.type.split('/')
            opt = att.type_options;
            data = att.file.read()
            if maintype == 'text':
                if 'encoding' not in opt:
                    opt['encoding'] = 'utf-8'
                part = MIMEText(data, subtype, opt['encoding'])
            elif maintype == 'image':
                part = MIMEImage(data, subtype)
            elif maintype == 'audio':
                part = MIMEAudio(data, subtype)
            elif maintype == 'application':
                part = MIMEApplication(data, subtype)
            else:
                part = MIMEApplication(data)
                
            part["Content-Disposition"] = "attachment; filename=" + att.filename
            msg.attach(part)
        attnum+=1;
    Post.inject(listname,msg)
    url = report_submission(msgid, 'Processing...', True)
    print "Status: 303 \nLocation: " + url +"\n"