本文整理汇总了Python中model.user.User.put方法的典型用法代码示例。如果您正苦于以下问题:Python User.put方法的具体用法?Python User.put怎么用?Python User.put使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类model.user.User
的用法示例。
在下文中一共展示了User.put方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_new_user
# 需要导入模块: from model.user import User [as 别名]
# 或者: from model.user.User import put [as 别名]
def create_new_user(self, user_keyname, password, set_user=True, **kwargs):
logging.info('creating user with keyname %s' % user_keyname)
user_entity = User(key_name=user_keyname, username=user_keyname)
if password:
user_entity.password = password
if '@passtiche.appspot.com' not in user_keyname and not user_keyname.startswith('auto_gen'):
deferred.defer(send_admin_email, subject='New %s User: %s' % (
self._settings['title'], user_keyname),
message='User %s just signed up for an account' % user_keyname,
user=user_keyname, user_agent=gae_utils.GetUserAgent(), url=gae_utils.GetUrl())
if '@' in user_keyname:
user_entity.email = user_keyname
#send_welcome_email(user_entity.email, 'Welcome to %s!' % self._settings['title'])
deferred.defer(send_welcome_email,
user_entity,
'Welcome to %s!' % self._settings['title'],
_countdown=10) # 1300 22 minutes
# optional args
for k in ['first_name', 'last_name','phone','organization']:
if kwargs.get(k):
v = kwargs.get(k)
setattr(user_entity, k, v)
from utils import string as str_utils
code = str_utils.genkey(length=7)
user_entity.short_code = code
user_entity.put()
if set_user:
self.set_current_user(user_entity)
return user_entity
示例2: _process_users
# 需要导入模块: from model.user import User [as 别名]
# 或者: from model.user.User import put [as 别名]
def _process_users(self, session, **kwargs):
modified_voters = set()
new_user = None
if "new_voter" in kwargs and kwargs["new_voter"]:
new_user = User(name=kwargs["new_voter"])
new_user.put()
user_by_session = UserBySession(user=new_user, session=session)
user_by_session.put()
voter_keys = []
if "voter_key" in kwargs:
voter_keys = [kwargs["voter_key"]]
if isinstance(kwargs["voter_key"], list):
voter_keys = voter_keys[0]
if "voter_name" in kwargs and not isinstance(kwargs["voter_name"], list):
kwargs["voter_name"] = [kwargs["voter_name"]]
for i in range(len(voter_keys)):
voter = User.get(voter_keys[i])
voter.name = kwargs["voter_name"][i]
voter.put()
modified_voters.add(voter)
return (new_user, modified_voters)
示例3: new_or_existing_ga
# 需要导入模块: from model.user import User [as 别名]
# 或者: from model.user.User import put [as 别名]
def new_or_existing_ga(user, alias_suggestion=None):
#id = unicode(type(user).__name__.lower() +':'+ user.user_id())
id = unicode('ah:'+ user.user_id())
entity = User.get_by_key_name(id)
if not entity:
entity = User(key_name=id, email=user.email())
entity.put()
logger.debug("Created user %s (%s)", entity.email, entity.key().name())
#if alias_suggestion and not find_alias(alias_suggestion):
# alias = new_alias(entity, alias_suggestion)
#else:
# alias = new_alias_for(entity)
#assert alias, "FIXME: Cannot create Alias for %s" % user.email()
#alias.put()
#logger.debug("Created alias %s for user (%s).", alias.handle, entity.key().name())
elif entity.email != user.email():
entity.email = user.email()
entity.put()
#alias = new_alias_for(entity)
#if alias:
# logger.debug("Updating user %s for alias %s. ", user.email(), newalias)
# alias.put()
#else:
# logger.info("New alias not available for user %s. ", user.email())
return entity
示例4: post
# 需要导入模块: from model.user import User [as 别名]
# 或者: from model.user.User import put [as 别名]
def post(self):
if not self.validate(self.request):
self.render_form()
else:
user = User(name=self.username, password_hash=Hash.password(self.username, self.password), email=(self.email if self.email else None ))
user.put()
self.set_cookie('userid', user.key())
self.redirect('/blog/home')
示例5: new_or_existing_email
# 需要导入模块: from model.user import User [as 别名]
# 或者: from model.user.User import put [as 别名]
def new_or_existing_email(email):
mbox_sha1 = hashlib.sha1(email).hexdigest()
id = unicode('bl:'+ mbox_sha1)
entity = User.get_by_key_name(id)
if not entity:
entity = User(key_name=id, email=email)
entity.put()
else:
logger.error("TODO: implement user authentication. ")
return entity
示例6: fetch_and_save_github_user
# 需要导入模块: from model.user import User [as 别名]
# 或者: from model.user.User import put [as 别名]
def fetch_and_save_github_user(access_token):
response = json.loads(urlfetch.fetch(github.USER_EMAILS_URL%access_token).content)
for email in response:
if email['primary']:
logging.info(email['email'])
user = User.get_by_key_name(email['email'])
if not user:
user = User(key_name=email['email'])
user.put()
response = json.loads(urlfetch.fetch(github.USER_URL%access_token).content)
id, followers = response['login'], response['followers']
ThirdPartyUser(key_name=GITHUB, parent=user, access_token=access_token, id=id, followers=followers).put()
示例7: get_user_or_letlogin
# 需要导入模块: from model.user import User [as 别名]
# 或者: from model.user.User import put [as 别名]
def get_user_or_letlogin(ctrl, dest_url='/'):
from google.appengine.api import users
guser = users.get_current_user()
if not guser:
ctrl.redirect(users.create_login_url(dest_url))
return None
user = User.get_by_key_name(guser.email())
if not user:
user = User(key_name=guser.email(), email=guser.email())
user.put()
return user
示例8: post
# 需要导入模块: from model.user import User [as 别名]
# 或者: from model.user.User import put [as 别名]
def post(self):
isUser = User.query(User.username == self.request.get('username')).get()
if((isUser is None) and (self.request.get('confirm') == self.request.get('password')) and validation(self.request.get('email'))):
hashsum = hashlib.md5(self.request.get('password')).hexdigest()
users = User(username = self.request.get('username'),
password=hashsum )
users.put()
return webapp2.redirect('/')
else:
templatevalues = {
'user_log' : checkcookies(self),
}
template = jinja_environment.get_template('error.html')
self.response.out.write(template.render({'templatevalues':templatevalues}))
示例9: create_user
# 需要导入模块: from model.user import User [as 别名]
# 或者: from model.user.User import put [as 别名]
def create_user(self, req_handler):
photos = self.get_uploads("uploaded_photo")
photo = self['image']
email = req_handler['email']
if photos:
photo_blob_key = photos[0].key()
photo = '/api/common/download_image/'+str(photo_blob_key)
password_hash = generate_password_hash(req_handler['password'])
user = User(key_name = email, name = req_handler['name'], password = password_hash, photo = photo)
intercomio_api.users(email=email, name=req_handler['name'], signed_up_at=int(time.time()))
intercomio_api.events(email=email, event_name='signedup')
mixpanel_api.users(email, req_handler['name'])
mixpanel_api.events(email, 'signedup')
user.put()
示例10: join_game
# 需要导入模块: from model.user import User [as 别名]
# 或者: from model.user.User import put [as 别名]
def join_game(self, game, name):
sess = User(uid = uuid.uuid4().hex)
sess.secret = channel.create_channel(sess.uid)
sess.gid = game.gid;
sess.name = name
sess.put()
self.response.set_cookie('Session', sess.uid)
# We don't need to save this as create() has more stuff to add
game.members.append(sess.name)
self.user = sess
# The userid
return sess.uid
示例11: testUserCreate
# 需要导入模块: from model.user import User [as 别名]
# 或者: from model.user.User import put [as 别名]
def testUserCreate( self ):
self.setup_admin_user()
u = users.get_current_user()
self.isNotNone( u )
_lu = User(
user = u,
email = u.email(),
is_blog_owner = users.is_current_user_admin()
)
_lu.put()
self.assertEquals( _lu.email, u.email() )
self.assertEquals( User.all().count(), 1 )
self.assertEquals( User.all().get().user, u )
示例12: create
# 需要导入模块: from model.user import User [as 别名]
# 或者: from model.user.User import put [as 别名]
def create(self):
"""
Create the ID
"""
try:
# retrieve the parameters
u = self.params['user']
if len(u['name']) < 2 or len(u['name']) > 16:
raise 'ID 長度有誤'
from google.appengine.api import users
from model.user import User
from model.counter import Counter
from random import randint
user = User.gql('WHERE name = :1', u['name']).get()
if user is not None:
raise 'ID 重覆'
guser = users.get_current_user()
# create user entity
user = User(key_name=guser.email(),
name=u['name'],
email=guser.email())
user.put()
# add user counter
shard_name = randint(0, 3)
counter = Counter.get_by_key_name('user_counter_%d' % shard_name)
if counter is None:
counter = Counter(key_name='user_counter_%d' % shard_name, name="user_counter")
counter.count += 1
counter.put()
if self.session.has_key('error'):
del self.session['error']
self.session.put()
self.redirect('/auth')
except Exception, ex:
self.session['error'] = ex
self.session.put()
self.redirect('/signup')