当前位置: 首页>>代码示例>>Python>>正文


Python HTTPFound.delete_cookie方法代码示例

本文整理汇总了Python中pyramid.httpexceptions.HTTPFound.delete_cookie方法的典型用法代码示例。如果您正苦于以下问题:Python HTTPFound.delete_cookie方法的具体用法?Python HTTPFound.delete_cookie怎么用?Python HTTPFound.delete_cookie使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pyramid.httpexceptions.HTTPFound的用法示例。


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

示例1: logout_view

# 需要导入模块: from pyramid.httpexceptions import HTTPFound [as 别名]
# 或者: from pyramid.httpexceptions.HTTPFound import delete_cookie [as 别名]
def logout_view(request):
    """
        The logout view
    """
    loc = request.route_url('index')
    headers = forget(request)
    response = HTTPFound(location=loc, headers=headers)
    response.delete_cookie("remember_me")
    return response
开发者ID:mike-perdide,项目名称:autonomie,代码行数:11,代码来源:auth.py

示例2: do_logout

# 需要导入模块: from pyramid.httpexceptions import HTTPFound [as 别名]
# 或者: from pyramid.httpexceptions.HTTPFound import delete_cookie [as 别名]
    def do_logout(self, request, location):
        """ do the logout """
        # convenient method to set Cache-Control and Expires headers
        request.response.cache_expires = 0

        headers = forget(request)
        response = HTTPFound(location=location, headers=headers)
        response.delete_cookie('cis_account', path="/")
        response.cache_control = 'no-cache'

        request.session.pop_flash('token')
        return response
开发者ID:puittenbroek,项目名称:cister.db,代码行数:14,代码来源:login.py

示例3: change_profile

# 需要导入模块: from pyramid.httpexceptions import HTTPFound [as 别名]
# 或者: from pyramid.httpexceptions.HTTPFound import delete_cookie [as 别名]
def change_profile(request, profile):
    """
    Sets a cookie for the given profile and deletes any location set in the
    cookies.
    Returns a response which directs to the map view.
    """
    response = HTTPFound(location=request.route_url('map_view'))
    response.set_cookie('_PROFILE_', profile, timedelta(days=90))

    if '_LOCATION_' in request.cookies:
        response.delete_cookie('_LOCATION_')

    return response
开发者ID:sinnwerkstatt,项目名称:lokp,代码行数:15,代码来源:views.py

示例4: logout

# 需要导入模块: from pyramid.httpexceptions import HTTPFound [as 别名]
# 或者: from pyramid.httpexceptions.HTTPFound import delete_cookie [as 别名]
 def logout(self, request):
     request_cookie = request.cookies.get('signed')
     if not request_cookie:
         return {}
     cookie = signed_deserialize(request_cookie, SECRET)
     cookie_csrf = cookie.get('csrf')
     if request.method == 'POST':
         csrf = request.POST.get('csrf')
         if csrf == cookie_csrf:
             response = HTTPFound(request.route_url('admin.index'))
             response.delete_cookie('signed')
             return response
     return dict(csrf=cookie_csrf)
开发者ID:tark-hidden,项目名称:pyramid_igniter,代码行数:15,代码来源:views.py

示例5: confirm

# 需要导入模块: from pyramid.httpexceptions import HTTPFound [as 别名]
# 或者: from pyramid.httpexceptions.HTTPFound import delete_cookie [as 别名]
def confirm(request):
	if not 'order' in request.cookies:
		return {'error': True, 'community': Settings.Community}
	order = json.loads(request.cookies['order'])
	try:
		steamid = order['steamid']
		email = order['email']
		promocode = order['promocode']
		server = order['server']
		item = order['item']
		promo = None
	except:
		return {'error': True, 'community': Settings.Community}
	server = Settings.Session.query(Server).filter(Server.id == order['server']).scalar()
	item = Settings.Session.query(Item).filter(Item.id == order['item']).scalar()
	if not server or not item or not re.match(r'[^@][email protected][^@]+\.[^@]+', email):
		return {'error': True, 'community': Settings.Community}
	promotions = []
	price = item.price
	for promotion in [promo.promotion for promo in item.promotions if promo.promotion.type == 1 and '%' not in promo.promotion.value and time.time() < promo.promotion.expires]:
		try:
			price = price - float(promotion.value)
			promotions.append(promotion)
		except:
			continue
	for promotion in [promo.promotion for promo in item.promotions if promo.promotion.type == 1 and '%' in promo.promotion.value and time.time() < promo.promotion.expires]:
		try:
			price = price - (price * (float(promotion.value.replace('%', '')) / 100))
			promotions.append(promotion)
		except:
			continue;
	if price < 0:
		price = 0
	try:
		commid = SteamIDToCommunityID(steamid)
	except SteamFormatException:
		return {'error': True, 'community': Settings.Community}
	if promocode != '':
		print "Code: %s" % promocode
		for promotion in [promo.promotion for promo in item.promotions if promo.promotion.type == 2 and time.time() < promo.promotion.expires]:
			if promotion.code == promocode:
				promo = promotion
				if '%' in promo.value:
					try:
						price = price - (price * (float(promo.value.replace('%', '')) / 100))
						promotions.append(promo)
					except:
						pass
				else:
					try:
						price = price - float(promo.value)
						promotions.append(promo)
					except:
						pass
				break
	if price < 0:
		price = 0
	if 'checkout' in request.params:
		txn = Transaction(item.id, server.id, round(price,2), steamid, email, time.time())
		Settings.Session.add(txn)
		Settings.Session.flush()
		Settings.Session.refresh(txn)
		payment = paypalrestsdk.Payment({
			"intent": "sale",
			"payer": {"payment_method": "paypal"},
			"redirect_urls": {
				"return_url": request.route_url('paypal/execute', txn=txn.txn_id),
				"cancel_url": request.route_url('paypal/cancel', txn=txn.txn_id)},
			"transactions": [{
				"item_list": {
					"items": [{
						"name": item.name,
						"sku": item.id,
						"price": round(price,2) if round(price,2) % 1 != 0 else int(round(price,2)),
						"currency": "USD",
						"quantity": 1 }]},
				"amount": {
					"total": round(price,2) if round(price,2) % 1 != 0 else int(round(price,2)),
					"currency": "USD",}}]})
		if payment.create():
			Settings.Session.add(OngoingTransaction(payment.id, txn.txn_id))
			try:
				Settings.Session.commit()
			except:
				Settings.Session.rollback()
			for link in payment.links:
				if link.method == 'REDIRECT':
					redirect_url = link.href
			response = HTTPFound(location=redirect_url)
			response.delete_cookie('order')
			return response
		else:
			print payment.error
			Settings.Session.delete(txn)
			try:
				Settings.Session.commit()
			except:
				Settings.Session.rollback()
			return {'error': True, 'community': Settings.Community}
	steamapi.core.APIConnection(api_key=Settings.SteamAPI)
#.........这里部分代码省略.........
开发者ID:EasyDonate,项目名称:EasyDonate,代码行数:103,代码来源:EDViews.py

示例6: logout

# 需要导入模块: from pyramid.httpexceptions import HTTPFound [as 别名]
# 或者: from pyramid.httpexceptions.HTTPFound import delete_cookie [as 别名]
def logout(request):
    headers = forget(request)
    response = HTTPFound(location=route_url('home', request),
                     headers=headers)
    response.delete_cookie('user')
    return response
开发者ID:trojanowski-radek,项目名称:bergamotka,代码行数:8,代码来源:views.py

示例7: logout

# 需要导入模块: from pyramid.httpexceptions import HTTPFound [as 别名]
# 或者: from pyramid.httpexceptions.HTTPFound import delete_cookie [as 别名]
def logout(request):
    response = HTTPFound('/')
    response.delete_cookie('user_id')
    return response
开发者ID:antoineleclair,项目名称:OpenCode20111201,代码行数:6,代码来源:sessions.py

示例8: log_out

# 需要导入模块: from pyramid.httpexceptions import HTTPFound [as 别名]
# 或者: from pyramid.httpexceptions.HTTPFound import delete_cookie [as 别名]
def log_out(request):
    if "cherubplay" in request.cookies:
        request.login_store.delete("session:" + request.cookies["cherubplay"])
    response = HTTPFound(request.route_path("home"))
    response.delete_cookie("cherubplay")
    return response
开发者ID:bengoeswild,项目名称:cherubplay,代码行数:8,代码来源:__init__.py

示例9: create_invoice

# 需要导入模块: from pyramid.httpexceptions import HTTPFound [as 别名]
# 或者: from pyramid.httpexceptions.HTTPFound import delete_cookie [as 别名]
 def create_invoice(self):
     records = self.request.params.getall('records')
     
     if records:
         fullname = self.request.params.get('customer.name','')
         email = self.request.params.get('customer.email','')
         address = self.request.params.get('customer.address','')
         address2 = self.request.params.get('customer.address2','')
         phone = self.request.params.get('customer.phone','')
         agreement = Validators.bool(self.request.params.get('customer.agreement',0))
         checkout = self.request.params.getall('customer.checkout')
         deliver_digitally = False
         deliver_physically = False
         
         # Delivery Options
         for option in checkout:
             if option == 'digitally':
                 deliver_digitally = True
             if option == 'physically':
                 deliver_physically = True
                 
         # Prep Orders
         orders = []
         total_price = 0.0
         location_emails = {} # to notify any locations a request has been made
         for record in records:
             c = Cases.load(id=int(record))
             e = Entities.load(case_id=int(record))
             r = Roles.load(id=e.role)
             l = Archives.load(id=c.archive)
             
             location_emails[l.email] = l.email
             total_price += float(r.price)
             
             orders.append({'case':int(c.id), 'price' : r.price, 'location':int(l.id)})
             
         invoice = Invoices(fullname=fullname, email=email, address=address, county_state_zip=address2, phone=phone, records=orders, 
                            agreement_accepted=agreement, deliver_digitally=deliver_digitally, deliver_physically=deliver_physically,
                            total_price='${:,.2f}'.format(total_price))
         invoice.insert(self.request)
         invoice = Invoices.load(order='id desc')
         
         #Email Client
         starting_status = Statuses.load(order='priority asc')
         Emailer.send(self.request,
                      [email],
                      starting_status.email_subject,
                      starting_status.email_message,
                      link=self.request.application_url + '/invoice/' + invoice.hash
                      )
                      
         #Email Archives Involved
         Emailer.send(self.request,
                      list(location_emails),
                      'Order request has been placed',
                      'A new order request has been placed',
                      link=self.request.application_url + '/login?goto=' + self.request.application_url + '/manage/orders'
                      )
                      
                      
         response = HTTPFound(location=route_url('invoice', self.request, hash=invoice.hash))
         response.delete_cookie('basket')
         return response
         
     else:
         return self.response
开发者ID:polklibrary,项目名称:courtrecords,代码行数:68,代码来源:basket.py

示例10: logOut

# 需要导入模块: from pyramid.httpexceptions import HTTPFound [as 别名]
# 或者: from pyramid.httpexceptions.HTTPFound import delete_cookie [as 别名]
def logOut(request):
    redirect = HTTPFound('/')
    redirect.delete_cookie('sessionData')
    redirect.delete_cookie('filterList')
    return redirect
开发者ID:Harikiranvuyyuru,项目名称:PS4M,代码行数:7,代码来源:main.py

示例11: __call__

# 需要导入模块: from pyramid.httpexceptions import HTTPFound [as 别名]
# 或者: from pyramid.httpexceptions.HTTPFound import delete_cookie [as 别名]

#.........这里部分代码省略.........

        initial_login = not logged_in

        storeplayeridPwd = params.get('remember', '')

        # if already logged in and requesting this page, redirect to forbidden

        if logged_in:
            message = 'You do not have the required permissions to see this page.'
            return dict(
                    message=message,
                    url=url,
                    came_from=came_from,
                    password=password,
                    user=activeUser,
                    headers=headers,
                    errors=errors,
                    logged_in=logged_in,
                    remember=storeplayeridPwd
                    )
        # check whether we are asked to do an autologin (from pwdreset.py)
        autologin = 0 #self.request.session.pop_flash(queue='autologin')

        # 'SECURITY RISK'
        forcelogin = lc and self.request.params.get('forcelogin', '')
        if forcelogin or autologin or 'form.submitted' in params:

            if autologin:
                autologin = autologin[0].split('|')
                playerid = autologin[0]
                password = autologin[1] #encrypted
            elif forcelogin:
                pass
            else:
                playerid = params['playerid']
                # when we get a password from a cookie, we already receive it encrypted. If not, encrypt it here
                password = (passwordFromCookie and password) or params['password']

            if not password:
                errors['password'] = "Enter your password"
            else:
                # if autologin, we already receive it encrypted. If not, encrypt it here
                password = ((forcelogin or autologin) and password) or hashlib.md5(params['password']).hexdigest()

            if not playerid:
                errors['playerid'] = "Enter your player id"

            if playerid and password:
                user = dbsession.query(User).filter_by(playerid=playerid).first()

                if user:
                    passwordOk = (user.password == password)
                if not user:
                    message = 'You do not have a CIS account'
                elif user.banned:
                    message = 'Your account has been banned.'
                elif not user.activated:
                    message = 'Your account has not yet been activated'
                elif not passwordOk:
                    message = 'Your account/password do not match' 
                else:
                    
                    # READY TO LOGIN, SOME FINAL CHECKS
                    now = datetime.now()

                    headers = remember(self.request, user.playerid)
                    last_login = now.strftime('%Y-%m-%d %H:%M:%S')
                    user.last_web = last_login

                    response = HTTPFound()
                    user.last_login = last_login
                    response.headers = headers

                    response.content_type = 'text/html'
                    response.charset = 'UTF-8' 
                    if storeplayeridPwd:
                        cookie_val = '%s|%s' % (playerid, password)
                        response.set_cookie('cis_login_credentials', cookie_val, max_age=timedelta(days=365), path='/')

                    response.location = came_from
                    if (not forcelogin) and (not storeplayeridPwd):
                        response.delete_cookie('cis_login_credentials')

                    response.cache_control = 'no-cache'
                    return response

            activeUser.playerid = playerid

        storeplayeridPwd = self.request.cookies.get('cis_login_credentials') and '1' or ''
        return dict(
                    message=message,
                    url=url,
                    came_from=came_from,
                    password=password,
                    user=activeUser,
                    headers=headers,
                    errors=errors,
                    logged_in=logged_in,
                    remember=storeplayeridPwd
                    )
开发者ID:puittenbroek,项目名称:cister.db,代码行数:104,代码来源:login.py


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