예제 #1
0
def delete(request):
    """country delete """
    id = request.matchdict['id']
    dbsession = DBSession()
    country = dbsession.query(Country).filter_by(id=id).first()
    if country is None:
        request.session.flash("error;Country not found!")
        return HTTPFound(location=request.route_url("country_list"))        
    
    try:
        transaction.begin()
        dbsession.delete(country);
        transaction.commit()
        request.session.flash("warning;The country is deleted!")
    except IntegrityError:
        # delete error
        transaction.abort()
        request.session.flash("error;The country could not be deleted!")
    
    return HTTPFound(location=request.route_url("country_list"))
예제 #2
0
def delete(request):
    """country delete """
    id = request.matchdict['id']
    dbsession = DBSession()
    country = dbsession.query(Country).filter_by(id=id).first()
    if country is None:
        request.session.flash("error;Country not found!")
        return HTTPFound(location=request.route_url("country_list"))

    try:
        transaction.begin()
        dbsession.delete(country)
        transaction.commit()
        request.session.flash("warning;The country is deleted!")
    except IntegrityError:
        # delete error
        transaction.abort()
        request.session.flash("error;The country could not be deleted!")

    return HTTPFound(location=request.route_url("country_list"))
예제 #3
0
def delete(request):
    """customer delete """
    id = request.matchdict['id']
    dbsession = DBSession()
    customer = dbsession.query(Customer).filter_by(id=id).first()
    address = dbsession.query(Address).filter_by(user_id=id).first()
    emails = dbsession.query(Email).filter_by(user_id=id).first()
    phones = dbsession.query(Phone).filter_by(user_id=id).first()
    
    if customer is None:
        request.session.flash("error;Customer not found!")
        return HTTPFound(location=request.route_url("customer_list"))        
    
    try:
        transaction.begin()
        dbsession.delete(customer)
        dbsession.delete(address)
        dbsession.delete(emails)
        dbsession.delete(phones)
        transaction.commit()
        request.session.flash("warning;The customer is deleted!")
    except IntegrityError:
        # delete error
        transaction.abort()
        request.session.flash("error;The customer could not be deleted!")
    
    return HTTPFound(location=request.route_url("customer_list"))