Example #1
0
 def add_or_update(self, charid, post_data):
     if self.get_by_id(charid):
         tt = self.get_by_id(charid)
         entry = self.tab.update(
             title = post_data['title'][0],
             keywords = post_data['keywords'][0],
             cnt_md = post_data['cnt_md'][0],
             cnt_html = tools.markdown2html(post_data['cnt_md'][0]),
             time_update = int(time.time()),
         ).where(self.tab.uid == tt.uid)
         entry.execute()
     else:
         entry = self.tab.create(
             uid = charid,
             title = post_data['title'][0],
             keywords = post_data['keywords'][0],
             date=datetime.now(),
             view_count = 1,
             time_run = 1,
             time_create = 1,
             time_update = 1,
             html_path = '',
             cnt_md = post_data['cnt_md'][0],
             cnt_html = tools.markdown2html(post_data['cnt_md'][0]),
             app  = charid,
             timestamp = int(time.time()),
         )
Example #2
0
 def add_or_update(self, charid, post_data):
     if self.get_by_id(charid):
         tt = self.get_by_id(charid)
         entry = self.tab.update(
             title=post_data['title'][0],
             keywords=post_data['keywords'][0],
             cnt_md=post_data['cnt_md'][0],
             cnt_html=tools.markdown2html(post_data['cnt_md'][0]),
             time_update=int(time.time()),
         ).where(self.tab.uid == tt.uid)
         entry.execute()
     else:
         entry = self.tab.create(
             uid=charid,
             title=post_data['title'][0],
             keywords=post_data['keywords'][0],
             date=datetime.now(),
             view_count=1,
             time_run=1,
             time_create=1,
             time_update=1,
             html_path='',
             cnt_md=post_data['cnt_md'][0],
             cnt_html=tools.markdown2html(post_data['cnt_md'][0]),
             app=charid,
             timestamp=int(time.time()),
         )
Example #3
0
 def modify_meta(self, data_dic):
     '''
     手工修改的。
     :param uid:
     :param data_dic:
     :return:
     '''
     uid = data_dic['uid'][0]
     entry = self.tab_app.update(
         title=data_dic['title'][0],
         keywords=data_dic['keywords'][0],
         desc=data_dic['desc'][0],
         update_time=int(time.time()),
         date=datetime.now(),
         cnt_md=data_dic['cnt_md'][0],
         cnt_html=tools.markdown2html(data_dic['cnt_md'][0]),
         memo=data_dic['memo'][0],
         lat=data_dic['lat'][0],
         lon=data_dic['lon'][0],
         zoom_max=data_dic['zoom_max'][0],
         zoom_min=data_dic['zoom_min'][0],
         zoom_current=data_dic['zoom_current'][0],
     ).where(self.tab_app.uid == uid)
     entry.execute()
     return (uid)
Example #4
0
    def insert_data(self, post_data):
        title = post_data['title'][0]
        uu = self.get_by_wiki(title)
        if uu is None:
            pass
        else:
            return (False)
        if 'id_spec' in post_data:
            id_spec = post_data['id_spec'][0]
        else:
            id_spec = 0
        if post_data['src_type'][0] == '1':
            cnt_html = tools.rst2html(post_data['cnt_md'][0])
        else:
            cnt_html = tools.markdown2html(post_data['cnt_md'][0])

        entry = CabWiki.create(title=post_data['title'][0],
                               date=datetime.datetime.now(),
                               cnt_html=cnt_html,
                               uid=tools.get_uu8d(),
                               time_create=time.time(),
                               user_name=post_data['user_name'],
                               cnt_md=tornado.escape.xhtml_escape(
                                   post_data['cnt_md'][0]),
                               time_update=time.time(),
                               view_count=1,
                               src_type=post_data['src_type'][0])
        return (entry.uid)
Example #5
0
    def insert_data(self, post_data):
        slug = post_data['slug'][0]
        uu = self.get_by_slug(slug)
        if uu is None:
            pass
        else:
            return (False)
        if 'id_spec' in post_data:
            id_spec = int(post_data['id_spec'][0])
        else:
            id_spec = 0

        try:
            entry = CabPage.create(
                title=post_data['title'][0],
                date=datetime.datetime.now(),
                slug=slug,
                cnt_html= tools.markdown2html(post_data['cnt_md'][0]),
                time_create=time.time(),
                id_user='',
                cnt_md=tornado.escape.xhtml_escape(post_data['cnt_md'][0]),
                time_update=time.time(),
                view_count=1,
            )
        except:
            return ''
        return slug
    def insert_data(self, id_post, post_data):

        uu = self.get_by_id(id_post)
        if uu is None:
            pass
        else:
            return (False)
        if 'id_spec' in post_data:
            id_spec = post_data['id_spec'][0]
        else:
            id_spec = 0
        if 'src_type' in post_data and post_data['src_type'][0] == '1':
            cnt_html = tools.rst2html(post_data['cnt_md'][0])
        else:
            cnt_html = tools.markdown2html(post_data['cnt_md'][0])

        entry = CabPost.create(
            title=post_data['title'][0],
            date=datetime.datetime.now(),
            cnt_html=cnt_html,
            uid=id_post,
            time_create=time.time(),
            user_name=post_data['user_name'],
            cnt_md=tornado.escape.xhtml_escape(post_data['cnt_md'][0]),
            time_update=time.time(),
            view_count=1,
            id_spec=id_spec,
            logo=post_data['logo'][0],
            keywords=post_data['keywords'][0],
            src_type=post_data['src_type'][0] if ('src_type' in post_data) else 0
        )
        return (entry.uid)
Example #7
0
 def modify_meta(self, data_dic):
     '''
     手工修改的。
     :param uid:
     :param data_dic:
     :return:
     '''
     uid = data_dic['uid'][0]
     entry = self.tab_app.update(
         title=data_dic['title'][0],
         keywords = data_dic['keywords'][0],
         desc=data_dic['desc'][0],
         update_time=int(time.time()),
         date=datetime.now(),
         cnt_md = data_dic['cnt_md'][0],
         cnt_html = tools.markdown2html(data_dic['cnt_md'][0]),
         memo = data_dic['memo'][0],
         lat = data_dic['lat'][0],
         lon = data_dic['lon'][0],
         zoom_max = data_dic['zoom_max'][0],
         zoom_min = data_dic['zoom_min'][0],
         zoom_current = data_dic['zoom_current'][0],
     ).where(self.tab_app.uid == uid)
     entry.execute()
     return (uid)
Example #8
0
    def insert_data(self, id_post, post_data):
        uu = self.get_by_id(id_post)
        if uu is None:
            pass
        else:
            return (False)
        if 'id_spec' in post_data:
            id_spec = post_data['id_spec'][0]
        else:
            id_spec = 0
        if 'src_type' in post_data and post_data['src_type'][0] == '1':
            cnt_html = tools.rst2html(post_data['cnt_md'][0])
        else:
            cnt_html = tools.markdown2html(post_data['cnt_md'][0])

        entry = CabPost.create(title=post_data['title'][0],
                               date=datetime.datetime.now(),
                               cnt_html=cnt_html,
                               uid=id_post,
                               time_create=time.time(),
                               user_name=post_data['user_name'],
                               cnt_md=tornado.escape.xhtml_escape(
                                   post_data['cnt_md'][0]),
                               time_update=time.time(),
                               view_count=1,
                               id_spec=id_spec,
                               logo=post_data['logo'][0],
                               keywords=post_data['keywords'][0],
                               src_type=post_data['src_type'][0] if
                               ('src_type' in post_data) else 0)
        return (id_post)
Example #9
0
    def update(self, uid, post_data, update_time=False):

        cnt_html = tools.markdown2html(post_data['cnt_md'][0])

        try:
            if update_time:
                entry2 = CabPost.update(
                    time_update=time.time()
                ).where(CabPost.uid == uid)
                entry2.execute()
        except:
            pass

        try:
            entry = CabPost.update(
                title=post_data['title'][0],
                cnt_html=cnt_html,
                user_name=post_data['user_name'],
                cnt_md=tornado.escape.xhtml_escape(post_data['cnt_md'][0]),
                logo=post_data['logo'][0],
                keywords=post_data['keywords'][0],
            ).where(CabPost.uid == uid)
            entry.execute()
        except:
            return  False
Example #10
0
    def insert_data(self, post_data):
        title = post_data["title"][0]
        uu = self.get_by_wiki(title)
        if uu is None:
            pass
        else:
            return False

        if post_data["src_type"][0] == "1":
            cnt_html = tools.rst2html(post_data["cnt_md"][0])
        else:
            cnt_html = tools.markdown2html(post_data["cnt_md"][0])

        entry = CabWiki.create(
            title=post_data["title"][0],
            date=datetime.datetime.now(),
            cnt_html=cnt_html,
            uid=tools.get_uu8d(),
            time_create=tools.timestamp(),
            user_name=post_data["user_name"],
            cnt_md=tornado.escape.xhtml_escape(post_data["cnt_md"][0]),
            time_update=tools.timestamp(),
            view_count=1,
            src_type=post_data["src_type"][0],
        )
        return entry.uid
Example #11
0
    def insert_data(self, post_data):
        title = post_data['title'][0]
        uu = self.get_by_wiki(title)
        if uu is None:
            pass
        else:
            return (False)
        if 'id_spec' in post_data:
            id_spec = post_data['id_spec'][0]
        else:
            id_spec = 0
        if post_data['src_type'][0] == '1':
            cnt_html = tools.rst2html(post_data['cnt_md'][0])
        else:
            cnt_html = tools.markdown2html(post_data['cnt_md'][0])

        entry = CabWiki.create(
            title=post_data['title'][0],
            date=datetime.datetime.now(),
            cnt_html=cnt_html,
            uid=tools.get_uu8d(),
            time_create=time.time(),
            user_name=post_data['user_name'],
            cnt_md=tornado.escape.xhtml_escape(post_data['cnt_md'][0]),
            time_update=time.time(),
            view_count=1,
            src_type=post_data['src_type'][0]
        )
        return (entry.uid)
Example #12
0
 def update(self, slug, post_data):
     entry = CabPage.update(
         title=post_data['title'][0],
         date=datetime.datetime.now(),
         cnt_html=tools.markdown2html(post_data['cnt_md'][0]),
         id_user='',
         cnt_md=tornado.escape.xhtml_escape(post_data['cnt_md'][0]),
         time_update=time.time(),
     ).where(CabPage.slug == slug)
     entry.execute()
Example #13
0
 def update(self, slug, post_data):
     entry = CabPage.update(
         title=post_data['title'][0],
         date=datetime.datetime.now(),
         cnt_html=tools.markdown2html(post_data['cnt_md'][0]),
         id_user='',
         cnt_md=tornado.escape.xhtml_escape(post_data['cnt_md'][0]),
         time_update=time.time(),
     ).where(CabPage.slug == slug)
     entry.execute()
Example #14
0
    def update(self, uid, post_data):

        cnt_html = tools.markdown2html(post_data['cnt_md'][0])

        entry = CabWiki.update(
            title=post_data['title'][0],
            date=datetime.datetime.now(),
            cnt_html=cnt_html,
            user_name=post_data['user_name'],
            cnt_md=tornado.escape.xhtml_escape(post_data['cnt_md'][0]),
            time_update=tools.timestamp(),
        ).where(CabWiki.uid == uid)
        entry.execute()
Example #15
0
    def update(self, uid, post_data):


        cnt_html = tools.markdown2html(post_data['cnt_md'][0])

        entry = CabWiki.update(
            title=post_data['title'][0],
            date=datetime.datetime.now(),
            cnt_html=cnt_html,
            user_name=post_data['user_name'],
            cnt_md=tornado.escape.xhtml_escape(post_data['cnt_md'][0]),
            time_update=tools.timestamp(),
        ).where(CabWiki.uid == uid)
        entry.execute()
Example #16
0
    def insert_data(self, post_data):

        uid = tools.get_uuid()
        try:
            CabReply.create(
                uid=uid,
                user_name=post_data['user_name'],
                create_user_id=post_data['user_id'],
                timestamp=tools.timestamp(),
                date=datetime.datetime.now(),
                cnt_md=post_data['cnt_md'][0],
                cnt_html=tools.markdown2html(post_data['cnt_md'][0]),
                vote=0,
            )
            return (uid)
        except:
            return False
Example #17
0
    def insert_data(self, post_data):

        uid = tools.get_uuid()
        try:
            CabReply.create(
                uid=uid,
                user_name=post_data['user_name'],
                create_user_id=post_data['user_id'],
                timestamp=tools.timestamp(),
                date=datetime.datetime.now(),
                cnt_md=post_data['cnt_md'][0],
                cnt_html=tools.markdown2html(post_data['cnt_md'][0]),
                vote=0,
            )
            return (uid)
        except:
            return False
Example #18
0
    def update(self, uid, post_data):

        print(post_data["src_type"][0])
        if post_data["src_type"][0] == "1":
            cnt_html = tools.rst2html(post_data["cnt_md"][0])
        else:
            cnt_html = tools.markdown2html(post_data["cnt_md"][0])

        entry = CabWiki.update(
            title=post_data["title"][0],
            date=datetime.datetime.now(),
            cnt_html=cnt_html,
            user_name=post_data["user_name"],
            cnt_md=tornado.escape.xhtml_escape(post_data["cnt_md"][0]),
            time_update=tools.timestamp(),
            src_type=post_data["src_type"][0],
        ).where(CabWiki.uid == uid)
        entry.execute()
Example #19
0
    def update(self, uid, post_data):


        print(post_data['src_type'][0])
        if post_data['src_type'][0] == '1':
            cnt_html = tools.rst2html(post_data['cnt_md'][0])
        else:
            cnt_html = tools.markdown2html(post_data['cnt_md'][0])

        entry = CabWiki.update(
            title=post_data['title'][0],
            date=datetime.datetime.now(),
            cnt_html=cnt_html,
            user_name=post_data['user_name'],
            cnt_md=tornado.escape.xhtml_escape(post_data['cnt_md'][0]),
            time_update=time.time(),
            src_type=post_data['src_type'][0]
        ).where(CabWiki.uid == uid)
        entry.execute()
Example #20
0
    def update(self, uid, post_data):

        print(post_data['src_type'][0])
        if post_data['src_type'][0] == '1':
            cnt_html = tools.rst2html(post_data['cnt_md'][0])
        else:
            cnt_html = tools.markdown2html(post_data['cnt_md'][0])

        entry = CabWiki.update(
            title=post_data['title'][0],
            date=datetime.datetime.now(),
            cnt_html=cnt_html,
            user_name=post_data['user_name'],
            cnt_md=tornado.escape.xhtml_escape(post_data['cnt_md'][0]),
            time_update=time.time(),
            # id_spec=id_spec,
            # logo=post_data['logo'][0],
            src_type=post_data['src_type'][0]).where(CabWiki.uid == uid)
        entry.execute()
Example #21
0
 def add_meta(self, data_dic):
     try:
         entry = self.tab_app.create(
             uid=data_dic['uid'][0],
             title=data_dic['title'][0],
             keywords=data_dic['keywords'][0],
             desc=data_dic['desc'][0],
             update_time=int(time.time()),
             date=datetime.now(),
             cnt_md=data_dic['cnt_md'][0],
             cnt_html=tools.markdown2html(data_dic['cnt_md'][0]),
             memo=data_dic['memo'][0],
             lat=data_dic['lat'][0],
             lon=data_dic['lon'][0],
             zoom_max=data_dic['zoom_max'][0],
             zoom_min=data_dic['zoom_min'][0],
             zoom_current=data_dic['zoom_current'][0],
         )
     except:
         return False
Example #22
0
 def add_meta(self, data_dic):
     try:
         entry = self.tab_app.create(
             uid=data_dic['uid'][0],
             title=data_dic['title'][0],
             keywords=data_dic['keywords'][0],
             desc=data_dic['desc'][0],
             update_time=int(time.time()),
             date=datetime.now(),
             cnt_md=data_dic['cnt_md'][0],
             cnt_html=tools.markdown2html(data_dic['cnt_md'][0]),
             memo=data_dic['memo'][0],
             lat=data_dic['lat'][0],
             lon=data_dic['lon'][0],
             zoom_max=data_dic['zoom_max'][0],
             zoom_min=data_dic['zoom_min'][0],
             zoom_current=data_dic['zoom_current'][0],
         )
     except:
         return False
Example #23
0
    def update(self, uid, post_data, update_time=False):

        if 'id_spec' in post_data:
            id_spec = post_data['id_spec'][0]
        else:
            id_spec = 0

        if 'src_type' in post_data and post_data['src_type'][0] == '1':
            cnt_html = tools.rst2html(post_data['cnt_md'][0])
        else:
            cnt_html = tools.markdown2html(post_data['cnt_md'][0])

        if update_time == True:
            entry = CabUser2Reply.update(
                title=post_data['title'][0],
                date=datetime.datetime.now(),
                cnt_html=cnt_html,
                user_name=post_data['user_name'],
                cnt_md=tornado.escape.xhtml_escape(post_data['cnt_md'][0]),
                time_update=time.time(),
                id_spec=id_spec,
                logo=post_data['logo'][0],
                keywords=post_data['keywords'][0],
                src_type=post_data['src_type'][0] if
                ('src_type' in post_data) else 0).where(
                    CabUser2Reply.uid == uid)
        else:
            entry = CabUser2Reply.update(
                title=post_data['title'][0],
                # date=datetime.datetime.now(),
                cnt_html=cnt_html,
                user_name=post_data['user_name'],
                cnt_md=tornado.escape.xhtml_escape(post_data['cnt_md'][0]),
                # time_update=time.time(),
                id_spec=id_spec,
                logo=post_data['logo'][0],
                keywords=post_data['keywords'][0],
                src_type=post_data['src_type'][0] if
                ('src_type' in post_data) else 0).where(
                    CabUser2Reply.uid == uid)
        entry.execute()
Example #24
0
    def insert_data(self, post_data):
        title = post_data['title'][0]
        uu = self.get_by_wiki(title)
        if uu is None:
            pass
        else:
            return (False)

        cnt_html = tools.markdown2html(post_data['cnt_md'][0])

        entry = CabWiki.create(
            title=post_data['title'][0],
            date=datetime.datetime.now(),
            cnt_html=cnt_html,
            uid=tools.get_uu8d(),
            time_create=tools.timestamp(),
            user_name=post_data['user_name'],
            cnt_md=tornado.escape.xhtml_escape(post_data['cnt_md'][0]),
            time_update=tools.timestamp(),
            view_count=1,
        )
        return (entry.uid)
Example #25
0
    def update(self, uid, post_data, update_time=False):

        if 'id_spec' in post_data:
            id_spec = post_data['id_spec'][0]
        else:
            id_spec = 0

        if 'src_type' in post_data and post_data['src_type'][0] == '1':
            cnt_html = tools.rst2html(post_data['cnt_md'][0])
        else:
            cnt_html = tools.markdown2html(post_data['cnt_md'][0])

        if update_time:
            entry = CabVoter2Reply.update(
                title=post_data['title'][0],
                date=datetime.datetime.now(),
                cnt_html=cnt_html,
                user_name=post_data['user_name'],
                cnt_md=tornado.escape.xhtml_escape(post_data['cnt_md'][0]),
                time_update=time.time(),
                id_spec=id_spec,
                logo=post_data['logo'][0],
                keywords=post_data['keywords'][0],
                src_type=post_data['src_type'][0] if
                ('src_type' in post_data) else 0).where(
                    CabVoter2Reply.uid == uid)
        else:
            entry = CabVoter2Reply.update(
                title=post_data['title'][0],
                cnt_html=cnt_html,
                user_name=post_data['user_name'],
                cnt_md=tornado.escape.xhtml_escape(post_data['cnt_md'][0]),
                id_spec=id_spec,
                logo=post_data['logo'][0],
                keywords=post_data['keywords'][0],
                src_type=post_data['src_type'][0] if
                ('src_type' in post_data) else 0).where(
                    CabVoter2Reply.uid == uid)
        entry.execute()
Example #26
0
    def insert_data(self, post_data):
        slug = post_data['slug'][0]
        uu = self.get_by_slug(slug)
        if uu is None:
            pass
        else:
            return (False)

        try:
            CabPage.create(
                title=post_data['title'][0],
                date=datetime.datetime.now(),
                slug=slug,
                cnt_html=tools.markdown2html(post_data['cnt_md'][0]),
                time_create=time.time(),
                id_user='',
                cnt_md=tornado.escape.xhtml_escape(post_data['cnt_md'][0]),
                time_update=time.time(),
                view_count=1,
            )
            return slug
        except:
            return ''
Example #27
0
    def insert_data(self, post_data):
        title = post_data['title'][0]
        uu = self.get_by_wiki(title)
        if uu is None:
            pass
        else:
            return (False)


        cnt_html = tools.markdown2html(post_data['cnt_md'][0])

        entry = CabWiki.create(
            title=post_data['title'][0],
            date=datetime.datetime.now(),
            cnt_html=cnt_html,
            uid=tools.get_uu8d(),
            time_create=tools.timestamp(),
            user_name=post_data['user_name'],
            cnt_md=tornado.escape.xhtml_escape(post_data['cnt_md'][0]),
            time_update=tools.timestamp(),
            view_count=1,
        )
        return (entry.uid)
Example #28
0
    def insert_data(self, id_post, post_data):

        uu = self.get_by_id(id_post)
        if uu is None:
            pass
        else:
            return (False)

        cnt_html = tools.markdown2html(post_data['cnt_md'][0])

        entry = CabPost.create(
            title=post_data['title'][0],
            date=datetime.datetime.now(),
            cnt_html=cnt_html,
            uid=id_post,
            time_create=time.time(),
            user_name=post_data['user_name'],
            cnt_md=tornado.escape.xhtml_escape(post_data['cnt_md'][0]),
            time_update=time.time(),
            view_count=1,
            logo=post_data['logo'][0],
            keywords=post_data['keywords'][0],
        )
        return (entry.uid)
Example #29
0
    def update(self, uid, post_data, update_time=False):

        cnt_html = tools.markdown2html(post_data['cnt_md'][0])

        try:
            if update_time:
                entry2 = CabPost.update(time_update=time.time()).where(
                    CabPost.uid == uid)
                entry2.execute()
        except:
            pass

        try:
            entry = CabPost.update(
                title=post_data['title'][0],
                cnt_html=cnt_html,
                user_name=post_data['user_name'],
                cnt_md=tornado.escape.xhtml_escape(post_data['cnt_md'][0]),
                logo=post_data['logo'][0],
                keywords=post_data['keywords'][0],
            ).where(CabPost.uid == uid)
            entry.execute()
        except:
            return False
Example #30
0
    def insert_data(self, id_post, post_data):

        uu = self.get_by_id(id_post)
        if uu is None:
            pass
        else:
            return (False)

        cnt_html = tools.markdown2html(post_data['cnt_md'][0])

        entry = CabPost.create(
            title=post_data['title'][0],
            date=datetime.datetime.now(),
            cnt_html=cnt_html,
            uid=id_post,
            time_create=time.time(),
            user_name=post_data['user_name'],
            cnt_md=tornado.escape.xhtml_escape(post_data['cnt_md'][0]),
            time_update=time.time(),
            view_count=1,
            logo=post_data['logo'][0],
            keywords=post_data['keywords'][0],
        )
        return (entry.uid)