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


Python Session.delete_item方法代码示例

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


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

示例1: LogoutHandler

# 需要导入模块: from util.sessions import Session [as 别名]
# 或者: from util.sessions.Session import delete_item [as 别名]
class LogoutHandler(webapp.RequestHandler):
    def get(self):
        self.session = Session()
        un = self.session.get('username')
        self.session.delete_item('username')
        self.session.delete_item('userkey')
        doRender(self, 'index.html', {'msg' : un + ' logout successful.'} ) 
开发者ID:herohunfer,项目名称:IITVs,代码行数:9,代码来源:index.py

示例2: LoginHandler

# 需要导入模块: from util.sessions import Session [as 别名]
# 或者: from util.sessions.Session import delete_item [as 别名]
class LoginHandler(webapp.RequestHandler):

  def get(self):
    doRender(self, 'loginscreen.htm')

  def post(self):
    self.session = Session()
    acct = self.request.get('account')
    pw = self.request.get('password')
    logging.info('Checking account='+acct+' pw='+pw)

    self.session.delete_item('username')

    if pw == '' or acct == '':
      doRender(
          self,
          'loginscreen.htm',
          {'error' : 'Please specify Account and Password'} )
      return

    que = db.Query(User)
    que = que.filter('account =',acct)
    que = que.filter('password = ',pw)

    results = que.fetch(limit=1)

    if len(results) > 0 :
      self.session['username'] = acct
      doRender(self,'index.htm',{ } )
    else:
      doRender(
          self,
          'loginscreen.htm',
          {'error' : 'Incorrect password'} )
开发者ID:jacobcr,项目名称:G4Btools,代码行数:36,代码来源:index.py

示例3: LogoutHandler

# 需要导入模块: from util.sessions import Session [as 别名]
# 或者: from util.sessions.Session import delete_item [as 别名]
class LogoutHandler(webapp.RequestHandler):

  def get(self):
    self.session = Session()
    self.session.delete_item('username')
    self.session.delete_item('userkey')
    doRender(self, 'index.htm')
开发者ID:i3enhamin,项目名称:learning_app_engine,代码行数:9,代码来源:index.py

示例4: LogOutHandler

# 需要导入模块: from util.sessions import Session [as 别名]
# 或者: from util.sessions.Session import delete_item [as 别名]
class LogOutHandler(webapp.RequestHandler):

    def get(self):
        
        self.session = Session()
        self.session.delete_item('user')
        self.redirect('main.html')
开发者ID:filipmares,项目名称:SynapSync,代码行数:9,代码来源:logout.py

示例5: LoginHandler

# 需要导入模块: from util.sessions import Session [as 别名]
# 或者: from util.sessions.Session import delete_item [as 别名]
class LoginHandler(webapp.RequestHandler):
    def get(self):
        doRender(self, "loginscreen.htm")

    def post(self):
        self.session = Session()
        acct = self.request.get("account")
        pw = self.request.get("password")
        logging.info("Checking account=" + acct + " pw=" + pw)

        self.session.delete_item("username")
        self.session.delete_item("userkey")

        if pw == "" or acct == "":
            doRender(self, "loginscreen.htm", {"error": "Please specify Account and Password"})
            return

        que = db.Query(User)
        que = que.filter("account =", acct)
        que = que.filter("password = ", pw)

        results = que.fetch(limit=1)

        if len(results) > 0:
            user = results[0]
            self.session["userkey"] = user.key()
            self.session["username"] = acct
            doRender(self, "index.htm", {})
        else:
            doRender(self, "loginscreen.htm", {"error": "Incorrect password"})
开发者ID:jacobcr,项目名称:G4Btools,代码行数:32,代码来源:index.py

示例6: logout

# 需要导入模块: from util.sessions import Session [as 别名]
# 或者: from util.sessions.Session import delete_item [as 别名]
class logout(webapp.RequestHandler):
    def get(self):
        self.session = Session()
        self.session.delete_item('username')
        render(self,"logout.html")
        
    def post(self):
        render()
开发者ID:adekola,项目名称:poller-app,代码行数:10,代码来源:pollerdashboard.py

示例7: LogoutHandler

# 需要导入模块: from util.sessions import Session [as 别名]
# 或者: from util.sessions.Session import delete_item [as 别名]
class LogoutHandler(webapp.RequestHandler):
    def get(self):
        self.session=Session()
        self.session.delete_item('username')
        self.session.delete_item('ft_client')
        path=self.request.path
        temp=os.path.join(os.path.dirname(__file__),'templates/index.html')
        html=template.render(temp,{'path':path})
        self.response.out.write(html)
开发者ID:apurvagoyal,项目名称:Google-App-Engine-Fusion-Table-Sample,代码行数:11,代码来源:index.py

示例8: ExitHandler

# 需要导入模块: from util.sessions import Session [as 别名]
# 或者: from util.sessions.Session import delete_item [as 别名]
class ExitHandler(webapp.RequestHandler):
    def get(self):
	self.session=Session()
	self.session.delete_item('username')
	self.session.delete_item('role')
	self.session.delete_item('tid')
	self.session.delete_item('level')
	self.session.delete_item('game_id')
	
	msg="Thank you for playing. Bye!"
	
	temp = os.path.join(os.path.dirname(__file__), 'templates/logout.html')
	
      	self.response.headers['Content-Type'] = 'text/html'
        self.response.out.write(str(template.render(temp,{"logoutmsg":msg})))
开发者ID:geekyjulie,项目名称:ciphersleuth,代码行数:17,代码来源:main.py

示例9: CipherInterfaceHandler

# 需要导入模块: from util.sessions import Session [as 别名]
# 或者: from util.sessions.Session import delete_item [as 别名]
class CipherInterfaceHandler(webapp.RequestHandler):
    def get(self):
	temp=os.path.join(os.path.dirname(__file__), 'templates/sample.html')
	self.response.headers['Content-Type'] = 'text/html'
	self.response.out.write(str(template.render(temp,{})))
	
    def post(self):
        # Our POST Input
	self.session=Session()
        txtinput = self.request.get('txtValue')
	txtinput=txtinput.lower()
	mode=self.request.get('mode')
	
	if (txtinput =='show files' or txtinput == 'sf'):
	    txtinput="Show Files: Ciphers.py Subsitution.py transposition.py vigenere.py Affine.py ciphers.py"
        elif (txtinput == "help" or txtinput =='h'):
	    txtinput="Would you like to go to the tutorial for the Caesar cipher(chelp or ch), Substitution cipher(shelp or sh), Transposition cipher(thelp or th), Vigenere cipher(vhelp or vh), or Affine cipher(ahelp or ah)? You can also type toolbox(toolbox or tb) to use the ciphers."
	elif(txtinput == "chelp" or txtinput=="ch"):
		txtinput="The Caesar cipher works by substituting letters for different letters a certain number away from the original letter. For example, the letter 'A' with a key of 2 would become 'C' because C is 2 letters away from 'A'. The word 'CAT' would be encoded to say 'ECV'. To figure out the key to decode a message, you can keep trying numbers between 1 and 26 until one decodes the message into something that makes sense."
	elif(txtinput == "shelp" or txtinput=="sh"):
		txtinput="The substitution cipher has a key of 26 letters, each one in the alphabet, all reordered, and matches the old letters of the alphabet to the new ones. So if the letter 'A' maps to 'V' because it is the first letter of the key, 'B' maps to 'Q' because 'Q' is the second letter in the key. If 'T' maps to 'P', the code word for 'TAB' would be 'PVQ'."
	elif(txtinput == "thelp" or txtinput=="th"):
		txtinput="The transposition cipher works by mapping different letters to columns in a table, and then putting the rows of the table together to make the ciphertext. For example, to encode the sentence 'The apple is red.' with a key of 3, the cipher will make a table with 3 columns. Because there are 17 characters in this sentence, we take 17/3 which gives 5 with a remainder of 2. This means we need 6 rows and one space will not be used since there are 17 characters and 18 table entries. The cipher will put one letter in each column of the table so that they read [T,h,e; ,a,p;p,l,e; ,i,s; ,r,e;d,.,X] (commas separate columns, semicolumns separate rows) The resulting ciphertext will go down each column one at a time putting together the characters, giving the ciphertext 'T p  dhalir.epese'"
	elif(txtinput == "vhelp" or txtinput=="vh"):
		txtinput="The Vigenere cipher works almost like the Caesar cipher, except for every letter, the number of letters it shifts is different. The alphabet index of each letter in the key tells how many letters to shift each letter of plaintext. To encode the sentence 'The sky is blue' with the key 'cat', the index of each letter in the key 'cat' is the shift number. The first letter of the message 'T' will shift 3 letters since the first letter of the key is 'c', and its index is 3. So, the first letter of the ciphertext will be 'W'. The next letter will shift 1 because the index of a is one, so 'h' will become 'i'. The index of 't' is 20, so 'e' will shift 20 to become 'y'. When the letters in the key run out, it just starts over, so the next letter of the message 's' will shift 3 to 'v' because the next shift will be the letter 'c' again."
	elif(txtinput == "ahelp" or txtinput=="ah"):
		txtinput="The affine cipher has a few more steps than the other ciphers. First, it maps each letter of the plaintext to its alphabetic index starting at 0. The word 'SLEUTH' would map to the numbers 18, 11, 4, 20, 19, 7. Let's say we want to include special characters in our encoded alphabet, which will now have a length of 96 instead of 26. We then need to select two numbers for the key, and the first number has to be coprime with 96, meaning it does not share any factors with 96. Since 96's prime factors are 2 and 3, the first part of the key can be any number not divisible by 2 or 3. Our numbers a and b will be used in the equation ax+b, where x is the letter index and the result of which needs to be bigger than 96 for reasons we'll explain in a minute. We'll choose a to be 31 and b to be 57. When we use each letter's index as x in the equation, we get 615, 398, 181, 677, 646, 274. To map these numbers to our alphabet of symbols and letters, we need them to be mod 96. This means we want to divide them by 96 and use the remainder as the new number. After doing that, our new numbers are 39, 14, 85, 5, 70, 82. To get our key, we can multiply a by 96 and add b, which gives us 3033. Mapping the new numbers to their indexes in our alphabet gives us the ciphertext '&lTcEQ'."
	elif(txtinput == "tb" or txtinput=='toolbox'):
	    txtinput="You have selected toolbox. Please select a mode(e for Encryption, d for Decryption) and type a message( ex: d-Hello )?"
	elif(mode=='e' or mode=='d'):
	    self.session.delete_item('mode')
	    self.session['mode']=mode
	    msg=self.request.get('msg')
	    self.session.delete_item('msg')
	    self.session['msg']=msg
	    if (mode =='e'):
		mo="Encryption"
	    else:
		mo="Decryption"
	    txtinput="You have chosen " + mo +" and your message is " + msg + ". Please select which cipher you would like to use - Caesar cipher(c), Substitution cipher(s), Transposition cipher(t), Vigenere cipher(v), or Affine cipher(a). Please type \"use-cipher method\"(ex - use-s)"
	else:
	    txtinput="Error, invalid command! Please type again."
	array = {'text': txtinput}	    
        
       
        # Output the JSON
        self.response.headers['Content-Type'] = 'application/json'
        self.response.out.write(json.dumps(array))
开发者ID:geekyjulie,项目名称:ciphersleuth,代码行数:50,代码来源:main.py

示例10: AuthenticationPage

# 需要导入模块: from util.sessions import Session [as 别名]
# 或者: from util.sessions.Session import delete_item [as 别名]
class AuthenticationPage(webapp.RequestHandler):

    def get(self):
        logging.info("reached login page")
        path=self.request.path
        temp=os.path.join(os.path.dirname(__file__),'templates/login.html')
        html=template.render(temp,{})
        self.response.out.write(html)

    def post(self):
        import sys, getpass
        self.session=Session()
        username = self.request.get('username')
        password = self.request.get('password')
        self.session.delete_item('username')

        if username=='' or password=='':
            temp=os.path.join(os.path.dirname(__file__),'templates/login.html')
            html=template.render(temp,{'error':'Invalid Login'})
            self.response.out.write(html)
        else:
            token = ClientLogin().authorize(username, password)
            if token is not None:
                self.session['username']=username
                ft_client = ftclient.ClientLoginFTClient(token)
                self.session['ft_client']=ft_client
                results = ft_client.query(SQL().showTables())
                temp=os.path.join(os.path.dirname(__file__),'templates/index.html')
                html=template.render(temp,{'username':username})
                self.redirect("/house")
            else:
                logging.info("unable to login")
                temp=os.path.join(os.path.dirname(__file__),'templates/login.html')
                html=template.render(temp,{'error':'Invalid Login'})
                self.response.out.write(html)







        #show tables


        '''temp=os.path.join(os.path.dirname(__file__),'templates/index.html')
开发者ID:apurvagoyal,项目名称:Google-App-Engine-Fusion-Table-Sample,代码行数:48,代码来源:index.py

示例11: CapitalHandler

# 需要导入模块: from util.sessions import Session [as 别名]
# 或者: from util.sessions.Session import delete_item [as 别名]
class CapitalHandler(webapp.RequestHandler):

	def get(self): 
		self.session = Session()
		self.session.delete_item('username')
		doRender(self,'index.html')

	def post(self):
		self.session = Session()
		guess_capital = str(self.request.get('capital'))
		for country in country_data:
			if country['name']==self.session['country']:
				self.session['capital'] = country['capital']
		true_capital = self.session['capital']
		if guess_capital != true_capital:
			doRender(self, 'country.html', {'error': 'Guess again...'})
		else:
			doRender(self,'capital.html', {'capital': true_capital})
开发者ID:aisaacso,项目名称:annai-gamedemo,代码行数:20,代码来源:index.py

示例12: TransHandler

# 需要导入模块: from util.sessions import Session [as 别名]
# 或者: from util.sessions.Session import delete_item [as 别名]
class TransHandler(webapp.RequestHandler):
    def post(self):
	self.session=Session()
	mode = self.session.get("mode")
	msg=self.session.get("msg")
	
        txtinput = self.request.get('method')
	
	if (txtinput=='t'):
	    txtinput="You have chosen Transposition cipher. Your mode is " + mode +" and your message is " + msg +". Please enter a key(1<= key <= length of your message) (ex: tkey-3)" 
	elif (txtinput == 'key'):
	    key=int(self.request.get("keystr"))
	    maxlen=len(msg)
	    trans = transposition.TranspositionCipherTool(mode,msg,maxlen)
	    keynum=trans.display()
	    if(key >= 1 and key <= int(maxlen)):
		trans.storekey(key)
		translated=trans.getTranslatedMessage()
		txtinput="Your translated message is " + translated
	    else:
		self.session.delete_item("msg")
		txtinput="Your key is not valid. Please re-enter a new message( ex: tmsg-{'This is message'})"
	elif (txtinput=='tmsg'):
	    msg=self.request.get("keystr")
	    self.session['msg']=msg
	    txtinput="Please enter a key(1<= key <= length of your message) (ex: tkey-3)"
	else:
	    txtinput="Error, invalid command! Please type again. Please select which cipher you would like to use - Caesar cipher(c), Substitution cipher(s), Transposition cipher(t), Vigenere cipher(v), or Affine cipher(a). Please type \"use-cipher method\"(ex - use-s)"
	    
	    
	    
	   
	    
		
	    
	    
	array = {'text': txtinput}	    
        
       
        # Output the JSON
        self.response.headers['Content-Type'] = 'application/json'
        self.response.out.write(json.dumps(array))
开发者ID:geekyjulie,项目名称:ciphersleuth,代码行数:44,代码来源:main.py

示例13: MainHandler

# 需要导入模块: from util.sessions import Session [as 别名]
# 或者: from util.sessions.Session import delete_item [as 别名]
class MainHandler(webapp.RequestHandler):

	def get(self):
	
		path = (self.request.path).replace('/', '')
		datastore = DataStoreInterface()
		
		if (path <> '') and (path <> 'main.html'):
			if (datastore.companyProfileExists(path) == 1):				
				path = 'profiles.html?company='+path
				self.redirect(path)
			else:
				self.response.out.write('404: File not Found')
		else:
			render.doRender(self,'main.html', {})
	
	def post(self):
		
		self.session = Session()
		datastore = DataStoreInterface()
		
		email = self.request.get('txtEmail').strip()
		password = self.request.get('txtPassword')
		
		self.session.delete_item('user')
		
		#Check for any fields left empty
		if email == '' or password == '':
			render.doRender(self, 'main.html', {'error' : 'Please fill in all the details'})
			return
		
		username = datastore.loginUser(email, password)
		
		if datastore.isUser(email)== 1:
			if datastore.checkPass(email, password)==1:	
				self.session['user'] = username			
				self.redirect('controlpanel.html')
			else:
				render.doRender(self, 'main.html', {'error' : 'Wrong password'})
		else:
			render.doRender(self, 'main.html', {'error' : 'Email Address does not exist'})
开发者ID:filipmares,项目名称:SynapSync,代码行数:43,代码来源:main.py

示例14: LoginHandler

# 需要导入模块: from util.sessions import Session [as 别名]
# 或者: from util.sessions.Session import delete_item [as 别名]
class LoginHandler( webapp.RequestHandler ):
    def get( self ):
        doRender( self, 'login/loginscreen.htm' )

    def post( self ):
        self.session = Session()
        acct = self.request.get( 'account' ).lower()
        pw = self.request.get( 'password' ).lower()
        logging.info( 'checking account=' + acct + ' pw=' + pw )

        self.session.delete_item( 'username' )

        if pw == '' or acct == '':
            doRender( self, 'login/loginscreen.htm', {'error':'Please specify acct and pw'} )
            return
        user = User.all().filter( 'email =', db.Email( acct ) ).filter( 'password =', pw ).fetch( 1 )
        if len( user ) == 0:
            doRender( self, 'login/loginscreen.htm',
                     {'error' : 'Incorrect password'} )
        else:
            self.session['username'] = acct
            doRender( self, 'index.htm', {} )
开发者ID:jackdreilly,项目名称:iShakeBackend,代码行数:24,代码来源:index.py

示例15: GameloadHandler

# 需要导入模块: from util.sessions import Session [as 别名]
# 或者: from util.sessions.Session import delete_item [as 别名]
class GameloadHandler(webapp.RequestHandler):
    
    def get(self):
	self.session=Session()
	start_msg=""	
	gid=self.request.get("gid")
	
	self.session['game_id']=gid
	#get current level for game id
	result_game=(db.GqlQuery("SELECT * FROM GameDB WHERE game_id = :1", gid)).get()
    	glevel=result_game.current_level
	if (glevel):
	    start_msg="START THE GAME"
	#level=self.request.get("level")
	if (self.session.get('level')):
	    self.session.delete_item('level')
	self.session['level']=glevel

	
	temp = os.path.join(os.path.dirname(__file__), 'templates/gameload.html')
	self.response.headers['Content-Type'] = 'text/html'
	self.response.out.write(str(template.render(temp,{"start_msg":start_msg,"level":glevel})))
开发者ID:geekyjulie,项目名称:ciphersleuth,代码行数:24,代码来源:main.py


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