本文整理汇总了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))
示例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)
示例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))
示例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
示例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))
示例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))
示例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))
示例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()
示例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)
示例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('/'))
示例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))
示例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('/'))
示例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),))
示例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)
示例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))