def create_thread(self, author, subject, message, readperm=1, attaches=[], tags=None): subject = escape(subject) xss = XssParser() xss.feed(message) message = xss.result at_users = xss.at_users print at_users hasAttach = (len(attaches)>0) post = Post(author=author, authorip=author.loginip, \ subject=subject, message=message, position=0, hasattach=hasAttach, \ readperm=readperm) thread = Thread(author=author, subject=subject, abstract="abstract", \ hasattach=hasAttach, tags=tags) try : thread.save() post.thread = thread post.save() except Exception, e: raise PostException(cause=e)
def reply_thread(self, author, tid, subject, message, readperm=1, attaches=[]): subject = escape(subject) xss = XssParser() xss.feed(message) message = xss.result at_users = xss.at_users print at_users hasAttach = (len(attaches)>0) qt = Thread.objects.filter(tid=tid) if not qt.exists(): raise NoSuchThreadException(tid=tid) thread = qt.get() position = thread.maxposition try: thread.replied_by(author) post = Post(thread=thread, author=author, authorip=author.loginip, subject=subject, \ message=message, position=position, hasattach=hasAttach, readperm=readperm) post.save() except Exception, e: raise PostException(cause=e)