本文整理汇总了Python中models.account.Account.put方法的典型用法代码示例。如果您正苦于以下问题:Python Account.put方法的具体用法?Python Account.put怎么用?Python Account.put使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.account.Account
的用法示例。
在下文中一共展示了Account.put方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_account
# 需要导入模块: from models.account import Account [as 别名]
# 或者: from models.account.Account import put [as 别名]
def create_account(cls, name=None):
if not name:
name = cls.DEFAULT_COMPANY_NAME
account = Account(name=name)
account.put()
return account
示例2: TestMatchSuggestionAccepter
# 需要导入模块: from models.account import Account [as 别名]
# 或者: from models.account.Account import put [as 别名]
class TestMatchSuggestionAccepter(unittest2.TestCase):
def setUp(self):
self.testbed = testbed.Testbed()
self.testbed.activate()
self.testbed.init_datastore_v3_stub()
self.testbed.init_memcache_stub()
ndb.get_context().clear_cache() # Prevent data from leaking between tests
self.testbed.init_taskqueue_stub(root_path=".")
self.account = Account(
email="[email protected]",
)
self.account.put()
self.suggestion = Suggestion(
author=self.account.key,
contents_json="{\"youtube_videos\":[\"123456\"]}",
target_key="2012ct_qm1",
target_model="match"
)
self.suggestion.put()
self.event = Event(
id="2012ct",
event_short="ct",
year=2012,
event_type_enum=EventType.REGIONAL,
)
self.event.put()
self.match = Match(
id="2012ct_qm1",
alliances_json="""{"blue": {"score": -1, "teams": ["frc3464", "frc20", "frc1073"]}, "red": {"score": -1, "teams": ["frc69", "frc571", "frc176"]}}""",
comp_level="qm",
event=self.event.key,
year=2012,
set_number=1,
match_number=1,
team_key_names=[u'frc69', u'frc571', u'frc176', u'frc3464', u'frc20', u'frc1073'],
youtube_videos=["abcdef"]
)
self.match.put()
def tearDown(self):
self.testbed.deactivate()
def test_accept_suggestions(self):
MatchSuggestionAccepter.accept_suggestion(self.match, self.suggestion)
match = Match.get_by_id("2012ct_qm1")
self.assertTrue("abcdef" in match.youtube_videos)
self.assertTrue("123456" in match.youtube_videos)
示例3: controller
# 需要导入模块: from models.account import Account [as 别名]
# 或者: from models.account.Account import put [as 别名]
def controller(request):
phone = request.get("From")
account = Account(phone=phone)
account.put()
account.state = account_model.STATE_ONBOARD
account.substate = onboard.SUBSTATE_WELCOME
account.state_locked = True
deferred.defer(account_model.incomplete_handler, account.key.id(),
_countdown=datetime.timedelta(minutes=10).seconds)
return account
示例4: signup
# 需要导入模块: from models.account import Account [as 别名]
# 或者: from models.account.Account import put [as 别名]
def signup(self):
form = ProfileForm(self.request.POST)
if self.request.method == 'POST' and form.validate():
# Create the webapp2_extras.auth user.
model = self.auth.store.user_model
ok, user = model.create_user(form.data['email'],
password_raw=form.data['password'])
if not ok:
self.session.add_flash(messages.ERROR_MESSAGE, level='error')
return self.redirect_to('signup')
# Ensure that we have a default account setup.
default_account = Account.all().filter(
'name = ', constants.PRODUCT_NAME).get()
if not default_account:
default_account = Account(name=constants.PRODUCT_NAME)
default_account.put()
# Create the profile.
name = ' '.join([form.data['first_name'], form.data['last_name']])
profile = Profile(parent=default_account,
name=name,
email=form.data['email'],
tel_number=form.data['tel_number'],
is_member=True,
auth_user_id=user.key.id())
profile.put()
# Automatically log the person in.
user_id = user.key.id()
self.auth.get_user_by_token(user_id, user.create_auth_token(user_id))
self.session.add_flash(messages.PROFILE_CREATE_SUCCESS, level='info')
return self.redirect_to('home')
return self.render_to_response('signup.haml', {'form': form})
示例5: create
# 需要导入模块: from models.account import Account [as 别名]
# 或者: from models.account.Account import put [as 别名]
def create(self):
form = TaxiDriverForm(self.request.POST)
if self.request.method == 'POST' and form.validate():
# Ensure that we have a default account setup.
default_account = Account.all().filter(
'name = ', constants.PRODUCT_NAME).get()
if not default_account:
default_account = Account(name=constants.PRODUCT_NAME)
default_account.put()
if TaxiDriver.get_by_driver_id(form.data['driver_id']):
self.session.add_flash(messages.TAXI_DRIVER_EXISTS,
level='error')
return self.render_to_response('taxi_driver/form.haml', {'form': form})
name = ' '.join((form.data['first_name'],
form.data['last_name']))
taxi_driver = TaxiDriver(parent=default_account,
name=name,
driver_id=form.data['driver_id'],
email=form.data['email'],
sex=form.data['sex'],
address=form.data['address'],
tel_number=form.data['tel_number'],
parish=form.data['parish'],
dob=form.data['dob'])
taxi_driver.put()
self.session.add_flash(messages.TAXI_DRIVER_CREATE_SUCCESS, level='info')
return self.redirect_to('taxi_driver.list')
self.session.add_flash(messages.TAXI_DRIVER_CREATE_ERROR, level='error')
return self.redirect_to('taxi_driver.list')
示例6: driver_signup
# 需要导入模块: from models.account import Account [as 别名]
# 或者: from models.account.Account import put [as 别名]
def driver_signup(self):
form1 = ProfileForm(self.request.POST)
form2 = TaxiDriverForm(self.request.POST)
if self.request.method == 'POST' and form1.validate() and form2.validate():
# Create the webapp2_extras.auth user.
model = self.auth.store.user_model
ok, user = model.create_user(form1.data['email'],
password_raw=form1.data['password'])
if not ok:
self.session.add_flash(messages.ERROR_MESSAGE, level='error')
return self.redirect_to('signup')
# Ensure that we have a default account setup.
default_account = Account.all().filter(
'name = ', constants.PRODUCT_NAME).get()
if not default_account:
default_account = Account(name=constants.PRODUCT_NAME)
default_account.put()
# Create the profile.
name = ' '.join([form1.data['first_name'], form1.data['last_name']])
profile = Profile(parent=default_account,
name=name,
email=form1.data['email'],
tel_number=form1.data['tel_number'],
is_driver=True,
auth_user_id=user.key.id())
profile.put()
self.session.add_flash(messages.PROFILE_CREATE_SUCCESS, level='info')
# Ensure that we have a default account setup.
default_account = Account.all().filter(
'name = ', constants.PRODUCT_NAME).get()
if not default_account:
default_account = Account(name=constants.PRODUCT_NAME)
default_account.put()
if TaxiDriver.get_by_driver_id(form2.data['driver_id']):
self.session.add_flash(messages.TAXI_DRIVER_EXISTS,
level='error')
return self.render_to_response('taxi_driver/form.haml')
name = ' '.join((form2.data['first_name'],
form2.data['last_name']))
taxi_driver = TaxiDriver(parent=default_account,
name=name,
driver_id=form2.data['driver_id'],
email=form2.data['email'],
sex=form2.data['sex'],
address=form2.data['address'],
tel_number=form2.data['tel_number'],
parish=form2.data['parish'],
dob=form2.data['dob'])
taxi_driver.put()
# Automatically log the person in.
user_id = user.key.id()
self.auth.get_user_by_token(user_id, user.create_auth_token(user_id))
self.session.add_flash(messages.TAXI_DRIVER_CREATE_SUCCESS, level='info')
return self.redirect_to('home')
return self.render_to_response('driver-signup.html')