• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python model.Link类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中model.Link的典型用法代码示例。如果您正苦于以下问题:Python Link类的具体用法?Python Link怎么用?Python Link使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Link类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: post

    def post(self):
        t_values = {}
        current_link_id = self.request.POST['current_link_id']
        link_title = self.request.POST['link_title']
        link_target = self.request.POST['link_target']
        link_sequence = self.request.POST['link_sequence']
        logging.info("LinkManager post: current_link_id = %s, link_title = %s, link_target = %s, link_sequence = %s" % (current_link_id, link_title, 'link_target', 'link_sequence'))

        if current_link_id:
            # edit existed link
            link = Link.get_by_id(long(current_link_id))
            link.title = link_title
            link.target = link_target
            link.sequence = long(link_sequence)
            link.put()
            t_values['alert_message'] = "link %s has been updated" % (link.title)
        else:
            # create new link
            link = Link(title=link_title, target=link_target, sequence=long(link_sequence))
            link.put()
            t_values['alert_message'] = "link %s has been added" % (link.title)

        # find all links
        links = Link.all().order("-date")
        t_values["links"] = links
        return self.response.out.write(render_template("links.html", t_values, "", True))
开发者ID:loongw,项目名称:another-gae-blog,代码行数:26,代码来源:admin.py


示例2: post

 def post(self, secret=""):
     data = (self.get_argument("data", ""),)
     if id and data and secret:
         if secret == getAttr("MOVE_SECRET"):
             Link.set_link(encode_special_txt(data[0]))
             return self.write("1")
     return self.write("Fail")
开发者ID:yobin,项目名称:saepy-log,代码行数:7,代码来源:admin.py


示例3: post

 def post(self):
     action = self.param('action')
     name,url = (self.request.get(item) for item in ('linkName', 'linkURL'))
     if(action == 'edit'):
         key = self.param('id')
         link = Link.get_by_id(int(key))
         link.linkName = name
         link.linkURL = url
     else:
         link = Link(linkName=name,linkURL=url)
     link.put()
     self.redirect('/admin/links')   
     return  
开发者ID:sunruijia,项目名称:simblog,代码行数:13,代码来源:blog.py


示例4: addNewLink

def addNewLink(originalLink):
    session = scoped_session(SessionFactory)
    link = Link(originalLink)
    session.add(link)
    session.flush()
    link.shortLink = makeMiniature(int(link.id))
    session.commit()
    session.remove()
    result = {
        'request_id': link.id,
        'short_url': request.url_root.encode() + link.shortLink
    }
    return 201, result
开发者ID:Polyhy,项目名称:miniature-spoon,代码行数:13,代码来源:controller.py


示例5: get

    def get(self):
        link = Link(title="linkx1", target="http://baidu.com", sequence=9)
        link.put()

        link = Link(title="linkx2", target="http://baidu.com", sequence=9)
        link.put()

        link = Link(title="linkx3", target="http://baidu.com", sequence=9)
        link.put()
        return self.response.out.write(render_template("index.html", {}, "basic", False))
开发者ID:loongw,项目名称:another-gae-blog,代码行数:10,代码来源:weblog.py


示例6: get

    def get(self, name = ''):
        objs = Category.get_cat_page_posts(name, 1)

        catobj = Category.get_cat_by_name(name)
        if catobj:
            pass
        else:
            self.redirect(BASE_URL)
            return

        allpost =  catobj.id_num
        allpage = allpost/EACH_PAGE_POST_NUM
        if allpost%EACH_PAGE_POST_NUM:
            allpage += 1

        output = self.render('index.html', {
            'title': "%s - %s"%( catobj.name, getAttr('SITE_TITLE')),
            'keywords':catobj.name,
            'description':getAttr('SITE_DECR'),
            'objs': objs,
            'cats': Category.get_all_cat_name(),
            'tags': Tag.get_hot_tag_name(),
            'archives': Archive.get_all_archive_name(),
            'page': 1,
            'allpage': allpage,
            'listtype': 'cat',
            'name': name,
            'namemd5': md5(name.encode('utf-8')).hexdigest(),
            'comments': Comment.get_recent_comments(),
            'links':Link.get_all_links(),
            'isauthor':self.isAuthor(),
            'Totalblog':get_count('Totalblog',NUM_SHARDS,0),
        },layout='_layout.html')
        self.write(output)
        return output
开发者ID:yangzilong1986,项目名称:saepy-log,代码行数:35,代码来源:blog.py


示例7: update_basic_info

	def update_basic_info(
		update_categories=False,
		update_tags=False,
		update_links=False,
		update_comments=False,
		update_archives=False,
		update_pages=False):

		from model import Entry,Archive,Comment,Category,Tag,Link
		basic_info = ObjCache.get(is_basicinfo=True)
		if basic_info is not None:
			info = ObjCache.get_cache_value(basic_info.cache_key)
			if update_pages:
				info['menu_pages'] = Entry.all().filter('entrytype =','page')\
							.filter('published =',True)\
							.filter('entry_parent =',0)\
							.order('menu_order').fetch(limit=1000)
			if update_archives:
				info['archives'] = Archive.all().order('-year').order('-month').fetch(12)
			if update_comments:
				info['recent_comments'] = Comment.all().order('-date').fetch(5)
			if update_links:
				info['blogroll'] = Link.all().filter('linktype =','blogroll').fetch(limit=1000)
			if update_tags:
				info['alltags'] = Tag.all().order('-tagcount').fetch(limit=100)
			if update_categories:
				info['categories'] = Category.all().fetch(limit=1000)

			logging.debug('basic_info updated')
			basic_info.update(info)
开发者ID:fly2014,项目名称:XBLOG,代码行数:30,代码来源:cache.py


示例8: get

 def get(self, direction = 'next', page = '2', base_id = '1'):
     if page == '1':
         self.redirect(BASE_URL)
         return
     objs = Article.get_page_posts(direction, page, base_id)
     if objs:
         if direction == 'prev':
             objs.reverse()            
         fromid = objs[0].id
         endid = objs[-1].id
     else:
         fromid = endid = ''
     
     allpost =  Article.count_all_post()
     allpage = allpost/EACH_PAGE_POST_NUM
     if allpost%EACH_PAGE_POST_NUM:
         allpage += 1
     output = self.render('index.html', {
         'title': "%s - %s | Part %s"%(SITE_TITLE,SITE_SUB_TITLE, page),
         'keywords':KEYWORDS,
         'description':SITE_DECR,
         'objs': objs,
         'cats': Category.get_all_cat_name(),
         'tags': Tag.get_hot_tag_name(),
         'page': int(page),
         'allpage': allpage,
         'listtype': 'index',
         'fromid': fromid,
         'endid': endid,
         'comments': Comment.get_recent_comments(),
         'links':Link.get_all_links(),
     },layout='_layout.html')
     self.write(output)
     return output
开发者ID:bibodeng,项目名称:pyWeiXin_SAElog,代码行数:34,代码来源:blog.py


示例9: delete_link

 def delete_link(cls, id):
     link = LinkModel.get_by_id(id)
     if link:
         link.key.delete()
     linkDoc = cls.getDoc(id)
     if linkDoc:
         cls.removeDocById(id)
开发者ID:yiransheng,项目名称:yiransbookmark,代码行数:7,代码来源:docs.py


示例10: get

 def get(self):
     action = self.param('action')
     values = {'action':action}
     if(action == 'edit'):
         key = self.param('id')
         link = Link.get_by_id(int(key))
         values.update({'link':link})
     self.generateBasePage('manage/link.html', values)
     return
开发者ID:sunruijia,项目名称:simblog,代码行数:9,代码来源:blog.py


示例11: post

    def post(self):
        act = self.get_argument("act", "")
        id = self.get_argument("id", "")
        name = self.get_argument("name", "")
        sort = self.get_argument("sort", "0")
        url = self.get_argument("url", "")

        if name and url:
            params = {"id": id, "name": name, "url": url, "displayorder": sort}
            if act == "add":
                Link.add_new_link(params)

            if act == "edit":
                Link.update_link_edit(params)

            clear_cache_by_pathlist(["/"])

        self.redirect("%s/admin/links" % (BASE_URL))
        return
开发者ID:biggtfish,项目名称:pyWeiXin_SAElog,代码行数:19,代码来源:admin.py


示例12: post

    def post(self):
        act = self.get_argument("act",'')
        id = self.get_argument("id",'')
        name = self.get_argument("name",'')
        sort = self.get_argument("sort",'0')
        url = self.get_argument("url",'')

        if name and url:
            params = {'id': id, 'name': name, 'url': url, 'displayorder': sort}
            if act == 'add':
                Link.add_new_link(params)

            if act == 'edit':
                Link.update_link_edit(params)

            clear_cache_by_pathlist(['/'])

        self.redirect('%s/admin/links'% (BASE_URL))
        return
开发者ID:cylinderlee,项目名称:saepy-log,代码行数:19,代码来源:admin.py


示例13: save_link

 def save_link(cls, title, url, body="", tags=[], clicks=0, unread=True):
     url = norm(url)
     id = mmh3.hash(url)
     key = ndb.Key(LinkModel, id)
     domain = urlparse(url).netloc
     if len(domain)>4 and domain.startswith('www.'):
         domain = domain[4:]
     link = LinkModel( key = key,
                       title = title,
                       url = url,
                       domain = domain,
                       body = body,
                       tags = tags,
                       clicks = clicks,
                       unread = unread )
     link.put()
     id = str(link.id)
     doc = cls._buildDoc(id, title, body, domain, tags)
     cls.add(doc)
     return cls(doc, link)
开发者ID:yiransheng,项目名称:yiransbookmark,代码行数:20,代码来源:docs.py


示例14: get

    def get(self):
        act = self.get_argument("act",'')
        id = self.get_argument("id",'')

        obj = None
        if act == 'del':
            if id:
                Link.del_link_by_id(id)
                clear_cache_by_pathlist(['/'])
            self.redirect('%s/admin/links'% (BASE_URL))
            return
        elif act == 'edit':
            if id:
                obj = Link.get_link_by_id(id)
                clear_cache_by_pathlist(['/'])
        self.echo('admin_link.html', {
            'title': "管理友情链接",
            'objs': Link.get_all_links(),
            'obj': obj,
        },layout='_layout_admin.html')
开发者ID:cylinderlee,项目名称:saepy-log,代码行数:20,代码来源:admin.py


示例15: migrate

def migrate():
    LinkDoc.deleteAllInIndex()
    q = Link.query()
    links = q.fetch(65535)
    for link in links:
        title = link.title
        url = link.url
        tags = link.tags
        body = link.body
        link.key.delete()
        LinkDoc.save_link(title, url, body, tags)
开发者ID:yiransheng,项目名称:yiransbookmark,代码行数:11,代码来源:migration.py


示例16: get

    def get(self):
        act = self.get_argument("act", "")
        id = self.get_argument("id", "")

        obj = None
        if act == "del":
            if id:
                Link.del_link_by_id(id)
                clear_cache_by_pathlist(["/"])
            self.redirect("%s/admin/links" % (BASE_URL))
            return
        elif act == "edit":
            if id:
                obj = Link.get_link_by_id(id)
                clear_cache_by_pathlist(["/"])
        self.echo(
            "admin_link.html",
            {"title": "管理友情链接", "objs": Link.get_all_links(), "obj": obj},
            layout="_layout_admin.html",
        )
开发者ID:biggtfish,项目名称:pyWeiXin_SAElog,代码行数:20,代码来源:admin.py


示例17: get

    def get(self):
        # find stats for this blog
        stats = {}
        stats['posts'] = Entry.all().filter("entrytype =", "post").filter("is_external_page =", True).count()
        stats['pages'] = Entry.all().filter("entrytype =", "page").filter("is_external_page =", True).count()
        stats['comments'] = Comment.all().count()
        stats['categories'] = Category.all().count()
        stats['links'] = Link.all().count()

        t_values = {}
        t_values['stats'] = stats
        return self.response.out.write(render_template("index.html", t_values, "", True))
开发者ID:loongw,项目名称:another-gae-blog,代码行数:12,代码来源:admin.py


示例18: search_link

def search_link():
  query = request.args.get('query')
  if not query:
    return jsonify(size=0, data=[])

  query_string = to_query_string(query)
  if query_string == '':
    return jsonify(size=0, data=[])

  ids = Link.search(query_string)
  if len(ids):
    links = map(lambda x:L.get_by_id(int(x)), ids)
    links = [l.to_dict() for l in links]
    return jsonify(size = len(links), data=links)
  else:
    return jsonify(size=0, data=[])
开发者ID:yiransheng,项目名称:yiransbookmark,代码行数:16,代码来源:api.py


示例19: update_link

def update_link(id):
  link = L.get_by_id(id)
  if link == None:
    return jsonify(success=False, message="No link exisit by id: "+str(id))
  title = request.form.get('title')
  body = request.form.get('body')
  unread = request.form.get('unread', type=bool)
  tags = request.form.getlist('tags')
  clicks = int(request.form.get('clicks'))
  if title != link.title or body != link.body or tags != link.tags:
    Link.save_link(title, link.url, body, tags, clicks, unread)
  elif unread != link.unread or clicks != link.clicks:
    link.unread = unread
    link.clicks = clicks
    link.put()

  return jsonify(success=True, size=1, data=link)
开发者ID:yiransheng,项目名称:yiransbookmark,代码行数:17,代码来源:api.py


示例20: get

    def get(self, listtype = '', direction = 'next', page = '1', name = ''):
        if listtype == 'cat':
            objs = Category.get_cat_page_posts(name, page)
            catobj = Category.get_cat_by_name(name)
        elif listtype == 'tag':
            objs = Tag.get_tag_page_posts(name, page)
            catobj = Tag.get_tag_by_name(name)
        elif listtype == 'archive':
            objs = Archive.get_archive_page_posts(name, page)
            catobj = Archive.get_archive_by_name(name)
        #
        if not catobj:
            return self.redirect(BASE_URL)

        if not objs:
            return self.redirect(BASE_URL)

        if MYSQL_TO_KVDB_SUPPORT:
            allpost =  len(catobj.split(','))
        else:
            allpost =  catobj.id_num
        allpage = allpost/EACH_PAGE_POST_NUM
        if allpost%EACH_PAGE_POST_NUM:
            allpage += 1

        output = self.render('index.html', {
            'title': "%s - %s | Part %s"%( name, getAttr('SITE_TITLE'), page),
            'keywords':name,
            'description':getAttr('SITE_DECR'),
            'objs': objs,
            'cats': Category.get_all_cat_name(),
            'tags': Tag.get_hot_tag_name(),
            'archives': Archive.get_all_archive_name(),
            'page': int(page),
            'allpage': allpage,
            'listtype': listtype,
            'name': name,
            'namemd5': md5(name.encode('utf-8')).hexdigest(),
            'comments': Comment.get_recent_comments(),
            'links':Link.get_all_links(),
            'isauthor':self.isAuthor(),
            'Totalblog':get_count('Totalblog',NUM_SHARDS,0),
        },layout='_layout.html')
        self.write(output)
        return output
开发者ID:yobin,项目名称:saepy-log,代码行数:45,代码来源:blog.py



注:本文中的model.Link类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python model.Member类代码示例发布时间:2022-05-27
下一篇:
Python model.Entry类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap