except Exception, err: logging.error(traceback.format_exc()) logging.error('Catalog not exist, id %s' % book_id) return [1, '未找到该知识谱!'] if article_type == "blog": try: AF_Object = Blog(_id=article_id) if not AF_Object.is_posted: return [1, '该文章未发布!'] except Exception, err: logging.error(traceback.format_exc()) logging.error('%s not exist, id %s' % (article_type, article_id)) return [1, '未找到该文章!'] else: return [1, '暂时不支持!'] AF_Object.add_to_catalog(book, node_id) #book.recommend_blog_to(url_query["id"], AF_Object) restr = '成功添加到知识谱<a href="/book/%s" target="_blank">《%s》</a>的章节中!' % ( book_id, book.name) return [0, restr] def fun_recommended_to_book(user=None, book_id='', node_id='', article_url=''): if user is None or book_id == '' or node_id == '': return [1, '参数错误!'] if article_url == "": return [1, '请填写链接!'] try: book = Catalog(_id=book_id) except Exception, err: logging.error(traceback.format_exc())
except Exception, err: logging.error(traceback.format_exc()) logging.error("Catalog not exist, id %s" % book_id) return [1, "未找到该知识谱!"] if article_type == "blog": try: AF_Object = Blog(_id=article_id) if not AF_Object.is_posted: return [1, "该文章未发布!"] except Exception, err: logging.error(traceback.format_exc()) logging.error("%s not exist, id %s" % (article_type, article_id)) return [1, "未找到该文章!"] else: return [1, "暂时不支持!"] AF_Object.add_to_catalog(book, node_id) # book.recommend_blog_to(url_query["id"], AF_Object) restr = '成功添加到知识谱<a href="/book/%s" target="_blank">《%s》</a>的章节中!' % (book_id, book.name) return [0, restr] def fun_recommended_to_book(user=None, book_id="", node_id="", article_url=""): if user is None or book_id == "" or node_id == "": return [1, "参数错误!"] if article_url == "": return [1, "请填写链接!"] try: book = Catalog(_id=book_id) except Exception, err: logging.error(traceback.format_exc()) logging.error("Catalog not exist, id %s" % book_id)