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


Python Account.put方法代码示例

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


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

示例1: process_request

# 需要导入模块: from models import Account [as 别名]
# 或者: from models.Account import put [as 别名]
 def process_request(self, request):
   """ This function sets up the user object
       Depending on the value of require_login, it
       can return None as 'profile'.
   """
   #Get Google user_id
   google_user = users.get_current_user()
   account = None
   is_admin = False
   logging.info(request.META['HTTP_USER_AGENT'])
   if google_user:
       #Check if the user already has a site profile
       user_id = google_user.user_id()
       is_admin = users.is_current_user_admin()
       q = Account.all()
       q.filter('google_user =', google_user)
       account = q.get()
       
       if not account:
           nickname = hashlib.md5(google_user.nickname()).hexdigest()[:10]
           account = Account(user_id = user_id, nickname = nickname)
           account.put()
           box = Box(title='My Box')
           box.put()
           
   request.user = account
   Account.current_user_account = account
   request.user_is_admin = is_admin
开发者ID:noio,项目名称:Cardbox,代码行数:30,代码来源:middleware.py

示例2: basicinfo

# 需要导入模块: from models import Account [as 别名]
# 或者: from models.Account import put [as 别名]
def basicinfo(user, self):
    if user:
        url = users.create_logout_url(self.request.uri)
        url_linktext = 'Logout'
        nickname = user.nickname()
        accounts = Account.query(Account.guser == user).fetch()

        if len(accounts) == 0:  # if no Account object exists for user
            new_account = Account(
                guser=user,
                modules_completed=[],
                projects_completed=[]
            )
            new_account.put()
    else:
        url = users.create_login_url(self.request.uri)
        url_linktext = 'Login'
        nickname = None

    template_values = {
        'title': config.SITE_NAME,
        'url': url,
        'url_linktext': url_linktext,
        'nickname': nickname
    }
    return template_values
开发者ID:N0tinuse,项目名称:senior_project,代码行数:28,代码来源:functions.py

示例3: test_get_one_returns_entity

# 需要导入模块: from models import Account [as 别名]
# 或者: from models.Account import put [as 别名]
    def test_get_one_returns_entity(self):
        acc = Account(username=self.username, password=self.password, userid=self.userid)
        acc.put()

        result = Account.get_one()

        self.assertEqual(acc, result)
开发者ID:notapresent,项目名称:rutracker_rss,代码行数:9,代码来源:test_models.py

示例4: get_or_init_account

# 需要导入模块: from models import Account [as 别名]
# 或者: from models.Account import put [as 别名]
def get_or_init_account(user):
    account = Account.all().filter('user =', user).get()
    if account is None:
        account = Account(user=user)
        account.put()
    
    return account
开发者ID:bmander,项目名称:amaurot,代码行数:9,代码来源:views.py

示例5: setAccountInfo

# 需要导入模块: from models import Account [as 别名]
# 或者: from models.Account import put [as 别名]
def setAccountInfo(info):
	e = Account.get_by_id(info['uid'])
	if e:
		pass
	else:
		account = Account(id = info['uid'], uid = info['uid'], name = info['display_name'], country = info['country'], link = info['referral_link'], 
		quota_normal = info['quota_info']['normal'], quota_shared = info['quota_info']['shared'], quota_quota = info['quota_info']['quota'])
		account.put()
开发者ID:var,项目名称:dbxcard,代码行数:10,代码来源:dataaccess.py

示例6: test_placeholder

# 需要导入模块: from models import Account [as 别名]
# 或者: from models.Account import put [as 别名]
  def test_placeholder(self):

    user = users.User("[email protected]")
    account = Account(user=user)
    account.set_hash_and_key()
    account.put()

    self.assertTrue(account.user.email() == "[email protected]")
开发者ID:MediaPreneur,项目名称:notify-io,代码行数:10,代码来源:test_account.py

示例7: create_account

# 需要导入模块: from models import Account [as 别名]
# 或者: from models.Account import put [as 别名]
def create_account(user):
    """
    This function creates account for new user
    """
    account = Account(user=user, newsletter=True)
    account.put()
    ig = ImageGroup(name="Custom Images", owner=account, priority=0)
    ig.save()
    notify_admins_about_new_user_signup(user)
    return account
开发者ID:andreyvit,项目名称:mockko,代码行数:12,代码来源:handlers.py

示例8: checkUser

# 需要导入模块: from models import Account [as 别名]
# 或者: from models.Account import put [as 别名]
    def checkUser(self, user):
        accounts = Account.all()
        user_ids = []
        for acc in accounts:
            user_ids.append(acc.user_id)

        uid = user.nickname()
        if uid not in user_ids:
            account = Account(key_name=uid, user_id=uid)
            account.put()
开发者ID:xz565,项目名称:vote-item,代码行数:12,代码来源:main.py

示例9: RequestHandler

# 需要导入模块: from models import Account [as 别名]
# 或者: from models.Account import put [as 别名]
class RequestHandler(webapp.RequestHandler):
    def initialize(self, request, response):
        super(RequestHandler, self).initialize(request, response)
        self.user = users.get_current_user()
        if self.user:
            self.login_url = None
            self.logout_url = users.create_logout_url("/")
            self.account = Account.all().filter("user =", self.user).get()
            if not self.account:
                # Set up a Notify.io account

                self.account = Account()
                self.account.set_hash_and_key()
                # self.account.source_name = self.user.nick() # More useful default than None
                self.account.put()

                # Create default Desktop Notifier
                o = Outlet(target=self.account, type_name="DesktopNotifier")
                o.set_name("Default Desktop Notifier")
                o.put()

            # This is to update existing accounts before outlets
            if not self.account.get_default_outlet():
                # Create default Desktop Notifier
                o = Outlet(target=self.account, type_name="DesktopNotifier")
                o.set_name("Default Desktop Notifier")
                o.put()
                for channel in Channel.get_all_by_target(self.account):
                    if not channel.outlet:
                        channel.outlet = o
                        channel.put()

        else:
            self.logout_url = None
            self.account = None
            self.login_url = users.create_login_url(request.path)

        # Hide the Get Started tip
        if request.query_string == "hide":
            self.account.started = True
            self.account.put()

    def render(self, template_path, locals):
        locals.update(
            {
                "user": self.user,
                "logout_url": self.logout_url,
                "login_url": self.login_url,
                "account": self.account,
                "api_host": API_HOST,
                "api_version": API_VERSION,
                "www_host": WWW_HOST,
            }
        )
        self.response.out.write(template.render(template_path, locals))
开发者ID:Mondego,项目名称:pyreco,代码行数:57,代码来源:allPythonContent.py

示例10: account_page

# 需要导入模块: from models import Account [as 别名]
# 或者: from models.Account import put [as 别名]
def  account_page(request):
	if request.method == 'POST':
		aid=request.POST['aid']
		aname=request.POST['aname']
		accin= Account()
		accin.aid=int(aid)
		accin.aname=aname
		accin.put()
		return HttpResponseRedirect('/account')
	if request.method == 'GET':
		accout= Account.query(Account.aid>0).fetch()
		return render(request, 'account.html',{'acc':accout})
开发者ID:g1z2yong,项目名称:accone,代码行数:14,代码来源:views.py

示例11: get_account

# 需要导入模块: from models import Account [as 别名]
# 或者: from models.Account import put [as 别名]
def get_account(user):
    from models import Account
    existing = db.GqlQuery('SELECT * from Account ' +
        'WHERE user = :1',
        user)
    if existing.count() == 0:
        account = Account()
        account.user = user
        account.put()
        return account
    else:
        return existing[0]
开发者ID:Ultixan,项目名称:A-Mind-Beside-Itself,代码行数:14,代码来源:util.py

示例12: get_account

# 需要导入模块: from models import Account [as 别名]
# 或者: from models.Account import put [as 别名]
def get_account(user):
    existing = db.GqlQuery('SELECT * from Account ' +
        'WHERE user = :1',
        user)
    if existing.count() == 0:
        account = Account()
        account.user = user
        import uuid
        account.game_id=uuid.uuid4().hex
        account.put()
        return account
    else:
        return existing[0]
开发者ID:Ultixan,项目名称:ohnoes,代码行数:15,代码来源:util.py

示例13: post

# 需要导入模块: from models import Account [as 别名]
# 或者: from models.Account import put [as 别名]
	def post(self):
		new_user = Account()
		
		accounts = Account.all()
		accounts.filter('nickname = ', self.request.get('nickname'))
		nick_already_exist = accounts.get()
		
		if nick_already_exist == None:
			new_user.user = users.get_current_user()
			new_user.nickname = self.request.get('nickname')
			new_user.put()
		
		self.redirect('/')
开发者ID:engleek,项目名称:pintme,代码行数:15,代码来源:main.py

示例14: test_verify_existing_user

# 需要导入模块: from models import Account [as 别名]
# 或者: from models.Account import put [as 别名]
def test_verify_existing_user():
    """
  Should return 200
  """
    user = users.User("[email protected]")
    account = Account(user=user)
    account.set_hash_and_key()
    account.put()

    response = app.get("/v1/users/%s?api_key=%s" % (account.hash, account.api_key), status=200)

    assert response.body == "200 OK"

    test.reset_datastore()
开发者ID:Mondego,项目名称:pyreco,代码行数:16,代码来源:allPythonContent.py

示例15: test_verify_non_existing_user

# 需要导入模块: from models import Account [as 别名]
# 或者: from models.Account import put [as 别名]
def test_verify_non_existing_user():
    """
  Should return a 404 if userhash does not have a Notify.io account
  """
    user = users.User("[email protected]")
    account = Account(user=user)
    account.set_hash_and_key()
    account.put()

    response = app.get("/v1/users/abcdef?api_key=%s" % account.api_key, status=404)

    assert response.body == "404 User not found"

    test.reset_datastore()
开发者ID:Mondego,项目名称:pyreco,代码行数:16,代码来源:allPythonContent.py


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