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


Python Session.query方法代码示例

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


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

示例1: test_04_cascade_delete

# 需要导入模块: from archeologicaladdressbook.model import Session [as 别名]
# 或者: from archeologicaladdressbook.model.Session import query [as 别名]
 def test_04_cascade_delete(self):
     """ Test for cascade delete between `VoluntaryMember` and `Person` models."""
     v_member = Session.query(model.VoluntaryMember).filter_by().first()
     Session.delete(v_member)
     Session.commit()
     person = Session.query(model.Person).filter_by(person_id=v_member.person_id).count()
     assert person == 0
开发者ID:lazaret,项目名称:archeobases,代码行数:9,代码来源:test_voluntary_member.py

示例2: test_04_cascade_delete

# 需要导入模块: from archeologicaladdressbook.model import Session [as 别名]
# 或者: from archeologicaladdressbook.model.Session import query [as 别名]
 def test_04_cascade_delete(self):
     """ Test for cascade delete on the `Address` model."""
     person = Session.query(model.Person).filter_by().first()
     Session.delete(person)
     Session.commit()
     addresses = Session.query(model.Address).filter_by(person_id=person.person_id).count()
     assert addresses == 0
开发者ID:lazaret,项目名称:archeobases,代码行数:9,代码来源:test_address.py

示例3: test_04_cascade_delete

# 需要导入模块: from archeologicaladdressbook.model import Session [as 别名]
# 或者: from archeologicaladdressbook.model.Session import query [as 别名]
 def test_04_cascade_delete(self):
     """ Test for cascade delete on the `Photo` model."""
     person = Session.query(model.Person).filter_by().first()
     Session.delete(person)
     Session.commit()
     photos = Session.query(model.Photo).filter_by(person_id=person.person_id).count()
     assert photos == 0
开发者ID:lazaret,项目名称:archeobases,代码行数:9,代码来源:test_photo.py

示例4: test_03_cascade_delete

# 需要导入模块: from archeologicaladdressbook.model import Session [as 别名]
# 或者: from archeologicaladdressbook.model.Session import query [as 别名]
 def test_03_cascade_delete(self):
     """ Test for cascade delete on the `Excavation` model."""
     person = Session.query(model.Person).filter_by().first()
     Session.delete(person)
     Session.commit()
     excavations = Session.query(model.Excavation). \
         filter_by(person_id=person.person_id).count()
     assert excavations == 0
开发者ID:lazaret,项目名称:archeobases,代码行数:10,代码来源:test_excavation.py

示例5: validate_python

# 需要导入模块: from archeologicaladdressbook.model import Session [as 别名]
# 或者: from archeologicaladdressbook.model.Session import query [as 别名]
 def validate_python(self, values, state):
     """ Check for the uniqueness of an `email_address`."""
     email_address = values['email_address']
     if email_address != None:  # do not check for empty `email_adress`
         if values.has_key('user_id'):
             user_id = values['user_id']
             email = Session.query(User).filter(User.user_id != user_id). \
                 filter(User.email_address == email_address).first()
         else:
             email = Session.query(User).filter(
                 User.email_address == email_address).first()
         if email:
             errors = {'email_address': self.message('not_unique_email', state)}
             raise formencode.Invalid(self.message('not_unique_email', state), values, state, error_dict=errors)
开发者ID:lazaret,项目名称:archeobases,代码行数:16,代码来源:user.py

示例6: test_03_child_relations

# 需要导入模块: from archeologicaladdressbook.model import Session [as 别名]
# 或者: from archeologicaladdressbook.model.Session import query [as 别名]
 def test_03_child_relations(self):
     """ Test the `Person` model child relations."""
     address_fixture()
     photo_fixture()
     person = Session.query(model.Person).filter_by().first()
     assert person.addresses, '`Address` child relation is missing.'
     assert person.photo, '`Photo` child relation is missing.'
开发者ID:lazaret,项目名称:archeobases,代码行数:9,代码来源:test_person.py

示例7: show

# 需要导入模块: from archeologicaladdressbook.model import Session [as 别名]
# 或者: from archeologicaladdressbook.model.Session import query [as 别名]
 def show(self, id=None):
     """ Display a person excavation record."""
     c.excavation = Session.query(Excavation).get(id)
     if c.excavation:
         return render('/excavations/show.mako')
     else:
         flash_message(_("This record did not exist"), 'warning')
         return redirect(url.current(action='index', id=None))
开发者ID:lazaret,项目名称:archeobases,代码行数:10,代码来源:excavations.py

示例8: confirm_delete

# 需要导入模块: from archeologicaladdressbook.model import Session [as 别名]
# 或者: from archeologicaladdressbook.model.Session import query [as 别名]
 def confirm_delete(self, id=None):
     """ Show an address record and ask to confirm deletion."""
     c.address = Session.query(Address).get(id)
     if c.address:
         return render('/addresses/confirm_delete.mako')
     else:
         flash_message(_("This record did not exist"), 'warning')
         return redirect(url.current(action='index', id=None))
开发者ID:lazaret,项目名称:archeobases,代码行数:10,代码来源:addresses.py

示例9: show

# 需要导入模块: from archeologicaladdressbook.model import Session [as 别名]
# 或者: from archeologicaladdressbook.model.Session import query [as 别名]
 def show(self, id=None):
     """ Display a person address record."""
     c.address = Session.query(Address).get(id)
     if c.address:
         return render('/addresses/show.mako')
     else:
         flash_message(_("This record did not exist"), 'warning')
         return redirect(url.current(action='index', id=None))
开发者ID:lazaret,项目名称:archeobases,代码行数:10,代码来源:addresses.py

示例10: create

# 需要导入模块: from archeologicaladdressbook.model import Session [as 别名]
# 或者: from archeologicaladdressbook.model.Session import query [as 别名]
 def create(self):
     """ Add a new address record for a person in the database."""
     person_id = self.form_result['person_id']
     person = Session.query(Person).get(person_id)
     address = Address(**self.form_result)
     person.addresses.append(address)
     Session.commit()
     flash_message(_("New address record added"), 'success')
     return redirect(url.current(action='show', id=address.address_id))
开发者ID:lazaret,项目名称:archeobases,代码行数:11,代码来源:addresses.py

示例11: create

# 需要导入模块: from archeologicaladdressbook.model import Session [as 别名]
# 或者: from archeologicaladdressbook.model.Session import query [as 别名]
 def create(self):
     """ Add a new excavation record for a person in the database."""
     person_id = self.form_result['person_id']
     person = Session.query(Person).get(person_id)
     excavation = Excavation(**self.form_result)
     person.excavations.append(excavation)
     Session.commit()
     flash_message(_("New excavation record added"), 'success')
     return redirect(url.current(action='show', id=excavation.excavation_id))
开发者ID:lazaret,项目名称:archeobases,代码行数:11,代码来源:excavations.py

示例12: show

# 需要导入模块: from archeologicaladdressbook.model import Session [as 别名]
# 或者: from archeologicaladdressbook.model.Session import query [as 别名]
 def show(self, id=None):
     """ Display a person record."""
     c.person = Session.query(Person).get(id)
     #c.audit = Session.query(Audit).filter(Audit.modelname=='Person').all()
     if c.person:
         return render('/persons/show.mako')
     else:
         flash_message(_("This record did not exist"), 'warning')
         return redirect(url.current(action='index', id=None))
开发者ID:lazaret,项目名称:archeobases,代码行数:11,代码来源:persons.py

示例13: test_01_columns

# 需要导入模块: from archeologicaladdressbook.model import Session [as 别名]
# 或者: from archeologicaladdressbook.model.Session import query [as 别名]
 def test_01_columns(self):
     """ Test the `Permission` model columns and types."""
     permission = Session.query(model.Permission).filter_by().first()
     assert isinstance(permission.permission_id, int), \
         '`permission_id` column is missing or has changed.'
     assert isinstance(permission.permission_name, unicode), \
         '`permission_name` column is missing or has changed.'
     assert isinstance(permission.description, unicode), \
         '`description` column is missing or has changed.'
开发者ID:lazaret,项目名称:archeobases,代码行数:11,代码来源:test_permissions.py

示例14: test_01_columns

# 需要导入模块: from archeologicaladdressbook.model import Session [as 别名]
# 或者: from archeologicaladdressbook.model.Session import query [as 别名]
 def test_01_columns(self):
     """ Test the `Photo` model columns and types."""
     photo = Session.query(model.Photo).filter_by().first()
     assert isinstance(photo.photo_id, int), \
         '`photo_id` column is missing or has changed.'
     assert isinstance(photo.person_id, int), \
         '`person_id` column is missing or has changed.'
     assert isinstance(photo.path, unicode), \
         '`path` column is missing or has changed.'
开发者ID:lazaret,项目名称:archeobases,代码行数:11,代码来源:test_photo.py

示例15: test_01_columns

# 需要导入模块: from archeologicaladdressbook.model import Session [as 别名]
# 或者: from archeologicaladdressbook.model.Session import query [as 别名]
 def test_01_columns(self):
     """ Test the `Group` model columns and types."""
     group = Session.query(model.Group).filter_by().first()
     assert isinstance(group.group_id, int), \
         '`group_id` column is missing or has changed.'
     assert isinstance(group.group_name, unicode), \
         '`group_name` column is missing or has changed.'
     assert isinstance(group.display_name, unicode), \
         '`display_name` column is missing or has changed.'
开发者ID:lazaret,项目名称:archeobases,代码行数:11,代码来源:test_group.py


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