當前位置: 首頁>>代碼示例>>Python>>正文


Python users.create_logout_url方法代碼示例

本文整理匯總了Python中google.appengine.api.users.create_logout_url方法的典型用法代碼示例。如果您正苦於以下問題:Python users.create_logout_url方法的具體用法?Python users.create_logout_url怎麽用?Python users.create_logout_url使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在google.appengine.api.users的用法示例。


在下文中一共展示了users.create_logout_url方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: _WriteTemplate

# 需要導入模塊: from google.appengine.api import users [as 別名]
# 或者: from google.appengine.api.users import create_logout_url [as 別名]
def _WriteTemplate(self, template_file, **kwargs):
    """Common method to write from a template.

    Args:
      template_file: String name of a file that exists within the template
                     folder.  For subdirectories the name may be 'sub/file'.
      **kwargs: A dictionary of key-value pairs that will be available
                within the template.
    """
    kwargs['tpl_logout_url'] = users.create_logout_url('/')
    kwargs['tpl_user_name'] = _SafelyGetCurrentUserEmail()
    if '.' not in template_file:
      template_file = '%s.html' % template_file
    self.response.headers['X-Frame-Options'] = 'DENY'  # Prevent clickjacking.
    self.response.write(
        self._jinja_env.get_template(template_file).render(kwargs)) 
開發者ID:google,項目名稱:googleapps-message-recall,代碼行數:18,代碼來源:frontend_views.py

示例2: get

# 需要導入模塊: from google.appengine.api import users [as 別名]
# 或者: from google.appengine.api.users import create_logout_url [as 別名]
def get(self):
    user = users.get_current_user()
    if not user:
      self.redirect(users.create_login_url('/account'))
      return
    email = user.email()
    action = 'Create'
    account, nickname = yield (get_account(user.user_id()),
                               get_nickname(user.user_id()))
    if account is not None:
      action = 'Update'
    if account:
      proposed_nickname = account.nickname or account.email
    else:
      proposed_nickname = email
    values = {'email': email,
              'nickname': nickname,
              'proposed_nickname': proposed_nickname,
              'login': users.create_login_url('/home'),
              'logout': users.create_logout_url('/home'),
              'action': action,
              }
    self.response.out.write(ACCOUNT_PAGE % values) 
開發者ID:GoogleCloudPlatform,項目名稱:datastore-ndb-python,代碼行數:25,代碼來源:main.py

示例3: post

# 需要導入模塊: from google.appengine.api import users [as 別名]
# 或者: from google.appengine.api.users import create_logout_url [as 別名]
def post(self):
    """Handle post request."""
    template_values = {
        'back_url': '/showCredentials',
        'back_msg': 'View Credentials',
        'logout_url': users.create_logout_url('/'),
        'user_nickname': users.get_current_user().nickname()
    }
    try:
      UpdateUserCredentials(self.request.get('client_id'),
                            self.request.get('client_secret'),
                            self.request.get('refresh_token'),
                            self.request.get('adwords_manager_cid'),
                            self.request.get('dev_token'))
      self.redirect('/showCredentials')
    except Exception as e:
      template_values['error'] = str(e)
      # Use template to write output to the page.
      path = os.path.join(os.path.dirname(__file__),
                          '../templates/base_template.html')
      self.response.out.write(template.render(path, template_values)) 
開發者ID:googleads,項目名稱:googleads-python-lib,代碼行數:23,代碼來源:update_credentials_view.py

示例4: index

# 需要導入模塊: from google.appengine.api import users [as 別名]
# 或者: from google.appengine.api.users import create_logout_url [as 別名]
def index():
    user = users.get_current_user()
    if user:
        logged_in = True
        nickname = user.nickname()
        logout_url = users.create_logout_url('/')
        login_url = None
    else:
        logged_in = False
        nickname = None
        logout_url = None
        login_url = users.create_login_url('/')

    template_values = {
        'logged_in': logged_in,
        'nickname': nickname,
        'logout_url': logout_url,
        'login_url': login_url,
    }

    return flask.render_template('index.html', **template_values)


# Fake status 
開發者ID:GoogleCloudPlatform,項目名稱:python-docs-samples,代碼行數:26,代碼來源:main.py

示例5: get

# 需要導入模塊: from google.appengine.api import users [as 別名]
# 或者: from google.appengine.api.users import create_logout_url [as 別名]
def get(self):
    template_values = { 'sign_out': users.create_logout_url('/') }
    # See if we have an auth token for this user.
    token = get_auth_token(self.request)
    if token is None:
      template_values['auth_url'] = gdata.gauth.generate_auth_sub_url(
          self.request.url, ['http://www.blogger.com/feeds/'])
      path = os.path.join(os.path.dirname(__file__), 'auth_required.html')
      self.response.out.write(template.render(path, template_values))
      return    
  
    elif token == False:
      self.response.out.write(
          '<html><body><a href="%s">You must sign in first</a>'
          '</body></html>' % users.create_login_url('/blogs'))
      return

    client = gdata.blogger.client.BloggerClient()
    feed = client.get_blogs(auth_token=token)
    template_values['feed'] = feed
    path = os.path.join(os.path.dirname(__file__), 'list_blogs.html')
    self.response.out.write(template.render(path, template_values)) 
開發者ID:kuri65536,項目名稱:python-for-android,代碼行數:24,代碼來源:blogapp.py

示例6: get

# 需要導入模塊: from google.appengine.api import users [as 別名]
# 或者: from google.appengine.api.users import create_logout_url [as 別名]
def get(self):  # pylint:disable-msg=invalid-name
    """Handle GET requests."""
    guestbook_name = self.request.get('guestbook_name')
    greetings_query = Greeting.all().ancestor(
        _GuestbookKey(guestbook_name)).order('-date')
    greetings = greetings_query.fetch(10)

    if users.get_current_user():
      url = users.create_logout_url(self.request.uri)
      url_linktext = 'Logout'
    else:
      url = users.create_login_url(self.request.uri)
      url_linktext = 'Login'

    template_values = {
        'greetings': greetings,
        'url': url,
        'url_linktext': url_linktext,
    }

    template = jinja_environment.get_template('index.html')
    self.response.out.write(template.render(template_values)) 
開發者ID:googlearchive,項目名稱:cloud-playground,代碼行數:24,代碼來源:helloworld.py

示例7: get

# 需要導入模塊: from google.appengine.api import users [as 別名]
# 或者: from google.appengine.api.users import create_logout_url [as 別名]
def get(self, param):
    user = users.get_current_user()
    if not user:
      self.redirect(users.create_login_url(self.request.path))
      return
    sign_out_link = users.create_logout_url('/')
    is_admin = users.is_current_user_admin()
    if param == "all" and is_admin:
      links = Link.query().fetch()
    else:
      links = Link.query(Link.owner_id == user.user_id()).fetch()
    context = {
        "links": links,
        "is_admin": is_admin,
        "sign_out_link": sign_out_link,
        "fqdn": config.GOLINKS_FQDN,
        "hostname": config.GOLINKS_HOSTNAME
    }
    self.response.write(render("template/list.html", context)) 
開發者ID:adamyi,項目名稱:golinks,代碼行數:21,代碼來源:appengine_main.py

示例8: setup

# 需要導入模塊: from google.appengine.api import users [as 別名]
# 或者: from google.appengine.api.users import create_logout_url [as 別名]
def setup(self, request, *args, **kwargs):
        """See docs on BaseView.setup."""
        # pylint: disable=attribute-defined-outside-init
        super(AdminBaseView, self).setup(request, *args, **kwargs)
        self.params.read_values(post_params={'xsrf_token': utils.strip})
        self.env.show_logo = True
        self.env.enable_javascript = True
        self.env.user = users.get_current_user()
        self.env.user_admin_permission = self._get_user_admin_permission()
        self.env.logout_url = users.create_logout_url(self.build_absolute_uri())
        self.env.all_repo_options = [
            utils.Struct(
                repo=repo, url=self.build_absolute_path('/%s/admin' % repo))
            for repo in sorted(model.Repo.list())
        ]
        self.xsrf_tool = utils.XsrfTool() 
開發者ID:google,項目名稱:personfinder,代碼行數:18,代碼來源:base.py

示例9: Render

# 需要導入模塊: from google.appengine.api import users [as 別名]
# 或者: from google.appengine.api.users import create_logout_url [as 別名]
def Render(request, template, params={}):
  """Wrapper function to render templates with global and category vars."""
  params['app_title'] = settings.APP_TITLE
  params['version_id'] = os.environ['CURRENT_VERSION_ID']
  params['build'] = settings.BUILD
  params['epoch'] = int(time.time())
  params['request_path'] = request.get_full_path()
  params['request_path_lastbit'] = re.sub('^.+\/([^\/]+$)', '\\1', request.path)
  params['current_ua_string'] = request.META['HTTP_USER_AGENT']
  params['current_ua'] = user_agent_parser.PrettyUserAgent(params['current_ua_string'])
  params['chromeframe_enabled'] = request.COOKIES.get(
      'browserscope-chromeframe-enabled', '0')
  params['app_categories'] = []
  params['is_admin'] = users.is_current_user_admin()

  current_user = users.get_current_user()
  if current_user:
    params['user_id'] = current_user.user_id()
  else:
    params['user_id'] = None
  params['user'] = current_user

  params['sign_in'] = users.create_login_url(request.get_full_path())
  params['sign_out'] = users.create_logout_url('/')

  return shortcuts.render_to_response(template, params) 
開發者ID:elsigh,項目名稱:browserscope,代碼行數:28,代碼來源:views.py

示例10: get

# 需要導入模塊: from google.appengine.api import users [as 別名]
# 或者: from google.appengine.api.users import create_logout_url [as 別名]
def get(self):
        self.redirect(users.create_logout_url('/')) 
開發者ID:Schibum,項目名稱:sndlatr,代碼行數:4,代碼來源:mainold.py

示例11: get

# 需要導入模塊: from google.appengine.api import users [as 別名]
# 或者: from google.appengine.api.users import create_logout_url [as 別名]
def get(self):
        """Returns logged in user information."""
        user = users.get_current_user()
        profile_information = {'email': user.email(),
                               'logoutUrl': users.create_logout_url('/')}
        self.response.out.write(json.dumps(profile_information)) 
開發者ID:googlearchive,項目名稱:billing-export-python,代碼行數:8,代碼來源:main.py

示例12: logout

# 需要導入模塊: from google.appengine.api import users [as 別名]
# 或者: from google.appengine.api.users import create_logout_url [as 別名]
def logout():
    '''
    Manually override the logout URL to avoid completely signing the user
    out of all Google accounts
    '''
    if os.getenv('SERVER_SOFTWARE', '').startswith('Google App Engine/'):
        return redirect('_ah/logout?continue=https://' + request.host + '/')
    return redirect(users.create_logout_url('/')) 
開發者ID:duo-labs,項目名稱:isthislegit,代碼行數:10,代碼來源:views.py

示例13: get

# 需要導入模塊: from google.appengine.api import users [as 別名]
# 或者: from google.appengine.api.users import create_logout_url [as 別名]
def get(self, user):
        logger.info("User was logged in: %r", user)
        self.response.out.write("%s <a href='%s'>logout</a>" % (
                user.email(),
                users.create_logout_url(self.request.url),)) 
開發者ID:ActiveState,項目名稱:code,代碼行數:7,代碼來源:recipe-577235.py

示例14: get

# 需要導入模塊: from google.appengine.api import users [as 別名]
# 或者: from google.appengine.api.users import create_logout_url [as 別名]
def get(self):
        user = users.get_current_user()
        
        if user:
            welcome = ("Welcome, %s! (<a href='%s'>Sing out</a>)"
                        % (user.nickname(), users.create_logout_url('/')))
        else:
            welcome = ("<a href='%s'>Sign in or Register</a>"
                        % users.create_login_url('/'))
        
        self.response.out.write("<html><head><title>Web App Title</title></head><body>%s</body></html>"
                                % welcome) 
開發者ID:ActiveState,項目名稱:code,代碼行數:14,代碼來源:recipe-577780.py

示例15: post

# 需要導入模塊: from google.appengine.api import users [as 別名]
# 或者: from google.appengine.api.users import create_logout_url [as 別名]
def post(self):
    """Handle post request."""
    client_customer_id = self.request.get('clientCustomerId')
    campaign_name = self.request.get('campaignName')
    ad_channel_type = self.request.get('adChannelType')
    budget = self.request.get('budget')
    template_values = {
        'back_url': '/showCampaigns?clientCustomerId=%s' % client_customer_id,
        'back_msg': 'View Campaigns',
        'logout_url': users.create_logout_url('/'),
        'user_nickname': users.get_current_user().nickname()
    }
    try:
      app_user = InitUser()

      # Load Client instance.
      handler = APIHandler(app_user.client_id,
                           app_user.client_secret,
                           app_user.refresh_token,
                           app_user.adwords_manager_cid,
                           app_user.developer_token)

      # Create new campaign.
      handler.AddCampaign(client_customer_id, campaign_name,
                          ad_channel_type, budget)

      self.redirect('/showCampaigns?clientCustomerId=%s' % client_customer_id)
    except Exception as e:
      template_values['error'] = str(e)
      # Use template to write output to the page.
      path = os.path.join(os.path.dirname(__file__),
                          '../templates/base_template.html')
      self.response.out.write(template.render(path, template_values)) 
開發者ID:googleads,項目名稱:googleads-python-lib,代碼行數:35,代碼來源:add_campaign_view.py


注:本文中的google.appengine.api.users.create_logout_url方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。