def add_meta(uid, data_dic, extinfo=None): if extinfo is None: extinfo = {} if len(uid) < 4: return False title = data_dic['title'].strip() if len(title) < 2: return False TabPost.create( uid=uid, title=title, keywords='', time_create=tools.timestamp(), time_update=tools.timestamp(), create_time=tools.timestamp(), date=datetime.now(), cnt_md=data_dic['cnt_md'].strip(), memo=data_dic['memo'] if 'memo' in data_dic else '', logo=data_dic['logo'].strip(), order=data_dic['order'] if 'order' in data_dic else '', 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
def addata_init(data_dic, ext_dic=None): if ext_dic is None: 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()) TabPost.create( uid=data_dic['sig'], title=data_dic['title'], create_time=time_stamp, time_update=time_stamp, cnt_md=data_dic['cnt_md'] if 'memo' in data_dic else '', memo=data_dic['memo'] if 'memo' in data_dic else '', cnt_html=data_dic['cnt_html'], date=datetime.now(), keywords='', extinfo=ext_dic)
def create_post(post_uid, post_data): ''' create the post. ''' 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 = TabPost.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'], memo=post_data['memo'] if 'memo' in post_data else '', order=post_data['order'] if 'order' in post_data else '', 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