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


Python Session.get方法代码示例

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


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

示例1: VigenereHandler

# 需要导入模块: from util.sessions import Session [as 别名]
# 或者: from util.sessions.Session import get [as 别名]
class VigenereHandler(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=='v'):
	    txtinput="You have chosen Vigenere cipher. Your mode is " + mode +" and your message is " + msg +". Please enter a string of letters to use as a key(ex: vkey-ELFMENG)" 
	elif (txtinput == 'key'):
	    key=self.request.get("keystr")
	    vig = vigenere.VigenereCipherTool(mode,msg)
	    vig.storekey(key)
	    translated=vig.getTranslatedMessage()
	    txtinput="Your translated message is " + translated
	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,代码行数:29,代码来源:main.py

示例2: CaesarHandler

# 需要导入模块: from util.sessions import Session [as 别名]
# 或者: from util.sessions.Session import get [as 别名]
class CaesarHandler(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=='c'):
	    txtinput="You have chosen Caesar cipher. Your mode is " + mode +" and your message is " + msg +". Please enter key size(1-26) as key-{key size} (ex ckey-22)"
	
	elif (txtinput == 'key'):
	    key=self.request.get("keynum")
	    caes = caesar.CaesarCipherTool(mode,msg)
	    #get key
	    if(int(key) >= 1 and int(key) <= 26):
		txtinput="Your key is " + key
		caes.storekey(key)
		txtinput="Your translated message: " + caes.getTranslatedMessage() + ". Please type tb for toolbox, h for help"
		
	    else:
		txtinput="Your key is not valid it must be in range (1 <= key <= 26). Please try again. key-{key size} (ex ckey-22)" + key
	
	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,代码行数:34,代码来源:main.py

示例3: CaesarHandler

# 需要导入模块: from util.sessions import Session [as 别名]
# 或者: from util.sessions.Session import get [as 别名]
class CaesarHandler(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=='c'):
	    txtinput="You have chosen Caesar cipher. Your mode is " + mode +" and your message is " + msg +". Please enter key size(1-26) as key-{key size} (ex ckey-22)" 
	elif (txtinput == 'key'):
	    key=self.request.get("keynum")
	    caes = caesar.CaesarCipherTool(mode,msg)
	    #get key
	    if(int(key) >= 1 and int(key) <= 26):
		txtinput="Your key is " + key
		caes.storekey(key)
		txtinput="Your translated message: " + caes.getTranslatedMessage() + ". Please type tb for toolbox, h for help"
		
	    else:
		txtinput="Your key is not valid it must be in range (1 <= key <= 26). Please try again. key-{key size} (ex ckey-22)" + key
	    
	    
	array = {'text': txtinput}	    
        
       
        # Output the JSON
        self.response.headers['Content-Type'] = 'application/json'
        self.response.out.write(json.dumps(array))
开发者ID:jancybsec,项目名称:ciphersleuth,代码行数:31,代码来源:main.py

示例4: TDSettingHandler

# 需要导入模块: from util.sessions import Session [as 别名]
# 或者: from util.sessions.Session import get [as 别名]
class TDSettingHandler(BaseHandler):
    def get(self):
        if self.guest():
            return
        self.session = Session()
        key = self.session.get('userkey')
        user = db.get(key) 
        form = UserForm()
        self.doRender( 'td_setting.html', {'form': form, 'u': user, \
                'info': ', please update your profile'})

    def post(self):
        self.session = Session()
        pkey = self.session.get('userkey')
        user = db.get(pkey)
  
        form = UserForm(self.request.POST)
        if form.validate():
            user.cwid = form.cwid.data 
            user.major = form.major.data 
            user.email = form.email.data 
            user.phone = form.phone.data 
            user.d_hours = form.d_hours.data
            user.put()

            self.doRender( 'td_setting.html', {'msg' : ', profile updated', 'u': user} )
        else: # form validation failed
            self.doRender('td_setting.html', {'form': form})
开发者ID:3ancho,项目名称:IITVs,代码行数:30,代码来源:views.py

示例5: SubstitutionHandler

# 需要导入模块: from util.sessions import Session [as 别名]
# 或者: from util.sessions.Session import get [as 别名]
class SubstitutionHandler(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=='s'):
	    txtinput="You have chosen Substitution. Your mode is " + mode +" and your message is " + msg +". Please enter the 26-letter string of characters to use as a key (ex skey-QWERTYUIOPASDFGHJKLZXCVBNM)" 
	elif (txtinput == 'key'):
	    key=str(self.request.get("keystr"))
	    subs = substitution.SubstitutionCipherTool(mode,msg)
	    if (subs.checkValidKey(key) != True):
			txtinput="The key you entered is not valid. Please re-enter the 26-letter string of characters to use as a key (ex skey-QWERTYUIOPASDFGHJKLZXCVBNM)"
	    else:
			subs.storekey(key)
			translated=subs.getTranslatedMessage()
			txtinput="Your translated message is " + translated
	    
	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,代码行数:30,代码来源:main.py

示例6: VigenereHandler

# 需要导入模块: from util.sessions import Session [as 别名]
# 或者: from util.sessions.Session import get [as 别名]
class VigenereHandler(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=='v'):
	    txtinput="You have chosen Vigenere cipher. Your mode is " + mode +" and your message is " + msg +". Please enter a string of letters to use as a key(ex: vkey-ELFMENG)" 
	elif (txtinput == 'key'):
	    key=self.request.get("keystr")
	    vig = vigenere.VigenereCipherTool(mode,msg)
	    vig.storekey(key)
	    translated=vig.getTranslatedMessage()
	    txtinput="Your translated message is " + translated
	    
	    
	array = {'text': txtinput}	    
        
       
        # Output the JSON
        self.response.headers['Content-Type'] = 'application/json'
        self.response.out.write(json.dumps(array))
开发者ID:jancybsec,项目名称:ciphersleuth,代码行数:27,代码来源:main.py

示例7: SubstitutionHandler

# 需要导入模块: from util.sessions import Session [as 别名]
# 或者: from util.sessions.Session import get [as 别名]
class SubstitutionHandler(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=='s'):
	    txtinput="You have chosen Substitution. Your mode is " + mode +" and your message is " + msg +". Please enter the 26-letter string of characters to use as a key (ex skey-QWERTYUIOPASDFGHJKLZXCVBNM)" 
	elif (txtinput == 'key'):
	    key=str(self.request.get("keystr"))
	    subs = substitution.SubstitutionCipherTool(mode,msg)
	    if (subs.checkValidKey(key) != True):
			txtinput="The key you entered is not valid. Please re-enter the 26-letter string of characters to use as a key (ex skey-QWERTYUIOPASDFGHJKLZXCVBNM)"
	    else:
			subs.storekey(key)
			translated=subs.getTranslatedMessage()
			txtinput="Your translated message is " + translated
	    
	    
	array = {'text': txtinput}	    
        
       
        # Output the JSON
        self.response.headers['Content-Type'] = 'application/json'
        self.response.out.write(json.dumps(array))
开发者ID:jancybsec,项目名称:ciphersleuth,代码行数:29,代码来源:main.py

示例8: MainHandler

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

	    
	#filepath = self.request.path
	self.session = Session()
      
	loggedUser=""
	greeting=""
	
	if (self.session.get('username')):
		greeting="Welcome, "
		loggedUser = self.session.get('username')
      	
	
	if (self.session.get('role') == 'teacher'):
	    
	   
	    temp = os.path.join(os.path.dirname(__file__), 'templates/teachermain.html')
	     #self.response.out.write(temp)
	    self.response.headers['Content-Type'] = 'text/html'
	    self.response.out.write(str(template.render(temp,{'loggedUser':loggedUser, "greeting":greeting})))
	 
	elif (self.session.get('role') == 'student'):
	    
	    temp = os.path.join(os.path.dirname(__file__), 'templates/studentmain.html')
	     #self.response.out.write(temp)
	    self.response.headers['Content-Type'] = 'text/html'
	    self.response.out.write(str(template.render(temp,{'loggedUser':loggedUser, "greeting":greeting})))
	 
	else:
	   
	    temp = os.path.join(os.path.dirname(__file__), 'templates/main.html')
	    self.response.headers['Content-Type'] = 'text/html'
	    self.response.out.write(str(template.render(temp,{'loggedUser':loggedUser, "greeting":greeting})))
开发者ID:geekyjulie,项目名称:ciphersleuth,代码行数:37,代码来源:main.py

示例9: ShowUserHandler

# 需要导入模块: from util.sessions import Session [as 别名]
# 或者: from util.sessions.Session import get [as 别名]
class ShowUserHandler(webapp.RequestHandler):
    def get(self):
        self.session = Session()
        pkey = self.session.get('userkey')
        current_user = db.get(pkey)
        if current_user.admin == "True":
            doRender(self, 'show_user.html', { })
        else:
            doRender(self, 'main.html', {'msg' : 'Require admin previlege!'})

    def post(self):
        self.session = Session()
        pkey = self.session.get('userkey')
        current_user = db.get(pkey)
        
        if current_user.admin == "False":
            doRender(self, 'main.html', {'msg' : 'Require admin previlege!'})
            return

        que = db.Query(User)
        
        if self.request.get('show_admin') == 'True': # if this will show admin
            admin = que.filter('admin =', 'True')
            admin = admin.fetch(limit = 100) 
            doRender(self, 'show_user.html', {'user_list' : admin } )
            return
        else:
            user = que.filter('admin =', 'False')
            user = user.fetch(limit = 500)
            doRender(self, 'show_user.html', {'user_list' : user } )
            return
开发者ID:herohunfer,项目名称:IITVs,代码行数:33,代码来源:index.py

示例10: TmainHandler

# 需要导入模块: from util.sessions import Session [as 别名]
# 或者: from util.sessions.Session import get [as 别名]
class TmainHandler(webapp.RequestHandler):
    def get(self):
	self.session=Session()
	logged_name=self.session.get("username")
	logged_id=self.session.get("id")
	greeting="Hello"
	
	lookup=(db.GqlQuery("SELECT * FROM TeacherDB WHERE teacher_id = :1", logged_id)).get()
	classid_teacher=lookup.teacher_class_id
	result=(db.GqlQuery("SELECT * FROM StudentDB WHERE classid = :1", classid_teacher)).fetch(limit=100)
	 	
	temp = os.path.join(os.path.dirname(__file__), 'templates/tcontrol.html')
	self.response.headers['Content-Type'] = 'text/html'
	self.response.out.write(str(template.render(temp,{'loggedUser':logged_id, "greeting":greeting,"result":result})))
开发者ID:geekyjulie,项目名称:ciphersleuth,代码行数:16,代码来源:main.py

示例11: DeleteUserHandler

# 需要导入模块: from util.sessions import Session [as 别名]
# 或者: from util.sessions.Session import get [as 别名]
class DeleteUserHandler(webapp.RequestHandler):
    def post(self):
        self.session = Session()
        pkey = self.session.get('userkey')
        current_user = db.get(pkey)
        
        if current_user.admin == "False":
            doRender(self, 'main.html', {'msg' : 'Require admin previlege!'})
            return

        delete_list = self.request.get_all('key_to_delete')
        ''' # Testing!
        doRender(self, 'test.html', {'msg' : first[0], 'msg2': str(len(first))})
        return
        '''
        if len(delete_list) == 0:
            doRender(self, 'show_user.html', {})
            return

        for item in delete_list:
            que = db.Query(User).filter('username =', item)
            result = que.fetch(limit = 1)
            result[0].delete()

        doRender(self, 'show_user.html', {})
开发者ID:herohunfer,项目名称:IITVs,代码行数:27,代码来源:index.py

示例12: ManageEventHandler

# 需要导入模块: from util.sessions import Session [as 别名]
# 或者: from util.sessions.Session import get [as 别名]
class ManageEventHandler(BaseHandler):
    '''The parent page is event view'''
    def post(self):
        if self.guest():
            return
        self.session = Session()
        pkey = self.session.get('userkey')
        current_user = db.get(pkey) # got user
       
        t_note = self.request.get('note')
        t_active = self.request.get('active_status')
        ckey = self.request.get('session_key')
        update = self.request.get('update_event')
        ckey = self.request.get('session_key') 
        csession = db.get(ckey) # got session
        td = csession.td # got TD
        
        if update == 'True': 
            new_event = csession.event
            new_event.active = (t_active == 'True')
            new_message = Message(note = t_note, user = current_user)
            new_event.messages.append( new_message.put())
            new_event.put()
        else:
            new_message = Message(note = t_note, user = current_user)
            new_event = Event(active = t_active == 'True', csession = ckey)
            new_event.messages.append( new_message.put() )
            csession.event = new_event.put() # put event, and, update session.event
            csession.put()

        message_list = toList(new_event)
        self.doRender('show_event.html', {'td': td, 'session': csession, \
                'event': new_event, 'msg':'Event just updated', \
                'message_list': message_list, 'session_key': ckey})
开发者ID:3ancho,项目名称:IITVs,代码行数:36,代码来源:views.py

示例13: EventHandler

# 需要导入模块: from util.sessions import Session [as 别名]
# 或者: from util.sessions.Session import get [as 别名]
class EventHandler(BaseHandler):
    '''The parent page is Main'''
    def post(self):
        if self.guest():
            return
        self.session = Session()
        pkey = self.session.get('userkey')
        user = db.get(pkey) # got current user

        ckey = self.request.get('session_key') 
        csession = db.get(ckey) # got the target session

        td = csession.td #  target session.td
        event = csession.event # target session.event
        

        if event != None:
            message_list = toList(event)
            self.doRender('show_event.html', {'td': td, 'session': csession, \
                    'event': event, 'session_key': ckey, 'message_list': message_list})
        else: # not event yet
            if td != None and td.username == user.username:
                self.doRender('add_event.html', {'td': td, 'session': csession, \
                        'session_key': ckey, 'apply_off': 'True' }) 
            else:
                self.doRender('add_event.html', {'td': td, 'session': csession, \
                        'session_key': ckey})
开发者ID:3ancho,项目名称:IITVs,代码行数:29,代码来源:views.py

示例14: LogoutHandler

# 需要导入模块: from util.sessions import Session [as 别名]
# 或者: from util.sessions.Session import get [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

示例15: editprofile

# 需要导入模块: from util.sessions import Session [as 别名]
# 或者: from util.sessions.Session import get [as 别名]
class editprofile(webapp.RequestHandler):
    
    def get(self):
        #check for sessions here to det which template to render
        
       data = {}
       #check if there's a username entry in the session
       self.session = Session()
    
       data['user'] =  self.session.get('username', None)
       user  = self.session.get('username', None)
       if user:
           que = db.Query(Poller)
           que.filter('email', user)
           res  = que.fetch(limit=1)
           current_user = res[0]
           data['email'] = current_user.email
           data['fullname'] = current_user.fullname
           data['password'] = current_user.password
           
           render(self,"profile.html",data)
        
       else:
            render(self, "index.html",data)
       
    def post(self):
        data={}
        em = self.request.get('em') 
        pw = self.request.get('pw')
        pwa = self.request.get('pwa')
        fn = self.request.get('fn')
        
        if pw == pwa:
            que = db.Query(Poller)
            que.filter('email',em)
            res = que.fetch(limit=1)
            
            poller = res[0] #get the first (and only)  dude in the match
            poller.fullname = fn
            poller.password = pw
            poller.put()
            data['updatesuccess'] = True
            render(self,"profile.html",data)
        else:
            data['pwmismatch'] = True
            data['error_msg'] = "The passwords you are trying to change do not match"
            render(self,"profile.html", data)
开发者ID:adekola,项目名称:poller-app,代码行数:49,代码来源:pollerdashboard.py


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