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

Python web.changequery函数代码示例

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

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



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

示例1: GET

    def GET(self, path):  
        i = web.input(b=None, a=None)
        # default value of b is latest revision and default value of a is b-1
        
        def get(path, revision):
            if revision == 0:
                page = web.ctx.site.new(path, {'revision': 0, 'type': {'key': '/type/object'}, 'key': path})
            else:
                page = web.ctx.site.get(path, revision)
            return page
        
        def is_int(n):
            return n is None or safeint(n, None) is not None
            
        # if either or i.a or i.b is bad, then redirect to latest diff
        if not is_int(i.b) or not is_int(i.a):
            return web.redirect(web.changequery(b=None, a=None))

        b = get(path, safeint(i.b, None))

        # if the page is not there go to view page
        if b is None:
            raise web.seeother(web.changequery(query={}))
        
        a = get(path, safeint(i.a, b.revision-1))            
        return render.diff(a, b)
开发者ID:EdwardBetts,项目名称:infogami,代码行数:26,代码来源:code.py


示例2: POST

    def POST(self, path):
        if not self.is_scan_user():
            return permission_denied('Permission denied.')

        book = web.ctx.site.get(path)
        i = web.input("scan_status", _comment=None)
        
        q = {
            'key': '/scan_record' + path,
            'scan_status': {
                'connect': 'update',
                'value': i.scan_status
            }
        }
        web.ctx.site.write(q, i._comment)

        def get_email(user):
            try:
                delegate.admin_login()
                return web.utf8(web.ctx.site.get_user_email(user.key).email)
            finally:
                web.ctx.headers = []

        scan_record = get_scan_record(path)
        to = scan_record.sponsor and get_email(scan_record.sponsor)
        cc = getattr(config, 'scan_email_recipients', [])
        if to:
            if i.scan_status == 'SCAN_IN_PROGRESS':
                message = render.scan_inprogress_email(book, scan_record, i._comment)
            else:    
                message = render.scan_book_notfound_email(book, scan_record, i._comment)
            web.sendmail(config.from_address, to, message.subject.strip(), str(message), cc=cc)
        raise web.seeother(web.changequery(query={}))
开发者ID:amoghravish,项目名称:openlibrary,代码行数:33,代码来源:code.py


示例3: redirect_if_needed

 def redirect_if_needed(self, i):
     params = {}
     need_redirect = False
     for k, v in i.items():
         if k in plurals:
             params[k] = None
             k = plurals[k]
             need_redirect = True
         if isinstance(v, list):
             if v == []:
                 continue
             clean = [b.strip() for b in v]
             if clean != v:
                 need_redirect = True
             if len(clean) == 1 and clean[0] == u'':
                 clean = None
         else:
             clean = v.strip()
             if clean == '':
                 need_redirect = True
                 clean = None
             if clean != v:
                 need_redirect = True
         params[k] = clean
     if need_redirect:
         raise web.seeother(web.changequery(**params))
开发者ID:ziwar,项目名称:openlibrary,代码行数:26,代码来源:code.py


示例4: make_collection

def make_collection(size, entries, limit, offset):
    d = {
        "size": size,
        "entries": entries,
        "links": {
            "self": web.changequery(),
        }
    }

    if offset + len(entries) < size:
        d['links']['next'] = web.changequery(limit=limit, offset=offset+limit)

    if offset:
        d['links']['prev'] = web.changequery(limit=limit, offset=max(0, offset-limit))

    return d
开发者ID:randomecho,项目名称:openlibrary,代码行数:16,代码来源:lists.py


示例5: GET

    def GET(self):
        i = web.input(author_key=[], language=[], first_publish_year=[], publisher_facet=[], subject_facet=[], person_facet=[], place_facet=[], time_facet=[])

        params = {}
        need_redirect = False
        for k, v in i.items():
            if isinstance(v, list):
                if v == []:
                    continue
                clean = [b.strip() for b in v]
                if clean != v:
                    need_redirect = True
                if len(clean) == 1 and clean[0] == u'':
                    clean = None
            else:
                clean = v.strip()
                if clean == '':
                    need_redirect = True
                    clean = None
                if clean != v:
                    need_redirect = True
            params[k] = clean
        if need_redirect:
            raise web.seeother(web.changequery(**params))

        return render.work_search(i, do_search, get_doc)
开发者ID:sribanta,项目名称:openlibrary,代码行数:26,代码来源:code.py


示例6: POST

 def POST(self, path):
     i = web.input(_method='post')
     i = web.storage(helpers.unflatten(i))
     i.key = path
     
     _ = web.storage((k, i.pop(k)) for k in i.keys() if k.startswith('_'))
     action = self.get_action(_)
     comment = _.get('_comment', None)
     
     for k, v in i.items():
         i[k] = self.trim(v)
         
     p = web.ctx.site.get(path) or web.ctx.site.new(path, {})
     p.update(i)
     
     if action == 'preview':
         p['comment_'] = comment
         return render.editpage(p, preview=True)
     elif action == 'save':
         try:
             p._save(comment)
             path = web.input(_method='GET', redirect=None).redirect or web.changequery(query={})
             raise web.seeother(path)
         except (ClientException, db.ValidationException), e:            
             add_flash_message('error', str(e))
             p['comment_'] = comment                
             return render.editpage(p)
开发者ID:EdwardBetts,项目名称:infogami,代码行数:27,代码来源:code.py


示例7: POST

    def POST(self, key):
        i = web.input("v", _comment=None)
        v = i.v and safeint(i.v, None)

        if v is None:
            raise web.seeother(web.changequery({}))

        user = accounts.get_current_user()
        is_admin = user and user.key in [m.key for m in web.ctx.site.get('/usergroup/admin').members]
        if not (is_admin and web.ctx.site.can_write(key)):
            return render.permission_denied(web.ctx.fullpath, "Permission denied to edit " + key + ".")

        thing = web.ctx.site.get(key, i.v)

        if not thing:
            raise web.notfound()

        def revert(thing):
            if thing.type.key == "/type/delete" and thing.revision > 1:
                prev = web.ctx.site.get(thing.key, thing.revision-1)
                if prev.type.key in ["/type/delete", "/type/redirect"]:
                    return revert(prev)
                else:
                    prev._save("revert to revision %d" % prev.revision)
                    return prev
            elif thing.type.key == "/type/redirect":
                redirect = web.ctx.site.get(thing.location)
                if redirect and redirect.type.key not in ["/type/delete", "/type/redirect"]:
                    return redirect
                else:
                    # bad redirect. Try the previous revision
                    prev = web.ctx.site.get(thing.key, thing.revision-1)
                    return revert(prev)
            else:
                return thing

        def process(value):
            if isinstance(value, list):
                return [process(v) for v in value]
            elif isinstance(value, client.Thing):
                if value.key:
                    if value.type.key in ['/type/delete', '/type/revert']:
                        return revert(value)
                    else:
                        return value
                else:
                    for k in value.keys():
                        value[k] = process(value[k])
                    return value
            else:
                return value

        for k in thing.keys():
            thing[k] = process(thing[k])

        comment = i._comment or "reverted to revision %d" % v
        thing._save(comment)
        raise web.seeother(key)
开发者ID:lukasklein,项目名称:openlibrary,代码行数:58,代码来源:code.py


示例8: GET

 def GET(self):
     i = web.input(status="WAITING_FOR_BOOK", p=None)
     options = ["NOT_SCANNED", "WAITING_FOR_BOOK", "BOOK_NOT_SCANNED", "SCAN_IN_PROGRESS", "SCAN_COMPLETE"]
     if i.status not in options:
         raise web.seeother(web.changequery({}))
         
     offset = safeint(i.p, 0) * 50
         
     records = get_scan_queue(i.status, limit=50, offset=offset)
     return render.scan_queue(records)
开发者ID:amoghravish,项目名称:openlibrary,代码行数:10,代码来源:code.py


示例9: POST

    def POST(self, site, path):
        i = input()

        if i.c != core.db.get_version(site, path).revision:
            return render.parallel_modification()
   
        if i.a == i.b:
	        return approve().POST(site, path)
        else:
            web.seeother(web.changequery(m='review', b=i.b-1))
开发者ID:EdwardBetts,项目名称:infogami,代码行数:10,代码来源:code.py


示例10: get_lists

    def get_lists(self, doc, limit=50, offset=0):
        lists = doc.get_lists(limit=limit, offset=offset)
        size = len(lists)

        if offset or len(lists) == limit:
            # There could be more lists than len(lists)
            size = len(doc.get_lists(limit=1000))

        d = {
            "links": {
                "self": web.ctx.path
            },
            "size": size,
            "entries": [lst.preview() for lst in lists]
        }
        if offset + len(lists) < size:
            d['links']['next'] = web.changequery(limit=limit, offset=offset + limit)

        if offset:
            offset = max(0, offset-limit)
            d['links']['prev'] = web.changequery(limit=limit, offset=offset)

        return d
开发者ID:randomecho,项目名称:openlibrary,代码行数:23,代码来源:lists.py


示例11: get_editions_data

    def get_editions_data(self, work, limit, offset):
        if limit > 1000:
            limit = 1000

        keys = web.ctx.site.things({"type": "/type/edition", "works": work.key, "limit": limit, "offset": offset})
        editions = web.ctx.site.get_many(keys, raw=True)

        size = work.edition_count
        links = {
            "self": web.ctx.fullpath,
            "work": work.key,
        }

        if offset > 0:
            links['prev'] = web.changequery(offset=min(0, offset-limit))

        if offset + len(editions) < size:
            links['next'] = web.changequery(offset=offset+limit)

        return {
            "links": links,
            "size": size,
            "entries": editions
        }
开发者ID:internetarchive,项目名称:openlibrary,代码行数:24,代码来源:api.py


示例12: get_works_data

    def get_works_data(self, author, limit, offset):
        if limit > 1000:
            limit = 1000

        keys = web.ctx.site.things({"type": "/type/work", "authors": {"author": {"key": author.key}}, "limit": limit, "offset": offset})
        works = web.ctx.site.get_many(keys, raw=True)

        size = author.get_work_count()
        links = {
            "self": web.ctx.fullpath,
            "author": author.key,
        }

        if offset > 0:
            links['prev'] = web.changequery(offset=min(0, offset-limit))

        if offset + len(works) < size:
            links['next'] = web.changequery(offset=offset+limit)

        return {
            "links": links,
            "size": size,
            "entries": works
        }
开发者ID:internetarchive,项目名称:openlibrary,代码行数:24,代码来源:api.py


示例13: delegate

def delegate():
    """Delegate the request to appropriate class."""
    path = web.ctx.path
    method = web.ctx.method

    # look for special pages
    cls, args = find_page()
    if cls is None:
        cls, args = find_mode()
        
    if cls is None:
        raise web.seeother(web.changequery(m=None))
    elif not hasattr(cls, method):
        raise web.nomethod(method)
    else:
        return getattr(cls(), method)(*args)
开发者ID:EdwardBetts,项目名称:infogami,代码行数:16,代码来源:app.py


示例14: change_params

def change_params(**kwargs):
    return re.sub('/.*?\?', '', web.changequery(**kwargs))
开发者ID:alexksikes,项目名称:sGeo,代码行数:2,代码来源:template_utils.py


示例15: except

                raise web.seeother(path)
            except (ClientException, db.ValidationException), e:            
                add_flash_message('error', str(e))
                p['comment_'] = comment                
                return render.editpage(p)
        elif action == 'delete':
            q = dict(key=i['key'], type=dict(key='/type/delete'))
            
            try:
                web.ctx.site.save(q, comment)
            except (ClientException, db.ValidationException), e:            
                add_flash_message('error', str(e))
                p['comment_'] = comment                
                return render.editpage(p)
            
            raise web.seeother(web.changequery(query={}))
    
    def get_action(self, i):
        """Finds the action from input."""
        if '_save' in i: return 'save'
        elif '_preview' in i: return 'preview'
        elif '_delete' in i: return 'delete'
        else: return None

class permission(delegate.mode):
    def GET(self, path):
        p = db.get_version(path)
        if not p:
            raise web.seeother(path)
        return render.permission(p)
        
开发者ID:EdwardBetts,项目名称:infogami,代码行数:30,代码来源:code.py


示例16: GET

 def GET(self):
     return web.changequery(x=1)
开发者ID:FrankSun0634,项目名称:webpy,代码行数:2,代码来源:application.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python web.conflict函数代码示例发布时间:2022-05-26
下一篇:
Python web.badrequest函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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