本文整理汇总了Python中archeologicaladdressbook.model.Session.add方法的典型用法代码示例。如果您正苦于以下问题:Python Session.add方法的具体用法?Python Session.add怎么用?Python Session.add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类archeologicaladdressbook.model.Session
的用法示例。
在下文中一共展示了Session.add方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create
# 需要导入模块: from archeologicaladdressbook.model import Session [as 别名]
# 或者: from archeologicaladdressbook.model.Session import add [as 别名]
def create(self):
""" Add a new person record in the database."""
# check first for a duplicate entry
self._check_duplicate(self.form_result)
# create the record
person = Person(**self.form_result)
Session.add(person)
Session.commit()
flash_message(_("New person record added"), 'success')
return redirect(url.current(action='show', id=person.person_id))
示例2: test_05_orphans
# 需要导入模块: from archeologicaladdressbook.model import Session [as 别名]
# 或者: from archeologicaladdressbook.model.Session import add [as 别名]
def test_05_orphans(self):
""" Test that orphans are forbidden for the `Photo` model."""
test_photo = OrphanPhotoData.JohnSmithPhoto()
photo = model.Photo(path=test_photo.path)
Session.add(photo)
try:
Session.commit()
raise AssertionError('`Photo` delete-orphans constraint is missing.')
except sa.exc.FlushError:
Session.rollback()
示例3: test_02_unique_constraint
# 需要导入模块: from archeologicaladdressbook.model import Session [as 别名]
# 或者: from archeologicaladdressbook.model.Session import add [as 别名]
def test_02_unique_constraint(self):
""" Test for unique constraint for the `Permission` model.
Test the unique constraint on `group_name`.
"""
test_permission = DuplicatePermissionData.View()
permission = model.Permission(
permission_name=test_permission.permission_name,
description=test_permission.description
)
Session.add(permission)
try:
Session.commit()
raise AssertionError('`Permission` unique constraint on `group_name`, is missing.')
except sa.exc.IntegrityError:
Session.rollback()
示例4: test_04_orphans
# 需要导入模块: from archeologicaladdressbook.model import Session [as 别名]
# 或者: from archeologicaladdressbook.model.Session import add [as 别名]
def test_04_orphans(self):
""" Test that orphans are forbidden for the `Excavation` model."""
test_excavation = OrphanExcavationData.ExcavationSite2()
excavation = model.Excavation(
site_name=test_excavation.site_name,
start_date=test_excavation.start_date,
end_date=test_excavation.end_date,
appreciation=test_excavation.appreciation
)
Session.add(excavation)
try:
Session.commit()
raise AssertionError("`Excavation` delete-orphans constraint \
is missing.")
except sa.exc.FlushError:
Session.rollback()
示例5: test_02_unique_constraint
# 需要导入模块: from archeologicaladdressbook.model import Session [as 别名]
# 或者: from archeologicaladdressbook.model.Session import add [as 别名]
def test_02_unique_constraint(self):
""" Test for unique constraint for the `Group` model.
Test the unique constraint on `group_name`.
"""
test_group = DuplicateGroupData.Guests()
group = model.Group(
group_name=test_group.group_name,
display_name=test_group.display_name
)
Session.add(group)
try:
Session.commit()
raise AssertionError('`Group` unique constraint on `group_name`, \
is missing.')
except sa.exc.IntegrityError:
Session.rollback()
示例6: test_02_unique_constraint
# 需要导入模块: from archeologicaladdressbook.model import Session [as 别名]
# 或者: from archeologicaladdressbook.model.Session import add [as 别名]
def test_02_unique_constraint(self):
""" Test for unique constraint for the `User` model.
Test the unique constraint on `user_name`.
"""
test_user = DuplicateUserData.Guest()
user = model.User(
user_name=test_user.user_name,
email_address=test_user.email_address,
password=test_user.password,
display_name=test_user.display_name
)
Session.add(user)
try:
Session.commit()
raise AssertionError('`User` unique constraint on `user_name`, is missing.')
except sa.exc.IntegrityError:
Session.rollback()
示例7: test_05_orphans
# 需要导入模块: from archeologicaladdressbook.model import Session [as 别名]
# 或者: from archeologicaladdressbook.model.Session import add [as 别名]
def test_05_orphans(self):
""" Test that orphans are forbidden for the `Address` model."""
test_address = OrphanAddressData.JohnSmithAddress()
address = model.Address(
address_line1 = test_address.address_line1,
address_line2 = test_address.address_line2,
address_line3 = test_address.address_line3,
zip_code = test_address.zip_code,
city = test_address.city,
country = test_address.country,
address_type = test_address.address_type
)
Session.add(address)
try:
Session.commit()
raise AssertionError('`Address` delete-orphans constraint is missing.')
except sa.exc.FlushError:
Session.rollback()
示例8: test_02_unique_constraint
# 需要导入模块: from archeologicaladdressbook.model import Session [as 别名]
# 或者: from archeologicaladdressbook.model.Session import add [as 别名]
def test_02_unique_constraint(self):
""" Test for unique constraint for the `Person` model.
Test the unique constraint on `last_name` and `first_name`.
"""
test_person = DuplicatePersonData.JohnDoe()
person = model.Person(
last_name=test_person.last_name,
first_name=test_person.first_name,
title=test_person.title,
birth_date=test_person.birth_date,
activity=test_person.activity
)
Session.add(person)
try:
Session.commit()
raise AssertionError('`Person` unique constraint on `last_name` \
and `first_name` is missing.')
except sa.exc.IntegrityError:
Session.rollback()
示例9: test_03_unique_constraint
# 需要导入模块: from archeologicaladdressbook.model import Session [as 别名]
# 或者: from archeologicaladdressbook.model.Session import add [as 别名]
def test_03_unique_constraint(self):
""" Test for unique constraint for the `VoluntaryMember` model.
Test the unique constraint on `member_number`.
"""
test_v_member = DuplicateVoluntaryMemberData.MaryJohnes()
v_member = model.VoluntaryMember(
last_name=test_v_member.last_name,
first_name=test_v_member.first_name,
title=test_v_member.title,
birth_date=test_v_member.birth_date,
activity=test_v_member.activity,
member_number=test_v_member.member_number,
last_fee_date=test_v_member.last_fee_date
)
Session.add(v_member)
try:
Session.commit()
raise AssertionError('`VoluntaryMember` unique constraint on `member_number` is missing.')
except sa.exc.IntegrityError:
Session.rollback()