def xmlrpc_edit(self, id, author, title, category, content): post = IBlog(self.store).getOne(id) post.author = author post.title = title post.category = category post.content = content post.setModified() return 'Successfully modified post number %s' % id
def eomReceived(self): post = {} isContent = False ctnt_buff = [] recipients = self.lines[0] addrs = [] for recipient in recipients: if '@' not in recipient.orig.addrstr: # Avoid answering to bounches if not recipient.orig.addrstr == '<>': addrs.append(recipient.orig.addrstr[:-1]+'@'+recipient.orig.domain+'>') else: # Avoid answering to bounches if not recipient.orig.addrstr == '<#@[]>': addrs.append(recipient.orig.addrstr) for line in self.lines[1:]: if not isContent: try: field, value = line.split(':', 1) except ValueError: continue if field.lower() != 'content': post[field.lower()] = value.strip() else: isContent = True ctnt_buff.append(value.strip()) else: ctnt_buff.append(line.strip()) post['content'] = '\n'.join(ctnt_buff) for header in 'content author category title'.split(): if header not in post: self.lines = [] return defer.fail(None) if 'id' in post: oldpost = IBlog(self.store).getOne(int(post['id'])) oldpost.author = str(post['author']) oldpost.title = str(post['title']) oldpost.category = str(post['category']) oldpost.content = str(post['content']) oldpost.setModified() action = 'modified' id = post['id'] else: newid = IBlog(self.store).getNextId() newPost = Post(store=self.store, id=newid, author=str(post['author']), title=str(post['title']), category=str(post['category']), content=str(post['content'])) IBlog(self.store).addNewPost(newPost) action = 'added' id = newid self.lines = [] msg = """From: <%s> Subject: Successfull Post Post number %s successfully %s """ % (FROM, id, action) return self.sendNotify(addrs, msg)
def eomReceived(self): post = {} isContent = False ctnt_buff = [] recipients = self.lines[0] addrs = [] for recipient in recipients: if '@' not in recipient.orig.addrstr: # Avoid answering to bounches if not recipient.orig.addrstr == '<>': addrs.append(recipient.orig.addrstr[:-1] + '@' + recipient.orig.domain + '>') else: # Avoid answering to bounches if not recipient.orig.addrstr == '<#@[]>': addrs.append(recipient.orig.addrstr) for line in self.lines[1:]: if not isContent: try: field, value = line.split(':', 1) except ValueError: continue if field.lower() != 'content': post[field.lower()] = value.strip() else: isContent = True ctnt_buff.append(value.strip()) else: ctnt_buff.append(line.strip()) post['content'] = '\n'.join(ctnt_buff) for header in 'content author category title'.split(): if not post.has_key(header): self.lines = [] return defer.fail(None) if post.has_key('id'): oldpost = IBlog(self.store).getOne(int(post['id'])) oldpost.author = unicode(post['author']) oldpost.title = unicode(post['title']) oldpost.category = unicode(post['category']) oldpost.content = unicode(post['content']) oldpost.setModified() action = 'modified' id = post['id'] else: newid = IBlog(self.store).getNextId() newPost = Post(store=self.store, id=newid, author=unicode(post['author']), title=unicode(post['title']), category=unicode(post['category']), content=unicode(post['content'])) IBlog(self.store).addNewPost(newPost) action = 'added' id = newid self.lines = [] msg = """From: <%s> Subject: Successfull Post Post number %s successfully %s """ % (FROM, id, action) return self.sendNotify(addrs, msg)