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


Python model.Session类代码示例

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


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

示例1: create

 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,代码行数:9,代码来源:excavations.py

示例2: create

 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,代码行数:9,代码来源:addresses.py

示例3: create

 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))
开发者ID:lazaret,项目名称:archeobases,代码行数:10,代码来源:persons.py

示例4: delete

 def delete(self, id=None):
     """ Delete an existing address record."""
     address = Session.query(Address).get(id)
     if address:
         Session.delete(address)
         Session.commit()
         flash_message(_("Address record deleted"), 'success')
         return redirect(url.current(action='index'))
     else:
         flash_message(_("This record did not exist"), 'warning')
         return redirect(url.current(action='index', id=None))
开发者ID:lazaret,项目名称:archeobases,代码行数:11,代码来源:addresses.py

示例5: delete

 def delete(self, id=None):
     """ Delete an existing excavation record."""
     excavation = Session.query(Excavation).get(id)
     if excavation:
         Session.delete(excavation)
         Session.commit()
         flash_message(_("Excavation record deleted"), 'success')
         return redirect(url.current(action='index'))
     else:
         flash_message(_("This record did not exist"), 'warning')
         return redirect(url.current(action='index', id=None))
开发者ID:lazaret,项目名称:archeobases,代码行数:11,代码来源:excavations.py

示例6: update

 def update(self, id=None):
     """ Update an existing address record."""
     address = Session.query(Address).get(id)
     if address:
         # update record attributes
         for key, value in self.form_result.items():
             setattr(address, key, value)
         Session.commit()
         flash_message(_("Address record updated"), 'success')
         return redirect(url.current(action='show', id=address.address_id))
     else:
         flash_message(_("This record did not exist"), 'warning')
         return redirect(url.current(action='index', id=None))
开发者ID:lazaret,项目名称:archeobases,代码行数:13,代码来源:addresses.py

示例7: test_02_unique_constraint

    def test_02_unique_constraint(self):
        """ Test for unique constraint for the `Photo` model.

        Test the unique constraint on `path`.
        """
        test_photo = DuplicatePhotoData.JohnDoePhoto()
        person = Session.query(model.Person).filter_by().first()
        person.photo = model.Photo(path=test_photo.path)
        try:
            Session.commit()
            raise AssertionError('`Photo` unique constraint on `path` is missing.')
        except sa.exc.IntegrityError:
            Session.rollback()
开发者ID:lazaret,项目名称:archeobases,代码行数:13,代码来源:test_photo.py

示例8: validate_python

 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,代码行数:14,代码来源:user.py

示例9: update

 def update(self, id=None):
     """ Update an existing person record."""
     person = Session.query(Person).get(id)
     if person:
         # check first for a duplicate entry
         self._check_duplicate(self.form_result, person.person_id)
         # update record attributes
         for key, value in self.form_result.items():
             setattr(person, key, value)
         Session.commit()
         flash_message(_("Person record updated"), 'success')
         return redirect(url.current(action='show', id=person.person_id))
     else:
         flash_message(_("This record did not exist"), 'warning')
         return redirect(url.current(action='index', id=None))
开发者ID:lazaret,项目名称:archeobases,代码行数:15,代码来源:persons.py

示例10: test_03_child_relations

 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,代码行数:7,代码来源:test_person.py

示例11: show

 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,代码行数:8,代码来源:excavations.py

示例12: confirm_delete

 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,代码行数:8,代码来源:addresses.py

示例13: show

 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,代码行数:8,代码来源:addresses.py

示例14: test_01_columns

 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,代码行数:9,代码来源:test_group.py

示例15: show

 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,代码行数:9,代码来源:persons.py


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