示例#1
0
文件: AF_Base.py 项目: deju/afw_old
    def get_all_lib(self, blog):
        self.picture_lib = []
        self.equation_lib = []
        self.langcode_lib = []
        self.tableform_lib = []
        self.reference_lib = []
        
        img_lib = blog.picture_lib
        math_lib = blog.equation_lib
        code_lib = blog.langcode_lib
        table_lib = blog.tableform_lib
        ref_lib = blog.reference_lib

        pic_con = Picture.get_instances('_id', img_lib.load_all().values())
        ref_con = Reference.get_instances('_id', ref_lib.load_all().values())
        code_con = Langcode.get_instances('_id', code_lib.load_all().values())
        math_con = Equation.get_instances('_id', math_lib.load_all().values())
        table_con = Tableform.get_instances('_id', table_lib.load_all().values())

        for iii in pic_con:
            self.picture_lib.append({'alias':iii.alias, 'name':iii.name, 'thumb_name':iii.thumb_name})
        for iii in ref_con:
            self.reference_lib.append({'alias':iii.alias, 'name':iii.name, 'url':iii.url, 'body':iii.body})
        for iii in code_con:
            self.langcode_lib.append({'alias':iii.alias, 'name':iii.name, 'lang':iii.lang, 'body':iii.code})
        for iii in math_con:
            self.equation_lib.append({'alias':iii.alias, 'name':iii.name, 'mode':iii.mode, 'body':iii.equation})
        for iii in table_con:
            self.tableform_lib.append({'alias':iii.alias, 'name':iii.name, 'body':iii.tableform})   
示例#2
0
    def get_all_lib(self, blog):
        self.picture_lib = []
        self.equation_lib = []
        self.langcode_lib = []
        self.tableform_lib = []
        self.reference_lib = []

        img_lib = blog.picture_lib
        math_lib = blog.equation_lib
        code_lib = blog.langcode_lib
        table_lib = blog.tableform_lib
        ref_lib = blog.reference_lib

        pic_con = Picture.get_instances('_id', img_lib.load_all().values())
        ref_con = Reference.get_instances('_id', ref_lib.load_all().values())
        code_con = Langcode.get_instances('_id', code_lib.load_all().values())
        math_con = Equation.get_instances('_id', math_lib.load_all().values())
        table_con = Tableform.get_instances('_id',
                                            table_lib.load_all().values())

        for iii in pic_con:
            self.picture_lib.append({
                'alias': iii.alias,
                'name': iii.name,
                'thumb_name': iii.thumb_name
            })
        for iii in ref_con:
            self.reference_lib.append({
                'alias': iii.alias,
                'name': iii.name,
                'url': iii.url,
                'body': iii.body
            })
        for iii in code_con:
            self.langcode_lib.append({
                'alias': iii.alias,
                'name': iii.name,
                'lang': iii.lang,
                'body': iii.code
            })
        for iii in math_con:
            self.equation_lib.append({
                'alias': iii.alias,
                'name': iii.name,
                'mode': iii.mode,
                'body': iii.equation
            })
        for iii in table_con:
            self.tableform_lib.append({
                'alias': iii.alias,
                'name': iii.name,
                'body': iii.tableform
            })
示例#3
0
def fun_get_article_src(target):
    # target is blog or about 
    pic_lib_result = []
    math_lib_result = []
    code_lib_result = []
    table_lib_result = []
    ref_lib_result = []

    img_lib = target.picture_lib
    math_lib = target.equation_lib
    code_lib = target.langcode_lib
    table_lib = target.tableform_lib
    ref_lib = target.reference_lib

    pic_con = Picture.get_instances('_id', img_lib.load_all().values())
    ref_con = Reference.get_instances('_id', ref_lib.load_all().values())
    code_con = Langcode.get_instances('_id', code_lib.load_all().values())
    math_con = Equation.get_instances('_id', math_lib.load_all().values())
    table_con = Tableform.get_instances('_id', table_lib.load_all().values())

    #tmp = {'alias':}
    for iii in pic_con:
        pic_lib_result.append({'alias':iii.alias, 'name':iii.name, 'thumb_name':iii.thumb_name})
    #print pic_lib_result

    for iii in ref_con:
        ref_lib_result.append({'alias':iii.alias, 'name':iii.name, 'url':iii.url, 'body':iii.body})
    #print ref_lib_result

    for iii in code_con:
        code_lib_result.append({'alias':iii.alias, 'name':iii.name, 'lang':iii.lang, 'body':iii.code})
    #print code_lib_result

    for iii in math_con:
        math_lib_result.append({'alias':iii.alias, 'name':iii.name, 'mode':iii.mode, 'body':iii.equation})
    #print math_lib_result

    for iii in table_con:
        table_lib_result.append({'alias':iii.alias, 'name':iii.name, 'body':iii.tableform})
    #print table_lib_result

    return [pic_lib_result, ref_lib_result, code_lib_result, math_lib_result, table_lib_result]
示例#4
0
    article_id = str(AF_Object._id)

    rstring = {'isnew':isnew, 'article':article_id, 'alias':''}

    if src_type == 'reference':
        ref_lib =  AF_Object.reference_lib
        alias = get_max_alias(ref_lib.load_all().keys())
        new_ref = Reference()
        new_ref.set_propertys(**{'alias':alias, 'url':source, 'name':title, 'body':body})
        ref_lib.add_obj(new_ref)
        rstring['alias'] = alias
        return [0, rstring]
    elif src_type == 'code':
        code_lib = AF_Object.langcode_lib
        alias = get_max_alias(code_lib.load_all().keys())
        new_code = Langcode()
        new_code.set_propertys(**{'alias':alias, 'name':title, 'code':body, 'lang':code_type})
        code_lib.add_obj(new_code)
        rstring['alias'] = alias
        return [0, rstring]
    elif src_type == 'math':
        math_lib = AF_Object.equation_lib
        alias = get_max_alias(math_lib.load_all().keys())
        new_math = Equation()
        new_math.set_propertys(**{'alias':alias, 'name':title, 'equation':body, 'mode':math_type})
        math_lib.add_obj(new_math)
        rstring['alias'] = alias
        return [0, rstring]
    elif src_type == 'table':
        table_lib = AF_Object.tableform_lib
        alias = get_max_alias(table_lib.load_all().keys())
示例#5
0
from article.blog import Blog
from article.about import About
from article.comment import Comment
from article.reference import Reference
from article.tableform import Tableform
from article.langcode import Langcode

from tornado.escape import xhtml_unescape

blogs_all = [Blog(each) for each in Blog.datatype.find()]
comments_all = [Comment(each) for each in Comment.datatype.find()]
about_all = About.find()
ref_all = Reference.find()
table_all = Tableform.find()
code_all = Langcode.find()


for each in blogs_all + comments_all + about_all:
    each.abstract = xhtml_unescape(each.abstract)
    each.body = xhtml_unescape(each.body)

for each in ref_all:
    each.body = xhtml_unescape(each.body)

for each in code_all:
    each.code = xhtml_unescape(each.code)

for each in table_all:
    each.tableform = xhtml_unescape(each.tableform)
示例#6
0
#!/usr/bin/env python

from article.blog import Blog
from article.about import About
from article.comment import Comment
from article.reference import Reference
from article.tableform import Tableform
from article.langcode import Langcode

from tornado.escape import xhtml_unescape

blogs_all = [Blog(each) for each in Blog.datatype.find()]
comments_all = [Comment(each) for each in Comment.datatype.find()]
about_all = About.find()
ref_all = Reference.find()
table_all = Tableform.find()
code_all = Langcode.find()

for each in blogs_all + comments_all + about_all:
    each.abstract = xhtml_unescape(each.abstract)
    each.body = xhtml_unescape(each.body)

for each in ref_all:
    each.body = xhtml_unescape(each.body)

for each in code_all:
    each.code = xhtml_unescape(each.code)

for each in table_all:
    each.tableform = xhtml_unescape(each.tableform)
示例#7
0
     ref_lib = AF_Object.reference_lib
     alias = get_max_alias(ref_lib.load_all().keys())
     new_ref = Reference()
     new_ref.set_propertys(**{
         'alias': alias,
         'url': source,
         'name': title,
         'body': body
     })
     ref_lib.add_obj(new_ref)
     rstring['alias'] = alias
     return [0, rstring]
 elif src_type == 'code':
     code_lib = AF_Object.langcode_lib
     alias = get_max_alias(code_lib.load_all().keys())
     new_code = Langcode()
     new_code.set_propertys(**{
         'alias': alias,
         'name': title,
         'code': body,
         'lang': code_type
     })
     code_lib.add_obj(new_code)
     rstring['alias'] = alias
     return [0, rstring]
 elif src_type == 'math':
     math_lib = AF_Object.equation_lib
     alias = get_max_alias(math_lib.load_all().keys())
     new_math = Equation()
     new_math.set_propertys(**{
         'alias': alias,
示例#8
0
def fun_get_article_src(target):
    # target is blog or about
    pic_lib_result = []
    math_lib_result = []
    code_lib_result = []
    table_lib_result = []
    ref_lib_result = []

    img_lib = target.picture_lib
    math_lib = target.equation_lib
    code_lib = target.langcode_lib
    table_lib = target.tableform_lib
    ref_lib = target.reference_lib

    pic_con = Picture.get_instances('_id', img_lib.load_all().values())
    ref_con = Reference.get_instances('_id', ref_lib.load_all().values())
    code_con = Langcode.get_instances('_id', code_lib.load_all().values())
    math_con = Equation.get_instances('_id', math_lib.load_all().values())
    table_con = Tableform.get_instances('_id', table_lib.load_all().values())

    #tmp = {'alias':}
    for iii in pic_con:
        pic_lib_result.append({
            'alias': iii.alias,
            'name': iii.name,
            'thumb_name': iii.thumb_name
        })
    #print pic_lib_result

    for iii in ref_con:
        ref_lib_result.append({
            'alias': iii.alias,
            'name': iii.name,
            'url': iii.url,
            'body': iii.body
        })
    #print ref_lib_result

    for iii in code_con:
        code_lib_result.append({
            'alias': iii.alias,
            'name': iii.name,
            'lang': iii.lang,
            'body': iii.code
        })
    #print code_lib_result

    for iii in math_con:
        math_lib_result.append({
            'alias': iii.alias,
            'name': iii.name,
            'mode': iii.mode,
            'body': iii.equation
        })
    #print math_lib_result

    for iii in table_con:
        table_lib_result.append({
            'alias': iii.alias,
            'name': iii.name,
            'body': iii.tableform
        })
    #print table_lib_result

    return [
        pic_lib_result, ref_lib_result, code_lib_result, math_lib_result,
        table_lib_result
    ]