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


Python user.User类代码示例

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


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

示例1: create_1000_users_in_Parse

def create_1000_users_in_Parse():

    li_u = []

    for i in range(1000):
        u = _User()
        li_u.append(u)

    register_for_events(li_u)

    for u in li_u:

        User.signup( username = u.username, password = "1234", 
            u_num = u.u_num,
            sex = u.sex,
            age = u.age,
            eyes = u.eyes,
            dob = u.dob,
            full_name = u.full_name,
            first_name = u.first_name,
            last_name = u.last_name,
            college = u.college,
            email_address = u.email_address,
            li_events_registered = u.li_events_registered)

        print "User {} signed up.".format(u.u_num)


    # batcher = ParseBatcher()
    # batcher.batch_save(li_u)

    pass
开发者ID:AlexChick,项目名称:daeious-event-dev,代码行数:32,代码来源:Parse_1000_Users.py

示例2: test_today_pings

  def test_today_pings(self):
    assignTask = Function("assignTask")
    ping = Function("ping")
    u1 = User.login('redsox55', 'secure123')
    assignee = User.Query.get(username='deepthroat')
    with SessionToken(u1.sessionToken):
      title = 'serha34g444'
      response = assignTask(
        title=title,
        description="Send a ping to this task",
        watchers=[u[2] for u in sample_users],
        score=2,
        assignee=assignee.email,
      )
    self.assertIn('task', response['result'])

    todayPings = Function('todayPings')
    with SessionToken(u1.sessionToken):
      task = Task.Query.get(title=title)
      ping(taskId=task.objectId)
      todayPingsU1 = todayPings()
    print "TODAY PINGS U1: %s" % todayPingsU1
    self.assertEqual(len(todayPingsU1['result']), 1)

    u2 = User.login('baracky', 'usanumber1')
    with SessionToken(u2.sessionToken):
      ping(taskId=task.objectId)
      ping(taskId=task.objectId)
      todayPingsU2 = todayPings()
    print "TODAY PINGS U2: %s" % todayPingsU2
    self.assertEqual(len(todayPingsU2['result']), 2)
开发者ID:danrobinson,项目名称:PingBox,代码行数:31,代码来源:tests.py

示例3: Login

def Login(userIDClass):
    global username, userDetails
    username = usernameEntry.get()
    password = passwordEntry.get()
    myClassName = 'User'
    myClass = Object.factory(myClassName)
    username = str(username.lower())
    Id = userDetails[username]
    print(Id)
    data = myClass.Query.get(objectId = Id)
    teacher = data.teacher
    print(teacher)
    if username in userDetails:
        print('Logging in')
        try:
            User.login(username, password)
            print('Logged in')
            currentUserLabel.config(text = 'Logged in as '+username+'. Class: '+userIDClass[Id])
            if teacher == False:
                outputUserResults()
                newWordButton.config(state = DISABLED)
                quizSelectButton.config(state = NORMAL)
            else:
                newWordButton.config(state = NORMAL)
                quizSelectButton.config(state = DISABLED)
                resultsList.delete(0, END)
                findTeachersPupils(Id)
        except:
            print('Incorrect password')
            currentUserLabel.config(text = 'Incorrect password')
    else:
        currentUserLabel.config(text = 'That is an invalid username')
        print('That is an invalid username')
    print('FUNCTION: userLogin COMPLETE')
    print(time.asctime( time.localtime(time.time()) ))
开发者ID:domahutch,项目名称:Spelling-bee,代码行数:35,代码来源:Parse+Version+(Slow).py

示例4: signUp

def signUp(names, classNames):
    global username
    username = usernameEntry.get()
    password = passwordEntry.get()
    username = username.lower()
    value = classBox.curselection()
    strip = str(value).strip(',')
    value = int(strip[1])
    group = classNames[value]
    if username in str(names):
        currentUserLabel.config(text = 'That username is already taken')
        print('That username is already taken')
    else:
        teacher = teacherVar.get()
        if teacher == 0:
            u = User.signup(username, password, teacher = False, group = group)
            currentUserLabel.config(text = 'Logged in as '+username)
            addUsertoResults()
            outputUserResults()
            newWordButton.config(state = DISABLED)
            quizSelectButton.config(state = NORMAL)
            print('Account Created')
        else:
            u = User.signup(username, password, teacher = True, group = group)
            currentUserLabel.config(text = 'Logged in as '+username)
            newWordButton.config(state = NORMAL)
            quizSelectButton.config(state = DISABLED)
            resultsList.delete(0, END)
            print('Account Created')
    print('FUNCTION: signUp COMPLETE')
    print(time.asctime( time.localtime(time.time()) ))
开发者ID:domahutch,项目名称:Spelling-bee,代码行数:31,代码来源:Parse+Version+(Slow).py

示例5: PUT

 def PUT(self, request, post_id):
     story = models.story.Story.active_story()
     if not story:
         return ("", 400)
     elif not story.accepting_snippets():
         return ("", 429)
         
     post = models.post.Post.get(post_id)
     if not post:
         return ("", 404)
         
     voted_users = [user['objectId'] for user in post.voted_users]
     if User.current_user().objectId not in voted_users:
         post.voted_users.append(User.current_user())
     
     post.save()
     
     refresh = False
     if len(post.voted_users) >= models.post.Post.max_vote_count():
         story.accept_post(post)
         story.save()
         
         refresh = True
     
     return json.dumps({
         'votes': len(post.voted_users),
         'refresh': refresh
     })
开发者ID:TheAppCookbook,项目名称:snipppit,代码行数:28,代码来源:post.py

示例6: GET

 def GET(self, request):
     email = request.values.get("email").lower()
     User.request_password_reset(
         email=email
     )
     
     return flask.redirect('/')
开发者ID:TheAppCookbook,项目名称:snipppit,代码行数:7,代码来源:login.py

示例7: login_twitter

	def login_twitter(self, details):
		if not User.Query.filter(username=details['screen_name']):
			print "hello"
			User.signup(
				username=details['screen_name'], 
				password='123456',
				NAME=details['name'],
				# cover=details['profile_background_image_url_https'],
				# image=details['profile_image_url']
			)
		else:
			pass
开发者ID:xssChauhan,项目名称:Learnhut_Server,代码行数:12,代码来源:models.py

示例8: index

def index():
 	settings_local.initParse()
	if request.method == 'POST' and request.form["what"]== 'Login':
		try:
			print request.form["password"]
			u = User.login(request.form["username"],request.form["password"])
			session['session_token'] = u.sessionToken
			resp = make_response(render_template("index.html"))
			return resp
		except:
			return render_template('login.html',error="Invalid username or password")
	elif request.method == 'POST' and request.form["what"]=='SignUp':
		email = request.form["email"]
		password = request.form["password"]
		ninja = request.form["ninja"]
		birthdate = request.form["birthdate"]
		u = User.signup(email,password)
		u.email=email
		u.save()
		# proPic.save(os.path.join(app.config['UPLOAD_FOLDER']),"userdp.png")
		# connection = httplib.HTTPSConnection('api.parse.com', 443)
		# connection.connect()
		# connection.request('POST', '/1/files/profilePic.png', open('userdp.png', 'rb').read(), {
		# "X-Parse-Application-Id": "${Y4Txek5e5lKnGzkArbcNMVKqMHyaTk3XR6COOpg4}",
		# "X-Parse-REST-API-Key": "${nJOJNtVr1EvNiyjo6F6M8zfiUdzv8lPx31FBHiwO}",
		# "Content-Type": "image/png"
		# })
		# result = json.loads(connection.getresponse().read())
		# print result
		# connection.request('POST', '/1/classes/_User', json.dumps({
		# "username": email,
		# "picture": {
		#  "name": "profilePic.png",
		#  "__type": "File"
		# }
		# }), {
		# "X-Parse-Application-Id": "${Y4Txek5e5lKnGzkArbcNMVKqMHyaTk3XR6COOpg4}",
		# "X-Parse-REST-API-Key": "${nJOJNtVr1EvNiyjo6F6M8zfiUdzv8lPx31FBHiwO}",
		# "Content-Type": "application/json"
		# })
		# result = json.loads(connection.getresponse().read())
		# print result
		session['session_token'] = u.sessionToken
		resp = make_response(render_template("index.html"))
		return u.sessionToken
	else:
		if session.get('session_token') is None:
			print "nohhh"
			return render_template('login.html')
		else:
			print "yes"
			return render_template('index.html')
开发者ID:jaygagnani,项目名称:Punchit.io_website_master,代码行数:52,代码来源:hello.py

示例9: testCanGetCurrentUser

    def testCanGetCurrentUser(self):
        user = User.signup(self.username, self.password)
        self.assertIsNotNone(user.sessionToken)

        register(
            getattr(settings_local, 'APPLICATION_ID'),
            getattr(settings_local, 'REST_API_KEY'),
            session_token=user.sessionToken
        )

        current_user = User.current_user()
        self.assertIsNotNone(current_user)
        self.assertEqual(current_user.sessionToken, user.sessionToken)
        self.assertEqual(current_user.username, user.username)
开发者ID:avinsrid,项目名称:ParsePy,代码行数:14,代码来源:tests.py

示例10: sign_up

def sign_up():
    while True:
        try:
            sign_up_dict = get_data()
            current_user = User.signup(sign_up_dict["username"], sign_up_dict["password"], email=sign_up_dict["email"],
                                       Experience=sign_up_dict["exp"], Name=sign_up_dict["name"],
                                       Profession=sign_up_dict["profession"])
            break
        except ResourceRequestBadRequest:
            print("E-mail or username already exist")
        except ValueError:
            print("Invalid exp value")
    current_user = User.login(sign_up_dict["username"], sign_up_dict["password"])
    return current_user
开发者ID:sandspider2234,项目名称:Sukkathon-2015,代码行数:14,代码来源:sign_up.py

示例11: test

def test():
    u = User.login("arjun", "password")

#     print predictBills(6, 'arjun')
    print getMonthlyRates("arjun")

    return render_template('test.html', u="blah")
开发者ID:DakotaNelson,项目名称:PayableVIP,代码行数:7,代码来源:app.py

示例12: delete_sample_users

def delete_sample_users():
  for username, password, email in sample_users:
    try:
      u = User.login(username, password)
      u.delete()
    except:
      pass
开发者ID:danrobinson,项目名称:PingBox,代码行数:7,代码来源:tests.py

示例13: register

def register():
    username = request.form['username']
    password = request.form['password']
    email = request.form['email']
    u = User.signup(username, password, email=email)
    circle = Circle(name="all", owner=u, users=[u])
    circle.save()
    u.circles = [circle]
    u.postingTo = ['all']
    u.save()

    session['username'] = username
    session['password'] = password
    u = User.login(username, password)
    u.save()
    return redirect(url_for('index'))
开发者ID:hspak,项目名称:cs390python,代码行数:16,代码来源:main.py

示例14: create_parse_user

def create_parse_user(email, referred_by=None):
	
	email = email.lower()

	try:	
		if LIVE:
			user_type = "live"
		else:
			user_type = "test"
		ref = gen_alphanum_key()
		user = User.signup(email, "pass", email=email, type=user_type, ref=ref, welcomed=False)	
	
	except Exception as err:
		return {'error': ast.literal_eval(err[0])['error']}
	
	if LIVE:
		try:
			highrise_id = create_highrise_account(email, 'user')
			user.highrise_id = highrise_id
			user.save()
		except:
			pass

	if referred_by:
		try:
			referral = Referrals(email=email, code=referred_by, verified=False)
			referral.save()
		except Exception as err:
			return {'error': ast.literal_eval(err[0])['error']}	
	
	return {'created': True, 'ref': ref}
开发者ID:rhouck,项目名称:traffic,代码行数:31,代码来源:utils.py

示例15: makePayment

def makePayment():
    req = request.get_json()

    if req is None:
        return json.dumps({"status": "fail",
                "reason": "Must include JSON."})

    # TODO authentication to make sure this user
    #      has permission to do this
    if not 'username' in req or not 'password' in req:
        return json.dumps({"status": "fail",
                "reason": "Must include username and password."})

    if not 'amount' in req:
        return json.dumps({"status": "fail",
                "reason": "Must include payment amount."})

    # make sure we can validate to the db
    try:
        u = User.login(req['username'], req['password'])
    except:
        return json.dumps({"status": "fail",
                "reason": "Unable to log user in."})

    # attempt the payment
    res = achCharge(float(req['amount']), u.routingNo, u.acctNo)
    if res['CmdStatus'] != 'Approved':
        return json.dumps({"status": "fail",
                "reason": "Unable to charge account."})

    u.acctBalance += float(req['amount'])
    u.save()
    return json.dumps({"status":"success"})
开发者ID:DakotaNelson,项目名称:PayableVIP,代码行数:33,代码来源:app.py


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