Exemplo n.º 1
0
 def add_meta(uid, data_dic, extinfo={}):
     if len(uid) < 4:
         return False
     title = data_dic['title'].strip()
     if len(title) < 2:
         return False
     g_Post.create(
         uid=uid,
         title=title,
         keywords=','.join(
             [x.strip() for x in data_dic['keywords'].split(',')]),
         time_create=tools.timestamp(),
         time_update=tools.timestamp(),
         create_time=tools.timestamp(),
         date=datetime.now(),
         cnt_md=data_dic['cnt_md'].strip(),
         logo=data_dic['logo'].strip(),
         cnt_html=tools.markdown2html(data_dic['cnt_md']),
         view_count=0,
         extinfo=extinfo,
         user_name=data_dic['user_name'],
         valid=data_dic['valid'] if 'valid' in data_dic else 1,
         kind=data_dic['kind'],
     )
     return uid
Exemplo n.º 2
0
    def addata_init(data_dic, ext_dic={}):
        if len(data_dic['sig']) < 4:
            return False
        title = data_dic['title'].strip()
        if len(title) < 2:
            return False

        postinfo = MPost.get_by_uid(data_dic['sig'])
        if postinfo:

            if data_dic['title'] == postinfo.title and data_dic[
                    'kind'] == postinfo.kind:
                pass
            else:
                MPost.modify_init(data_dic['sig'], data_dic)
        else:
            time_stamp = int(time.time())

            g_Post.create(uid=data_dic['sig'],
                          title=data_dic['title'],
                          create_time=time_stamp,
                          time_update=time_stamp,
                          cnt_md=data_dic['cnt_md'],
                          cnt_html=data_dic['cnt_html'],
                          date=datetime.now(),
                          keywords=data_dic['keywords'],
                          extinfo=ext_dic)
Exemplo n.º 3
0
    def insert_data(self, id_post, post_data):
        title = post_data['title'].strip()
        if len(title) < 2:
            return False

        cur_rec = self.get_by_id(id_post)
        if cur_rec:
            return (False)

        entry = g_Post.create(
            title=title,
            date=datetime.datetime.now(),
            cnt_md=tornado.escape.xhtml_escape(post_data['cnt_md']),
            cnt_html=tools.markdown2html(post_data['cnt_md']),
            uid=id_post,
            time_create=post_data['time_create'] if 'time_create' in post_data else tools.timestamp(),
            time_update=post_data['time_update'] if 'time_update' in post_data else tools.timestamp(),
            user_name=post_data['user_name'],
            view_count=post_data['view_count'] if 'view_count' in post_data else 1,
            logo=post_data['logo'],
            keywords=post_data['keywords'] if 'keywords' in post_data else '',
            extinfo=post_data['extinfo'] if 'extinfo' in post_data else {},
            kind=post_data['kind'] if 'kind' in post_data else '1',
            valid=1,
        )
        return (entry.uid)
Exemplo n.º 4
0
    def create_post(post_uid, post_data):
        '''
        :param post_uid:
        :param post_data:
        :return:
        '''
        title = post_data['title'].strip()
        if len(title) < 2:
            return False

        cur_rec = MPost.get_by_uid(post_uid)
        if cur_rec:
            return False

        entry = g_Post.create(
            title=title,
            date=datetime.now(),
            cnt_md=tornado.escape.xhtml_escape(post_data['cnt_md'].strip()),
            cnt_html=tools.markdown2html(post_data['cnt_md']),
            uid=post_uid,
            time_create=(post_data['time_create']
                         if 'time_create' in post_data else tools.timestamp()),
            time_update=(post_data['time_update']
                         if 'time_update' in post_data else tools.timestamp()),
            user_name=post_data['user_name'],
            view_count=post_data['view_count']
            if 'view_count' in post_data else 1,
            logo=post_data['logo'],
            keywords=post_data['keywords'] if 'keywords' in post_data else '',
            extinfo=post_data['extinfo'] if 'extinfo' in post_data else {},
            kind=post_data['kind'] if 'kind' in post_data else '1',
            valid=1,
        )
        return entry.uid