• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python meeplib.get_user函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中meeplib.get_user函数的典型用法代码示例。如果您正苦于以下问题:Python get_user函数的具体用法?Python get_user怎么用?Python get_user使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: create_user

    def create_user(self, environ, start_response):
        # get cookie if there is one
        try:
            cookie = Cookie.SimpleCookie(environ["HTTP_COOKIE"])
            username = cookie["username"].value
        except:
            username = ''
        
        user = meeplib.get_user(username)
        if user is not None:
            headers = [('Content-type', 'text/html')]
            headers.append(('Location', '/'))
            start_response("302 Found", headers)
            return ["You must be logged out to use that feature."]

        headers = [('Content-type', 'text/html')]

        print environ['wsgi.input']
        form = cgi.FieldStorage(fp=environ['wsgi.input'], environ=environ)

        try:
            username = form['username'].value
        except KeyError:
            username = ''

        try:
            password = form['password'].value
        except KeyError:
            password = ''

        s=[]

        ##if we have username and password
        if username != '':
            user = meeplib.get_user(username)
            ## user already exists
            if user is not None:
                s.append('''Creation Failed! <br>
                    User already exists, please use a different username.<p>''')
            ## user doesn't exist but they messed up the passwords
            elif password == '':
                s.append('''Creation Failed! <br>
                    Please fill in the Password field<p>''')
            else:
                u = meeplib.User(username, password)
                meeplib.save_state()
                ## send back a redirect to '/'
                k = 'Location'
                v = '/'
                headers.append((k, v))
                cookie_name, cookie_val = meepcookie.make_set_cookie_header('username',username)
                headers.append((cookie_name, cookie_val))

        start_response('302 Found', headers)

        s.append(render_page("create_user.html", username=username))
        return [''.join(s)]
开发者ID:SheikGeek,项目名称:meep,代码行数:57,代码来源:meep_example_app.py


示例2: reply_action

    def reply_action(self, environ, start_response):

        print environ["wsgi.input"]
        form = cgi.FieldStorage(fp=environ["wsgi.input"], environ=environ)

        post = form["post"].value

        # username = 'aLlama'

        cookie = Cookie.SimpleCookie(environ["HTTP_COOKIE"])
        username = cookie["username"].value

        user = meeplib.get_user(username)

        new_message = meeplib.Message(post, user)
        thread_id = int(form["thread_id"].value)

        t = meeplib.get_thread(thread_id)
        t.add_post(new_message)
        meeplib.save()

        headers = [("Content-type", "text/html")]
        headers.append(("Location", "/m/list"))
        start_response("302 Found", headers)
        return ["reply added"]
开发者ID:hairlessllama,项目名称:meep,代码行数:25,代码来源:meep_example_app.py


示例3: reply

	def reply(self, environ, start_response):
		print "enter reply"
		username = check_cookie(environ)
		user = meeplib.get_user(username)
		if user is None:
			headers = [('Content-type', 'text/html')]
			headers.append(('Location', '/'))
			start_response("302 Found", headers)
			return ["log in to use that feature"]
		headers = [('Content-type', 'text/html')]
		form = cgi.FieldStorage(fp=environ['wsgi.input'], environ=environ)
		thread_id = int(form['thread_id'].value)
		t = meeplib.get_thread(thread_id)
		s = []
		try:
			post = form['post'].value
		except KeyError:
			post = ''
		if post != '':
			new_message = meeplib.Message(post, user)
			t.add_post(new_message)
			meeplib.save_state()
			headers.append(('Location','/m/list'))
		start_response("302 Found", headers)
		s.append(render_page("reply.html", thread=t))
		print "exit reply"
		return ["".join(s)]
开发者ID:caitsydney,项目名称:meep,代码行数:27,代码来源:meep_example_app.py


示例4: index

    def index(self, environ, start_response):
        start_response("200 OK", [("Content-type", "text/html")])
        # get cookie if there is one
        try:
            cookie = Cookie.SimpleCookie(environ["HTTP_COOKIE"])
            username = cookie["username"].value
            print "Username = %s" % username
        except:
            print "session cookie not set! defaulting username"
            username = ""

        user = meeplib.get_user(username)
        print "User = %s" % user
        if user is None:
            s = [
                """<h1>Welcome <i style = "color:red;">Human</i>!</h1><h2>Please Login or create an account.</h2>
<form action='login' method='POST'>
Username:<input type='text' name='username'><br>
Password:<input type='password' name='password'>&nbsp;<br>
<input type='submit' value='Login'></form>

<p>Don't have an account? Create a user <a href='/create_user'>here</a>"""
            ]

        elif user is not None:
            s = [
                """%s logged in!<p><a href='/m/add_message'>Add a Message</a><p><a href='/create_user'>Create a User</a><p><a href='/logout'>Log out</a><p><a href='/m/list'>Show All Messages</a>"""
                % (username,)
            ]
        return s
开发者ID:hairlessllama,项目名称:meep,代码行数:30,代码来源:meep_example_app.py


示例5: login

    def login(self, environ, start_response):
        username = 'sessionuser'
        session_cookie = str(uuid.uuid4())
        username=str(username)
        cur.execute('INSERT INTO sessions (username, cookie) VALUES (?, ?)', (username, session_cookie))
        con.commit()
        print "THE COOKIE",session_cookie
        usernameDB=session_get(cur,session_cookie)
        print "THE USERNAMEDB ",usernameDB



        # hard code the username for now; this should come from Web input!

        # retrieve user
        user = meeplib.get_user(username)

        # set content-type
        headers = [('Content-type', 'text/html')]
        #cookies
        cookie_name, cookie_val = meepcookie.make_set_cookie_header('username',session_cookie)

        headers.append((cookie_name, cookie_val))
        # send back a redirect to '/'
        k = 'Location'
        v = '/'
        headers.append((k, v))
        start_response('302 Found', headers)
        
        return "no such content"
开发者ID:kgleas,项目名称:meep,代码行数:30,代码来源:meep_example_app.py


示例6: delete_message_action

    def delete_message_action(self, environ, start_response):
        # get cookie if there is one
        try:
            cookie = Cookie.SimpleCookie(environ["HTTP_COOKIE"])
            username = cookie["username"].value
            #print "Username = %s" % username
        except:
            #print "session cookie not set! defaulting username"
            username = ''
        
        user = meeplib.get_user(username)
        if user is None:
            headers = [('Content-type', 'text/html')]
            headers.append(('Location', '/'))
            start_response("302 Found", headers)
            return ["You must be logged in to use that feature."]

        print environ['wsgi.input']
        form = cgi.FieldStorage(fp=environ['wsgi.input'], environ=environ)

        thread_id = int(form['thread_id'].value)
        post_id = int(form['post_id'].value)

        t = meeplib.get_thread(thread_id)
        post = t.get_post(post_id)
        t.delete_post(post)
        meeplib.save_state()

        headers = [('Content-type', 'text/html')]
        headers.append(('Location', '/m/list'))
        start_response("302 Found", headers)

        return["post deleted"]
开发者ID:remd,项目名称:meep,代码行数:33,代码来源:meep_example_app.py


示例7: add_message_action

    def add_message_action(self, environ, start_response):
        if self.username is None:
            headers = [('Content-type', 'text/html')]
            start_response("302 Found", headers)
            return ["You must be logged in to use this feature <p><a href='/login'>Log in</a><p><a href='/m/list'>Show messages</a>"]


        print environ['wsgi.input']
        form = cgi.FieldStorage(fp=environ['wsgi.input'], environ=environ)

        title = form['title'].value
        message = form['message'].value
        parent = int(form['parent_id'].value)
        
        user = meeplib.get_user(self.username)
        
        new_message = meeplib.Message(title, message, user, parent)
  
        with con:
            cur.execute("INSERT INTO Messages (ID, Title, Post, Author, Parent) VALUES (?, ?, ?, ?, ?)", (new_message.id, title, message, self.username, parent))
			
        con.commit()
        #meeplib.save()

        headers = [('Content-type', 'text/html')]
        headers.append(('Location', '/m/list'))
        start_response("302 Found", headers)
        return ["message added"]
开发者ID:hessler4,项目名称:meep,代码行数:28,代码来源:meep_example_app.py


示例8: logout

    def logout(self, environ, start_response):
        # get cookie if there is one
        try:
            cookie = Cookie.SimpleCookie(environ["HTTP_COOKIE"])
            username = cookie["username"].value
            #print "Username = %s" % username
        except:
            #print "session cookie not set! defaulting username"
            username = ''
        
        user = meeplib.get_user(username)
        if user is None:
            headers = [('Content-type', 'text/html')]
            headers.append(('Location', '/'))
            start_response("302 Found", headers)
            return ["You must be logged in to use that feature."]

        headers = [('Content-type', 'text/html')]

        # send back a redirect to '/'
        k = 'Location'
        v = '/'
        headers.append((k, v))
        cookie_name, cookie_val = meepcookie.make_set_cookie_header('username','')
        headers.append((cookie_name, cookie_val))
        start_response('302 Found', headers)
        return "no such content"
开发者ID:remd,项目名称:meep,代码行数:27,代码来源:meep_example_app.py


示例9: login

    def login(self, environ, start_response):
        # hard code the username for now; this should come from Web input!
        username = 'test'

        # retrieve user
        user = meeplib.get_user(username)

        # set content-type
        headers = [('Content-type', 'text/html')]

        cookie_name, cookie_val = \
                     meepcookie.make_set_cookie_header('username',
                                                       user.username)
        
	
	print "setting cookie!!!"
	headers.append((cookie_name, cookie_val))
        
        # send back a redirect to '/'
        k = 'Location'
        v = '/'
        headers.append((k, v))
        start_response('302 Found', headers)
        
        return "no such content"
开发者ID:bachelis,项目名称:meep,代码行数:25,代码来源:meep_example_app.py


示例10: add_message_action

    def add_message_action(self, environ, start_response):
        print environ['wsgi.input']
        form = cgi.FieldStorage(fp=environ['wsgi.input'], environ=environ)

        title = form['title'].value
        message = form['message'].value
        pID = form['pID'].value
        
        username = meeplib.get_curr_user()
        user = meeplib.get_user(username)
        
        conn = sqlite3.connect('meep.db')
        c = conn.cursor()
        c.execute("INSERT INTO Message VALUES('" + title + "', '" + message + "', '" + username + "', '" + pID + "')")
        conn.commit()

        #new_message = meeplib.Message(title, message, user, pID)

        headers = [('Content-type', 'text/html')]
        headers.append(('Location', '/m/list'))
        start_response("302 Found", headers)
        
        #SaveMessages()

        if(pID != '!'):
            return ["Message Added"]
        else:
            return ["Reply Added"]
开发者ID:kienlebr,项目名称:meep,代码行数:28,代码来源:meep_example_app.py


示例11: add_message_topic_action

    def add_message_topic_action(self, environ, start_response):
        form = cgi.FieldStorage(fp=environ['wsgi.input'], environ=environ)

        topicId = form['topicid'].value
        topic = meeplib.get_topic(int(topicId))
        
        title = form['title'].value
        message = form['message'].value
        
        cookie = environ.get('HTTP_COOKIE', '')

        username = meepcookie.load_username(cookie)
        print username
        user = meeplib.get_user(username)
        print user
        
        if username != "":
            #print title, message, user
            new_message = meeplib.Message(title, message, user)
            
            topic.add_message(new_message)
            print "Message added to topic" + topicId
            
            headers = [('Content-type', 'text/html')]
            headers.append(('Location', '/m/topics/view?id=%d' % (topic.id)))
            start_response("302 Found", headers)
            return ["message added to topic"]
        else:
            headers = [('Content-type', 'text/html')]
            headers.append(('Location', '/login'))
            start_response("302 Found", headers)
            return ["session expired"]
开发者ID:Solatrus,项目名称:meep,代码行数:32,代码来源:meep_example_app.py


示例12: add_topic_action

    def add_topic_action(self, environ, start_response):
        print environ['wsgi.input']
        form = cgi.FieldStorage(fp=environ['wsgi.input'], environ=environ)

        title = form['title'].value
        msgtitle = form['msgtitle'].value
        message = form['message'].value
        
        cookie = environ.get('HTTP_COOKIE', '')
        username = meepcookie.load_username(cookie)
        
        if username == "":
            headers = [('Content-type', 'text/html')]
            headers.append(('Location', '/login'))
            start_response("302 Found", headers)
            
            return ["session ended"]
            
        user = meeplib.get_user(username)
        
        new_message = meeplib.Message(msgtitle, message, user)
        new_topic = meeplib.Topic(title, new_message, user)

        headers = [('Content-type', 'text/html')]
        headers.append(('Location', '/m/list_topics'))
        start_response("302 Found", headers)
        return ["topic added"]
开发者ID:Solatrus,项目名称:meep,代码行数:27,代码来源:meep_example_app.py


示例13: authHandler

 def authHandler(self, environ):
     try:
         cookie = Cookie.SimpleCookie(environ["HTTP_COOKIE"])
         username = cookie["username"].value
         return meeplib.get_user(username)
     except:
         return None
开发者ID:byblivro,项目名称:meep,代码行数:7,代码来源:meep_example_app.py


示例14: create_user

	def create_user(self, environ, start_response):
		print "enter create user"
		username = check_cookie(environ)
		user = meeplib.get_user(username)
		if user is not None:
			headers = [('Content-type', 'text/html')]
			headers.append(('Location', '/'))
			start_response("302 Found", headers)
			return ["log out to use that feature"]
		headers = [('Content-type', 'text/html')]
		form = cgi.FieldStorage(fp=environ['wsgi.input'], environ=environ)
		try:
			username = form['username'].value
		except KeyError:
			username = ''
		try:
			password = form['password'].value
		except KeyError:
			password = ''
			
		s=[]

		##if we have username and password
		if username != '':
			user = meeplib.get_user(username)
			## user already exists
			if user is not None:
				s.append('''user already exists; <br>
				please use a different username.<p>''')
			## user doesn't exist but they messed up the passwords
			elif password == '':
				s.append('''enter a password <br/>''')
			else:
				u = meeplib.User(username, password)
				meeplib.save_state()
				## send back a redirect to '/'
				k = 'Location'
				v = '/'
				headers.append((k, v))
				cookie_name, cookie_val = meepcookie.make_set_cookie_header('username',username)
				headers.append((cookie_name, cookie_val))

		start_response('302 Found', headers)

		s.append(render_page("create_user.html", username=username))
		print "exit create user"
		return [''.join(s)]
开发者ID:caitsydney,项目名称:meep,代码行数:47,代码来源:meep_example_app.py


示例15: alter_message_action

    def alter_message_action(self, environ, start_response):
        post = (environ.get('REQUEST_METHOD') == 'POST')
        if post:
            form = cgi.FieldStorage(fp=environ['wsgi.input'], environ=environ)
        else:
            form = parse_qs(environ['QUERY_STRING'])
        """
        try:
            form = cgi.FieldStorage(fp=environ['wsgi.input'], environ=environ)
            #params = dict([part.split('=') for part in environ['QUERY_STRING'].split('&')])
            #msgId = int(params['id'])
        except:
            headers = [('Content-type', 'text/html')]
            start_response("200 OK", headers)
            return ["Error Processing provided ID"]

        id = int(form['id'].value)
        
        action = form['bttnSubmit'].value
        """

        print 'post %s' % (post,)
        id = int(self.get_value(form,post,'id',''))
        action = self.get_value(form,post,'bttnSubmit','')
        msg = meeplib.get_message(id)
        
        error = False
        errorMsg = ""
        response = "200 OK"
        
        headers = [('Content-type', 'text/html')]
        u = self.getUser(environ)
        if u == None:
            error = True
            errorMsg = """You must be logged in to proceed."""
        if msg == None:
            error = True
            errorMsg = """Message id: %d could not be found.""" % (id,)
        elif action == "Delete":
            if msg.author.username == u.username:
                meeplib.delete_message(msg)
                response = "302 Found"
                headers.append(('Location', '/'))
                errorMsg = "message removed"
            else:
                errorMsg = "You cannot delete another user's post."
        elif action == "Reply":
            title = ""
            message = form['replyText'].value
            user = meeplib.get_user(u.username)
            new_message = meeplib.Message(title, message, user, True)
            msg.add_reply(new_message)
            response = "302 Found"
            headers.append(('Location', '/'))
            errorMsg = "message replied"

        start_response(response, headers)
        return [errorMsg]
开发者ID:hkb261,项目名称:meep,代码行数:58,代码来源:meep_example_app.py


示例16: add_message

def add_message(title, message, pid):
    try:
        username = "test"
        user = meeplib.get_user(username)

        new_message = meeplib.Message(title, message, user, pid)
        return new_message.id
    except:
        return -1
开发者ID:kienlebr,项目名称:meep,代码行数:9,代码来源:serve_meep_rpc.py


示例17: test_message_ownership

    def test_message_ownership(self):
        x = meeplib.get_all_users()
        assert len(x) != 0
        u = meeplib.get_user('foo')

        x = meeplib.get_all_messages()
        assert len(x) != 0
        m = x[len(x) - 1]

        assert m.author == u
开发者ID:kienlebr,项目名称:meep,代码行数:10,代码来源:test_meeplib.py


示例18: tearDown

    def tearDown(self):
        m = meeplib.get_message(self.msgId)
        if m != None:
            meeplib.delete_message(m)
            

        l = len(meeplib.get_all_users())
        meeplib.delete_user(meeplib.get_user(self.ux))
        lafter = len(meeplib.get_all_users())
        
        assert l > lafter
开发者ID:hkb261,项目名称:meep,代码行数:11,代码来源:test_meeplib.py


示例19: test_get_next_message_id

 def test_get_next_message_id(self):
     #there should be 1 message initially created
     assert meeplib._get_next_message_id() == 1
     user = meeplib.User('admin', 'admin')
     user.insertIntoDB()
     author = meeplib.get_user('admin')
     message = meeplib.Message('title', 'message', author.id, -1)
     message.insertIntoDB()
     
     #there should not be two messages
     assert meeplib._get_next_message_id() == 2
开发者ID:benjaminkatt,项目名称:meep,代码行数:11,代码来源:test_meeplib.py


示例20: index

	def index(self, environ, start_response):
		print "enter index"
		start_response("200 OK", [('Content-type', 'text/html')])
		username = check_cookie(environ)
		user = meeplib.get_user(username)
		if user is None:
			print "exit index"
			return [ render_page('login.html') ]
		elif user is not None:
			print "exit index"
			return [ render_page('index.html', username=username) ]
开发者ID:caitsydney,项目名称:meep,代码行数:11,代码来源:meep_example_app.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python meetup.meetup函数代码示例发布时间:2022-05-27
下一篇:
Python io.save函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap