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

Python pylons.url函数代码示例

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

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



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

示例1: delete

    def delete(self, repo_name):
        """DELETE /repos/repo_name: Delete an existing item"""
        # Forms posted to this method should contain a hidden field:
        #    <input type="hidden" name="_method" value="DELETE" />
        # Or using helpers:
        #    h.form(url('repo_settings_delete', repo_name=ID),
        #           method='delete')
        # url('repo_settings_delete', repo_name=ID)

        repo_model = RepoModel()
        repo = repo_model.get_by_repo_name(repo_name)
        if not repo:
            h.not_mapped_error(repo_name)
            return redirect(url('home'))
        try:
            action_logger(self.rhodecode_user, 'user_deleted_repo',
                              repo_name, self.ip_addr, self.sa)
            repo_model.delete(repo)
            invalidate_cache('get_repo_cached_%s' % repo_name)
            h.flash(_('deleted repository %s') % repo_name, category='success')
            Session().commit()
        except Exception:
            log.error(traceback.format_exc())
            h.flash(_('An error occurred during deletion of %s') % repo_name,
                    category='error')

        return redirect(url('admin_settings_my_account', anchor='my'))
开发者ID:break123,项目名称:rhodecode,代码行数:27,代码来源:settings.py


示例2: logout

    def logout(self):
        '''
        This action deletes the cookie and redirects to the
        /openid/status to show the login status

        If the logout is called in the context of an openid authentication,
        the user is already logged in as a different user. In this case we
        forward to the /openid/login page after the logout was made.

        Another option for the openid authentication context would be to
        redirect to the return_to url by setting
            redirect_to = params["openid.return_to"]
            p["openid.mode"] = "setup_needed"
        which advises the openid relying party to restart the login process.
        '''

        response.delete_cookie(COOKIE_NAME)

        params = {}
        params.update(request.params)
        p = {}

        ## are we are called during an openid auth request?
        if "openid.return_to" in params:
            redirect_to = "/openid/login"
            p.update(params)
            do_redirect = url(str("%s?%s" % (redirect_to, urlencode(p))))

        else:
            redirect_to = "/openid/status"
            do_redirect = url(str("%s?%s" % (redirect_to, urlencode(p))))

        redirect(do_redirect)
开发者ID:MuhamadYULIANTO,项目名称:LinOTP,代码行数:33,代码来源:openid.py


示例3: loggedout

 def loggedout(self):
     "Logged out page"
     session.clear()
     session.save()
     came_from = (unquote(str(request.params.get('came_from', '')))
                 or url('/accounts/login'))
     redirect(url(came_from))
开发者ID:TetraAsh,项目名称:baruwa2,代码行数:7,代码来源:accounts.py


示例4: rss

    def rss(self, repo_name):
        """Produce an rss2 feed via feedgenerator module"""
        feed = Rss201rev2Feed(
            title=self.title % repo_name,
            link=url('summary_home', repo_name=repo_name,
                     qualified=True),
            description=self.description % repo_name,
            language=self.language,
            ttl=self.ttl
        )

        for cs in reversed(list(c.rhodecode_repo[-self.feed_nr:])):
            desc_msg = []
            desc_msg.append('%s - %s<br/><pre>' % (cs.author, cs.date))
            desc_msg.append(self.__changes(cs))

            feed.add_item(title=self._get_title(cs),
                          link=url('changeset_home', repo_name=repo_name,
                                   revision=cs.raw_id, qualified=True),
                          author_name=cs.author,
                          description=''.join(desc_msg),
                         )

        response.content_type = feed.mime_type
        return feed.writeString('utf-8')
开发者ID:elfixit,项目名称:rhodecode,代码行数:25,代码来源:feed.py


示例5: welcome

 def welcome(self):
     identity = request.environ.get("repoze.who.identity")
     came_from = request.params.get('came_from') or "/"
     came_from = unquote(came_from)
     came_from = unquote(came_from)
     came_from = unquote(came_from)
     came_from = str(came_from)
     if identity:
         # Login succeeded
         userid = identity['repoze.who.userid']
         #user_det = get_mediator_details(userid)
         #if user_det['name']:
         #    session['user_name'] = user_det['name']
         #if user_det['uri']:
         #    session['user_uri'] = str(user_det['uri'])
         session['user_id'] = userid
         session.save()
         return redirect(url(came_from))
     else:
         # Login failed
         try:
             login_counter = request.environ['repoze.who.logins'] + 1
         except:
             login_counter = 0
         destination = "/login?came_from=%s&logins=%s" % (came_from, login_counter)
         return redirect(url(destination))
开发者ID:benosteen,项目名称:RDFDatabank,代码行数:26,代码来源:account.py


示例6: delete_my_account

 def delete_my_account(self):
     if hasattr(self, 'form_result'):
             h.flash(_('Your account has been successfully removed!'))
             c.user.delete_user()
             meta.Session.commit()
             redirect(url(controller='home', action='logout'))
     redirect(url(controller='profile', action='login_settings'))
开发者ID:nous-consulting,项目名称:ututi,代码行数:7,代码来源:base.py


示例7: login_validate

    def login_validate(self):
    
        if (c.userid != "false"):
             redirect(url('/users/login?m=2'))
        session['logged_in'] = True
        session.save()    
            
        if request.method == 'POST':
            loginform = LoginForm(request.POST)
            if   loginform.is_valid():

                userid = authenticate_user(loginform.cleaned_data['email'], \
                         loginform.cleaned_data['password'])

                if (userid != "invalid" ):
                    session['userid'] = userid
                    session.save()
                    print session['userid']
                    c.login = "valid"
                    print loginform.cleaned_data['redirect']
                    if request.POST['redirect']=='null':                  
                        redirect(url('/'))
                    else:
                        redirect(url(str(loginform.cleaned_data['redirect'])))
                else:
                    c.login = "invalid"
                    c.form = LoginForm(request.POST)
                    return render("/users/login.mako")
            else:
                 c.form = LoginForm(request.POST)
                 return render("/users/login.mako")
        redirect(url('/'))
开发者ID:icheckmate,项目名称:DARE-1,代码行数:32,代码来源:users.py


示例8: test_new_wrong_user

    def test_new_wrong_user(self):
        # First we add a Dataset with user 'test_new'
        user = Account.by_name('test_new')
        assert user.api_key == 'd0610659-627b-4403-8b7f-6e2820ebc95d'

        u = url(controller='api/version2', action='create')
        params = {
            'metadata':
            'https://dl.dropbox.com/u/3250791/sample-openspending-model.json',
            'csv_file':
            'http://mk.ucant.org/info/data/sample-openspending-dataset.csv'
        }
        apikey_header = 'apikey {0}'.format(user.api_key)
        response = self.app.post(u, params, {'Authorization': apikey_header})

        assert "200" in response.status
        assert Dataset.by_name('openspending-example') is not None

        # After that we try to update the Dataset with user 'test_new2'
        user = Account.by_name('test_new2')
        assert user.api_key == 'c011c340-8dad-419c-8138-1c6ded86ead5'

        u = url(controller='api/version2', action='create')
        params = {
            'metadata':
            'https://dl.dropbox.com/u/3250791/sample-openspending-model.json',
            'csv_file':
            'http://mk.ucant.org/info/data/sample-openspending-dataset.csv'
        }
        apikey_header = 'apikey {0}'.format(user.api_key)
        response = self.app.post(u, params, {'Authorization': apikey_header},
                                 expect_errors=True)
        assert '403' in response.status
开发者ID:hagino3000,项目名称:openspending,代码行数:33,代码来源:test_api_version2.py


示例9: submit

    def submit(self):
        """
		Verify username and password
		"""
        # Both fields filled?
        form_username = str(request.params.get("username"))
        form_password = str(request.params.get("password"))
        m = hashlib.md5()
        m.update(form_password)
        passhash = m.hexdigest()
        # Get user data from database
        if app_globals.rpcservice.check_admin(form_username, passhash):
            # Mark admin as logged in
            session["user"] = form_username
            session["passhash"] = passhash
            session.save()
            return redirect(url(controller="syncuser", action="index"))

        if app_globals.rpcservice.check_user(form_username, passhash):
            # Mark user as logged in
            session["user"] = form_username
            session["passhash"] = passhash
            session.save()
            return redirect(url(controller="account"))
        return redirect(url.current(action="invalid"))
开发者ID:hermixy,项目名称:szarp,代码行数:25,代码来源:login.py


示例10: job_insert

    def job_insert(self):
        if (c.userid == "false"):
             redirect(url('/users/login?m=1'))

        #extra_questions = get_questions(request)
        #form = UserCreationForm(request.POST or None, extra=extra_questions)

        if request.method == 'POST':
            appname  = request.POST['appname']
            if (appname =='tophatfusion'):
               c.form = tophatfusionForm(request.POST,request.POST )
            elif (appname =='bfast') :
               c.form = bfastForm(request.POST,request.POST )
            elif (appname =='chipseq') :
               c.form = chipseqForm(request.POST,request.POST )

            if c.form.is_valid():
                #add using job queue
                jobid =add_job(c.userid)

                for key in c.form.cleaned_data:
                    print "key", key
                    print "value", c.form.cleaned_data[key]
                    newjobinfo = model.jobinfo()
                    newjobinfo.key = key
                    newjobinfo.value = c.form.cleaned_data[key]
                    newjobinfo.submitted_time = time.asctime()
                    newjobinfo.jobid = jobid
                    add_jobinfo(newjobinfo)

                update_job_status(jobid, str(JOBSTATES.NEW))
                redirect(url('/ngs/job_table_view?m=1&id=' + str(jobid) ))
            else:
                return render('/forms/chipseq_form.mako')
开发者ID:icheckmate,项目名称:DARE-1,代码行数:34,代码来源:ngs.py


示例11: test_aggregate_order

    def test_aggregate_order(self):
        def unique(seq):
            result = []
            for item in seq:
                if item not in result:
                    result.append(item)
            return result
        response = self.app.get(url(controller='api/version2',
                                    action='aggregate',
                                    dataset='cra', order='year:asc',
                                    drilldown='year'))
        assert response.status == '200 OK'
        result = json.loads(response.body)
        order = [cell['year'] for cell in result['drilldown']]
        expected_result = map(unicode, [2003, 2004, 2005, 2006, 2007,
                                        2008, 2009, 2010])
        assert unique(order) == expected_result

        response = self.app.get(url(controller='api/version2',
                                    action='aggregate',
                                    dataset='cra', order='year:desc',
                                    drilldown='year'))
        assert response.status == '200 OK'
        result = json.loads(response.body)
        order = [cell['year'] for cell in result['drilldown']]
        expected_result = map(unicode, [2010, 2009, 2008, 2007, 2006,
                                        2005, 2004, 2003])
        assert unique(order) == expected_result
开发者ID:hagino3000,项目名称:openspending,代码行数:28,代码来源:test_api_version2.py


示例12: delete

    def delete(self, group_name):
        """DELETE /repos_groups/group_name: Delete an existing item"""
        # Forms posted to this method should contain a hidden field:
        #    <input type="hidden" name="_method" value="DELETE" />
        # Or using helpers:
        #    h.form(url('repos_group', group_name=GROUP_NAME),
        #           method='delete')
        # url('repos_group', group_name=GROUP_NAME)

        gr = c.repos_group = ReposGroupModel()._get_repo_group(group_name)
        repos = gr.repositories.all()
        if repos:
            h.flash(_('This group contains %s repositores and cannot be '
                      'deleted') % len(repos), category='warning')
            return redirect(url('repos_groups'))

        children = gr.children.all()
        if children:
            h.flash(_('This group contains %s subgroups and cannot be deleted'
                      % (len(children))), category='warning')
            return redirect(url('repos_groups'))

        try:
            ReposGroupModel().delete(group_name)
            Session().commit()
            h.flash(_('Removed repository group %s') % group_name,
                    category='success')
            #TODO: in future action_logger(, '', '', '', self.sa)
        except Exception:
            log.error(traceback.format_exc())
            h.flash(_('Error occurred during deletion of repository group %s')
                    % group_name, category='error')

        return redirect(url('repos_groups'))
开发者ID:adamscieszko,项目名称:rhodecode,代码行数:34,代码来源:repos_groups.py


示例13: public_journal_rss

    def public_journal_rss(self):
        """
        Produce an rss2 feed via feedgenerator module
        """
        c.following = self.sa.query(UserFollowing)\
            .filter(UserFollowing.user_id == self.rhodecode_user.user_id)\
            .options(joinedload(UserFollowing.follows_repository))\
            .all()

        journal = self._get_journal_data(c.following)

        feed = Rss201rev2Feed(title=self.title % 'rss',
                         link=url('public_journal_rss', qualified=True),
                         description=_('Public journal'),
                         language=self.language,
                         ttl=self.ttl)

        for entry in journal[:self.feed_nr]:
            #tmpl = h.action_parser(entry)[0]
            action, action_extra = h.action_parser(entry, feed=True)
            title = "%s - %s %s" % (entry.user.short_contact, action,
                                 entry.repository.repo_name)
            desc = action_extra()
            feed.add_item(title=title,
                          pubdate=entry.action_date,
                          link=url('', qualified=True),
                          author_email=entry.user.email,
                          author_name=entry.user.full_contact,
                          description=desc)

        response.content_type = feed.mime_type
        return feed.writeString('utf-8')
开发者ID:elfixit,项目名称:rhodecode,代码行数:32,代码来源:journal.py


示例14: _process_contact

    def _process_contact(self):

        # Validate secure_form's (CSRF protection) token

        if not (request.params.get(secure_form.token_key) == secure_form.authentication_token()):
            abort (403, detail=u'Not permitted (possible CSRF attack)')

        # If cancelled, dont do anything

        if request.params.get('op') != 'Submit':
            session.pop('contactform.errors', None)
            session.pop('contactform.values', None)
            return url(controller='contactform', action='nevermind')

        # Validate form fields ...

        schema = ContactForm()
        try:
            fields = schema.to_python(dict(request.params))
            session.pop('contactform.errors', None)
            session.pop('contactform.values', None)
            self._save_contact(fields, schema)
            return url(controller='contactform', action='thanks')
        except formencode.Invalid, ex:
            session.update({
                'contactform.errors': ex.error_dict,
                'contactform.values': ex.value,
            })
            return url(controller='contactform', action='contact')
开发者ID:drmalex07,项目名称:pylons-helloworld,代码行数:29,代码来源:contactform.py


示例15: post_edit_statement

    def post_edit_statement(self, id):
        if not c.user:
            # should not happen therefore no c.returnTo
            redirect(url(controller='login', action='signin', id=id))

        query = meta.Session.query(model.Statement)
        thesis = query.filter_by(id=id).first().attachTrueFalseCount()

        if not c.user.allow_edit(thesis):
            raise Exception('no you dont')
            
        newMsg = request.params.get('msg')
        
        if len(stripMarkup(newMsg)) > int(statement_length):
            h.flash(_("Error: Only %s characters are allowed!") % statement_length)
            c.previousMessage = newMsg
            return self.edit_statement(id)        
        
        thesis.message = newMsg
        
        meta.Session.commit()
        search.update_index(thesis)
        
        

        redirect(url(controller, 'statements', action='show', id=id))
开发者ID:arturh85,项目名称:truthmaschine,代码行数:26,代码来源:statements.py


示例16: authenticate

    def authenticate(self):
        user = User()
        user.login = request.POST["login"]
        user.password = request.POST["password"]

        try:
            user.exists()
        except UserDoesntExistsException:
            flash(u"Niepoprawne dane autoryzacyjne. Sprawdź swój login i hasło.", "error")
            return redirect(url(controller="users", action="login"))

        user = User.query.filter(User.login == request.POST["login"]).first()
        flash(u"Witamy w systemie")
        try:
            session["user"] = {"id": user.id, "login": user.login}

            groups = []
            for group in user.groups:
                groups.append(str(group.name).lower())
            session["user"].update({"groups": groups})
        except KeyError:
            pass
        else:
            session.save()
            return redirect(url("/"))
开发者ID:rafal-kos,项目名称:pytis,代码行数:25,代码来源:users.py


示例17: create_comment

    def create_comment(self):
        content = None
        node = None
        if 'comment' in request.params:
            content = request.params['comment']
            if not content:
                return redirect(
                    url(controller='nodes', action='show', id=id))

            if 'node' in request.params:
                id = request.params['node']
                node = Session.query(Node)\
                    .filter(Node.id == id).first()

        if node:
            if not node.comments:
                node.comments = []
            comment = NodeComment()
            comment.node_id = id
            user = Session.query(User).filter(
                User.id == session['active_user']['user_id']).first()
            comment.user_id = session['active_user']['user_id']
            comment.description = content
            node.comments.append(comment)
            Session.add(node)
            Session.add(comment)
            Session.commit()

        return redirect(url(controller='nodes', action='show', id=id))
开发者ID:seryl,项目名称:Nodetraq,代码行数:29,代码来源:nodes.py


示例18: feed_rss

 def feed_rss(self):
     q = db.session.query(Dataset)
     if not (c.account and c.account.admin):
         q = q.filter_by(private=False)
     feed_items = q.order_by(Dataset.created_at.desc()).limit(20)
     items = []
     for feed_item in feed_items:
         items.append({
             'title': feed_item.label,
             'pubdate': feed_item.updated_at,
             'link': url(controller='dataset', action='view',
                         dataset=feed_item.name, qualified=True),
             'description': feed_item.description,
             'author_name': ', '.join([person.fullname for person in
                                       feed_item.managers if
                                       person.fullname]),
         })
     feed = Rss201rev2Feed(_('Recently Created Datasets'), url(
         controller='home', action='index', qualified=True),
         _('Recently created datasets in the OpenSpending Platform'),
         author_name='Openspending')
     for item in items:
         feed.add_item(**item)
     sio = StringIO()
     feed.write(sio, 'utf-8')
     response.content_type = 'application/xml'
     return sio.getvalue()
开发者ID:serchaos,项目名称:openspending,代码行数:27,代码来源:dataset.py


示例19: support

 def support(self):
     if not c.user:
         redirect(url(controller='home',
                      action='login',
                      came_from=url(controller='profile', action='support'),
                      context_type='support'))
     return render('/profile/support.mako')
开发者ID:nous-consulting,项目名称:ututi,代码行数:7,代码来源:base.py


示例20: image

def image(image):
    if image.unauthenticated_access:
        http_url = url('get_raw_by_user', user=image.owner.user_name, 
                       image=image.name, hypervisor='__hypervisor__', protocol='http')
    else:
        http_url = None

    return {'uuid':image.uuid,
             'name':image.name,
             'owner_user_name':image.owner.user_name,
             'owner':url('user', user=image.owner.user_name, qualified=True),
             'uploaded':ctime_or_none(image.uploaded),
             'modified':ctime_or_none(image.modified),
             'expires':ctime_or_none(image.expires),
             'checksum':{'type':image.checksum.ctype, 'value':image.checksum.cvalue},
             'os_variant':image.os_variant,
             'os_type':image.os_type,
             'os_arch':image.os_arch,
             'hypervisor':image.hypervisor,
             'description':image.description,
             'read_only':image.read_only,
             'unauthenticated_access':image.unauthenticated_access,
             'http_file_url':http_url,
             'raw_file_uploaded':image.raw_uploaded,
             'version':image.version,
             'size':image.size,
             'file_url':url('get_raw_by_user', user=image.owner.user_name,
                            image=image.name, hypervisor='__hypervisor__', qualified=True),
             'shared_with':{'groups':[url('group', group=g.name, qualified=True)
                                      for g in image.shared.groups],
                            'users':[url('user', user=u.user_name, qualified=True)
                                      for u in image.shared.users], },
            }
开发者ID:genba,项目名称:repoman,代码行数:33,代码来源:beautify.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python pylons.Response类代码示例发布时间:2022-05-25
下一篇:
Python standard.add函数代码示例发布时间:2022-05-25
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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