def test_delete_entity(self): fr = self.article.add_locale('fr', title='Les mille et une nuits', content=u"J'ai entendu dire, Ô mon roi, dit Scheherazade") session.commit() session.expunge_all() article = Article.get(1) session.delete(article) session.commit() assert session.query(Article.__localized_class__).count() == 0
def flush(self, party): from sqlalchemy.orm.session import Session session = Session.object_session( party ) if session: # # flush all contact mechanism related objects # objects = [party] deleted = ( party in session.deleted ) for party_contact_mechanism in party.contact_mechanisms: if deleted: session.delete( party_contact_mechanism ) objects.extend([ party_contact_mechanism, party_contact_mechanism.contact_mechanism ]) session.flush( objects )
def _set_contact_mechanism( self, described_by, value ): """Set a specific type of contact mechanism """ for party_contact_mechanism in self.contact_mechanisms: contact_mechanism = party_contact_mechanism.contact_mechanism if contact_mechanism != None: mechanism = contact_mechanism.mechanism if mechanism != None: if mechanism[0] == described_by: if value and value[1]: contact_mechanism.mechanism = value else: session = orm.object_session( party_contact_mechanism ) self.contact_mechanisms.remove( party_contact_mechanism ) if party_contact_mechanism.id: session.delete( party_contact_mechanism ) return if value and value[1]: contact_mechanism = ContactMechanism( mechanism = value ) party_contact_mechanism = PartyContactMechanism( contact_mechanism = contact_mechanism ) self.contact_mechanisms.append( party_contact_mechanism )
def deleteTask(self, task_id): task = self.getTaskById(task_id) session.delete(task) session.commit()
def removeRow(self, row): session.delete(self.getRow(row)) self.saveChanges() self.load()