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

Python webapp2.uri_for函数代码示例

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

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



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

示例1: handle_get

    def handle_get(self):
        if not self.user:
            raise WebException("error.html", "Yo dude, must be signed in to mange your streams.")

        #query for streams
        api_req_kwargs = {
            "user_id": self.user.user_id()
        }
        api_req = self.get_internal_api_request('GET', 'API-StreamByUser', api_req_kwargs)
        api_resp = api_req.send()
        if api_resp is None:
            raise WebException("error.html", "There was a problem getting your streams")
        self.data["streams"] = api_resp

        for stream in self.data["streams"]:
            stream["linkUrl"] = self.base_uri + webapp2.uri_for('Web-ViewStream', id=stream["id"])
            stream["deleteUrl"] = self.base_uri + webapp2.uri_for('API-Stream', id=stream["id"])

        #query for subscriptions
        api_req = self.get_internal_api_request('GET', 'API-StreamBySubscription', api_req_kwargs)
        api_resp = api_req.send()
        if api_resp is None:
            raise WebException("error.html", "There was a problem getting your subscriptions")

        self.data["subscriptions"] = api_resp
        for sub in self.data["subscriptions"]:
            sub["linkUrl"] = self.base_uri + webapp2.uri_for('Web-ViewStream', id=sub["id"])
            sub["deleteUrl"] = self.base_uri + webapp2.uri_for('API-Subscription')

        self.data["active_page"] = "manage"
        self.data["resources"]["js"].append("manage.js")
        self.render_template("manage.html", self.data)
开发者ID:nathanielwendt,项目名称:APT-Connexus,代码行数:32,代码来源:web_handlers.py


示例2: render

    def render(self, template_name, template_values={}):
        #Let's turn of GCF for those poor lost souls with IE
        self.response.headers['X-UA-Compatible'] = 'chrome=1'

        # Routes common to all templates
        nav_bar = {
            'home':webapp2.uri_for('home'),
            'login': webapp2.uri_for('login'),
            'logout': webapp2.uri_for('logout'),
            'account': webapp2.uri_for('account')
        }
        # Preset values for the template
        values = {
          'request': self.request,
          'prefs': self.userprefs,
          'login_url': users.create_login_url(self.request.uri),
          'logout_url': users.create_logout_url(self.request.uri),
          'is_testenv':tools.common.is_testenv(),
          'nav_bar': nav_bar
        }

        # Add manually supplied template values
        values.update(template_values)

        template_dir = os.path.join(os.path.dirname(__file__),
            '../%s' % webapp2.get_app().config.get('template.dir'))

        # Render template
        fn = os.path.join(template_dir, template_name)
        self.response.out.write(template.render(fn, values,
                debug=tools.common.is_testenv()))
开发者ID:Cirrus-Business,项目名称:Cirrus-Business-clean,代码行数:31,代码来源:baserequesthandler.py


示例3: get

	def get(self):
		if users.is_current_user_admin():

			user = users.get_current_user()
			logout_url = users.create_logout_url("/admin")
			waitinglist = wl_models.WaitingList.get()
			add_waitinglist_action = webapp2.uri_for('admin_add_waitinglist', _full=True)
			delete_waitinglist_action = webapp2.uri_for('admin_delete_waitinglist', _full=True)

			context = {
						'user': user, \
						'logout_url': logout_url, \
						'waitinglist': waitinglist, \
						'add_waitinglist_action': add_waitinglist_action, \
						'delete_waitinglist_action': delete_waitinglist_action, \
						'form_add_waitinglist': self.form, \
						}

			self.render_response('admin/admin.html', **context)

		else:
			login_url = users.create_login_url("/admin")

			context = {'login_url': login_url}

			self.render_response('admin/login.html', **context)
开发者ID:aorura,项目名称:GAE_EX,代码行数:26,代码来源:admin_handlers.py


示例4: get

 def get(self):
     if not self.logged_in:
         self.session['referer'] = webapp2.uri_for('posmon')
         return self.redirect_to('login')
     if self.session['alliance_id'] != self.config.alliance_id:
         _log.debug('Alliance: %s != %s' % (self.session['alliance_id'], self.config.alliance_id))
         self.session['referer'] = webapp2.uri_for('posmon')
         return self.redirect_to('logout')
     corps = Corporation.query().fetch_async()
     towers = Tower.query(Tower.deleted == False).fetch()
     corps = corps.get_result()
     if 'corp' in self.request.GET:
         corp = self.request.get('corp')
         corpIds = [t.corp_id for t in corps if str(t.corp_id) == corp or t.corp_name == corp or t.corp_ticker == corp]
         towers = filter(lambda t: t.corp_id in corpIds, towers)
     corps = { c.corp_id: c for c in corps }
     if 'system' in self.request.GET:
         system = self.request.get('system')
         towers = filter(lambda t: str(t.system_id) == system or t.system_name == system, towers)
     if 'owner' in self.request.GET:
         def roman(n):
             if n == 0:
                 return ''
             if n >= 10:
                 return 'X' + roman(n-10)
             if n == 9 or n == 4:
                 return 'I' + roman(n+1)
             if n == 5:
                 return 'V'
             return roman(n-1) + 'I'
         owner = self.request.get('owner')
         owned = set(PosOwner.query(PosOwner.owner == owner).map(lambda o: o.location))
         towers = filter(lambda t: ('%s %s-%d' % (t.system_name, roman(t.planet), t.moon)) in owned, towers)
     self.write_json(towers)
开发者ID:cainau,项目名称:evetools,代码行数:34,代码来源:main.py


示例5: get

 def get(self, key):
     try:
         server_key = ndb.Key(urlsafe=key)
         server = server_key.get()
         if server is None:
             self.abort(404)
         if not server.is_gce:
             self.redirect(webapp2.uri_for('server', key=server.key.urlsafe()))
         versions = gcs.get_versions(server.key.urlsafe())
         current_version = versions[0] if versions else None
         if current_version:
             current_version_name = "{0} ({1})".format(
                 human_date(current_version['updated'], self.request.user.timezone),
                 human_size(current_version['size'])
             )
         form = ServerRestoreForm(
             versions=versions,
             timezone=self.request.user.timezone
         )
         url = webapp2.uri_for('server_uploaded', key=server.key.urlsafe())
         upload_url = blobstore.create_upload_url(
             url, gs_bucket_name="{0}/uploads/".format(gcs.get_default_bucket_name())
         )
     except Exception, e:
         logging.error(u"Error GETting GCE server restore: {0}".format(e))
         self.abort(404)
开发者ID:RubyCoin,项目名称:mc-coal,代码行数:26,代码来源:admin.py


示例6: post

 def post(self, key):
     try:
         server_key = ndb.Key(urlsafe=key)
         server = server_key.get()
         if server is None:
             self.abort(404)
         if not server.is_gce:
             self.redirect(webapp2.uri_for('home', server_key=server.url_key))
         form = ServerRestoreForm(
             formdata=self.request.POST,
             versions=gcs.get_versions(server.key.urlsafe()),
             timezone=self.request.user.timezone
         )
         if form.validate():
             gcs.restore_generation(server.key.urlsafe(), form.generation.data)
             name = None
             for choice in form.generation.choices:
                 if choice[0] == form.generation.data:
                     name = choice[1]
                     break
             message = u"Saved game restored."
             if name:
                 message = u"Saved game {0} restored.".format(name)
             logging.info(message)
             self.session.add_flash(message, level='info')
             time.sleep(1)
             self.redirect(webapp2.uri_for('home', server_key=server.url_key))
     except Exception, e:
         message = "Problem restoring game: {0}".format(e)
         logging.error(message)
         self.session.add_flash(message, level='error')
开发者ID:RubyCoin,项目名称:mc-coal,代码行数:31,代码来源:admin.py


示例7: get

    def get(self):
        rss = MemcacheManager.get('rss')
        if rss is None:
            items = []
            files = ArticleManager.get_files()[:NUMBER_OF_POSTS_ON_RSS_FEED]
            for filename in files:
                article = ArticleManager.get_article(filename)

                item = PyRSS2Gen.RSSItem(
                    title = article['title'],
                    link = article['url'],                    
                    description = article['html'],
                    content = article['html'],
                    guid = PyRSS2Gen.Guid(article['url']),
                    pubDate = article['dateTime'])

                items.append(item)

            rss = PyRSS2Gen.RSS2(
                title = "Opposite Reasons",
                link = webapp2.uri_for('home', _full=True),
                feedLink = webapp2.uri_for('rss', _full=True),
                description = "Opposite Reasons RSS feed",
                lastBuildDate = datetime.datetime.now(),
                items = items).to_xml()

            MemcacheManager.add('rss', rss)

        self.response.content_type = 'application/rss+xml'    
        self.response.charset = 'iso-8859-1'    
        self.response.write(rss)   
开发者ID:svpino,项目名称:blog-engine,代码行数:31,代码来源:handlers.py


示例8: get

    def get(self):
        _LATEST_COUNT = 6

        channels = globalconfig.getChannels()
        for channel in channels:
            slug = channel.get('slug')
            channel['url'] = webapp2.uri_for('channel', channel=slug)

            events = heapi.getEventPages(slug)
            for page in events:
                if page['event']['exposed']:
                    eventUrlType = 'event'
                else:
                    eventUrlType = 'hidden-event'
                # if eventId=0, error happens: 'Missing argument "eventId" to build URI.'
                page['event']['url'] = webapp2.uri_for(eventUrlType, eventScope=slug, eventId=page['event']['id'])
            events.sort(key=lambda page: page['weight'], reverse=True)
            events = events[:_LATEST_COUNT]
            globalutil.populateSourceUrl(events)
            channel['events'] = events

        chartses = snapi.getChartses()
        chartses.sort(key=lambda charts: charts['source']['added'], reverse=True)
        for charts in chartses:
            charts['url'] = webapp2.uri_for('charts', charts=charts['source']['slug'])
            charts['pages'] = charts['pages'][:_LATEST_COUNT]

        templateValues = {
            'channels': channels,
            'chartses': chartses,
        }
        self.render(templateValues, 'home.html')
开发者ID:sportlin,项目名称:newsshow,代码行数:32,代码来源:handlers.py


示例9: get

 def get(self):
     self.cache_must_revalidate()
     values = dict()
     values['sync_url'] = uri_for('cron-sync')
     values['full_url'] = uri_for('calendar-admin')
     values['calendar_admin_url'] = self.request.uri
     values['calendar'] = self.get_events()
     self.render_response('calendar_admin.html', **values)
开发者ID:tomaszlukowski,项目名称:oxford-strings,代码行数:8,代码来源:calendar_view.py


示例10: buildURI

 def buildURI(self, target, collection=None):
     if isinstance(target, db.Model):
         if collection:
             return webapp2.uri_for("rest-model-collection", modelname=target.__class__.__name__, itemid=target.key().id_or_name(), collectionname=collection, _full=True)
         else:
             return webapp2.uri_for("rest-model-item", modelname=target.__class__.__name__, itemid=target.key().id_or_name(), _full=True)
     else:
         return webapp2.uri_for("rest-model-list", modelname=target.__name__, _full=True)
开发者ID:carlozamagni,项目名称:restfulgae,代码行数:8,代码来源:__init__.py


示例11: _init_handler

 def _init_handler(cls, rrequest):
     rrequest.add_parameter('title', 'Glass Notifier')
     rrequest.add_breadcrumb('Home', uri_for('home'))
     brand = model.Link('Glass Notifications', uri_for('home'))
     nav_links = list()
     nav_links.append(model.Link('About', '#'))
     nav_links.append(model.Link('Contact', '#'))
     rrequest.add_parameter('brand', brand)
     rrequest.add_parameter('nav_links', nav_links)
开发者ID:tikurahul,项目名称:mirror-notify-python-server,代码行数:9,代码来源:main.py


示例12: get

 def get(self, name='index.html'):
     self.cache_must_revalidate()
     page = self.load_page(name)
     values = dict()
     values['content'] = self.markdown(page.source)
     values['edit_url'] = uri_for('editor', name=name)
     values['history_url'] = uri_for('history', name=name)
     self.render_response('wiki_page.html', **values)
     self.response.md5_etag()
开发者ID:tomaszlukowski,项目名称:oxford-strings,代码行数:9,代码来源:editable_view.py


示例13: get

	def get(self):
		id = self.request.get('id')
		
		deleted = db.run_in_transaction(self.delete, id)
		
		if (deleted):
			self.redirect(uri_for('greek-admin-main'))
		else:
			query_params = { 'error': 'Could not find chapter with that ID!' }
			self.redirect(uri_for('greek-admin-main') + '?' + urllib.urlencode(query_params))
开发者ID:mboumaraf,项目名称:phillsacre,代码行数:10,代码来源:greek_admin.py


示例14: get

    def get(self):
        users = UserPrefs.query().fetch()

        context = {
            'users': users,
            'user_delete_url': webapp2.uri_for('users-delete'),
            'user_create_url': webapp2.uri_for('users-create'),
        }
        template = JINJA_ENVIRONMENT.get_template('users.html')
        self.response.write(template.render(**context))
开发者ID:soofaloofa-zz,项目名称:cloudpypi,代码行数:10,代码来源:main.py


示例15: get

    def get(self, event_id, bracket_id):
        event = Event.get_by_id(event_id)
        if not event:
            self.redirect(uri_for('home'))

        bracket = Bracket.get_by_id(bracket_id)
        if not bracket:
            self.redirect(uri_for('brackets', event_id=event_id))

        bracket.regenerate(bracket.format_code)
        self.redirect(uri_for('single-bracket', event_id=event_id, bracket_id=bracket.id))
开发者ID:kaldonis,项目名称:ft-event-manager,代码行数:11,代码来源:bracket.py


示例16: uri_for_pagination

def uri_for_pagination(name, server_key=None, cursor=None):
    if server_key is None:
        uri = webapp2.uri_for(name)
    else:
        uri = webapp2.uri_for(name, server_key=server_key)
    if cursor is not None and cursor != 'START':
        if cursor.startswith('PAGE_0'):
            uri = u"{0}{1}{2}".format(uri, '&' if '?' in uri else '?', cursor[7:])
        else:
            uri = u"{0}{1}cursor={2}".format(uri, '&' if '?' in uri else '?', cursor)
    return uri
开发者ID:RubyCoin,项目名称:mc-coal,代码行数:11,代码来源:base_handler.py


示例17: get_article

    def get_article(filename):
        year = filename[:4]
        month = filename[4:6]
        day = filename[6:8]
        key = 'article-' + filename[:-5]

        article = MemcacheManager.get(key)
        if article is not None:
            return article
        else:
            html = JINJA_ENVIRONMENT.get_template('articles/' + year + '/' + month + '/' + filename).render()
            title = re.findall('<h1>(.+?)</h1>', html)[0]
            html = re.sub('<h1>(.+?)</h1>', '', html, count=1)
            name = filename[9:-5]

            metadata = re.findall('@metadata: ({.+?})', html, re.DOTALL)
            metadata = json.loads(metadata[0]) if len(metadata) == 1 else None

            if metadata is not None:
                html = re.sub('@metadata: ({.+?})', '', html, count=1, flags=re.DOTALL) 

                if "tags" in metadata:
                    metadata["tags"] = [tag.strip() for tag in metadata["tags"].split(',')]
                else:
                    metadata["tags"] = []

                if "summary" not in metadata:
                    metadata["summary"] = title

                if "lang" not in metadata:
                    metadata["lang"] = "en"
            else:
                metadata = { "summary": title, "tags": [], "lang": "en" }

            article = { 
                'id': key,
                'filename': filename,
                'url2': urllib.quote_plus(webapp2.uri_for('post', _full=True, year=year, month=month, day=day, page=name)),
                'html': html, 
                'formattedLongDate': calendar.month_name[int(month)] + ' ' + str(int(day)) + ', ' + year,
                'formattedShortDate': month + '/' + day + '/' + year,
                'dateTime': datetime.datetime(int(year), int(month), int(day)),
                'title': title,
                'link': '/' + year + '/' + month + '/' + day + '/' + name, 
                'url': webapp2.uri_for('post', _full=True, year=year, month=month, day=day, page=name),
                'summary': metadata["summary"],
                'lang': metadata["lang"],
                'tags': metadata["tags"] 
            }

            MemcacheManager.add(key, article)

            return article
开发者ID:svpino,项目名称:blog-engine,代码行数:53,代码来源:engine.py


示例18: sysadmin_callback

def sysadmin_callback(request, response):
    logged_in_user = users.get_current_user()

    if not logged_in_user or not users.is_current_user_admin():
        redirect_url = webapp2.uri_for('component.authentication.login.ui')
        webapp2.redirect(uri=redirect_url, request=request, response=response)
        return response

    registered_user = appapi.Users.get_by_auth_id(auth_id=logged_in_user.user_id())

    if registered_user:
        # Sync user with the Google UserAPI
        modified = False
        if registered_user.email_address != logged_in_user.email():
            registered_user.email_address = logged_in_user.email()
            modified = True

        if 'admin' not in registered_user.permissions.roles:
            registered_user.permissions.add_role('admin')
            modified = True
        if 'sysadmin' not in registered_user.permissions.roles:
            registered_user.permissions.add_role('sysadmin')
            modified = True

        if modified:
            appapi.Users.update(resource_object=registered_user)
        registered_user_uid = registered_user.uid
    else:
        random_password = koalacore.generate_random_string(20)

        user = appapi.Users.new(username=logged_in_user.user_id(),
                                   email_address=logged_in_user.email(),
                                   email_address_verified=True,
                                   first_name=u'Sys',
                                   raw_password=random_password,
                                   last_name=u'Admin',
                                   language_preference=u'en',
                                   roles={'user', 'admin', 'sysadmin'})

        try:
            user_uid = appapi.Users.insert(resource_object=user)
        except koalacore.UniqueValueRequired:
            redirect_url = webapp2.uri_for('component.authentication.login.ui', status_code='16')
            webapp2.redirect(uri=redirect_url, request=request, response=response)
            return response
        registered_user_uid = user_uid

    request.environ['beaker.session']['user_uid'] = registered_user_uid

    redirect_url = webapp2.uri_for('default')
    webapp2.redirect(uri=redirect_url, request=request, response=response)
    return response
开发者ID:LighthouseUK,项目名称:koala-quick-start,代码行数:52,代码来源:authentication.py


示例19: get

	def get(self):

		page_title = 'testapp - The CrowdFunding Portal'
		page_description = 'testapp - The CrowdFunding Portal'

		context = {'page_title': page_title, \
					'page_description': page_description, \
					'form_contact': self.form_contact, \
					'form_waiting': self.form_waiting, \
					'waiting_action': webapp2.uri_for('waiting_list_submit', _full=True), \
					'contact_action': webapp2.uri_for('contact_submit', _full=True), \
					}

		self.render_response('public/splash.html', **context)
开发者ID:aorura,项目名称:GAE_EX,代码行数:14,代码来源:public_handlers.py


示例20: get

 def get(self):
   user = users.get_current_user()
   self.response.out.write(template.render(
     'templates/json-api-post-login-password-reset.html', {
       'user': user,
       'login_url': users.create_login_url(
         webapp2.uri_for('documentation')),
       'logout_url': users.create_logout_url(
         webapp2.uri_for('documentation')),
       'password_forgot_url': users.create_password_forgot_url(
         webapp2.uri_for('documentation')),
       'password_change_url': users.create_password_change_url(
         webapp2.uri_for('documentation'))
     }))
开发者ID:roberthodgen,项目名称:ndb_users,代码行数:14,代码来源:main.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python webapp2.Config类代码示例发布时间:2022-05-26
下一篇:
Python webapp2.redirect函数代码示例发布时间: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