Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8597657
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T00:57:43+00:00 2026-06-12T00:57:43+00:00

I built a view which allow user input some information and inserted that information

  • 0

I built a view which allow user input some information and inserted that information as a new record into my database with Pyramid framework. The code is like this:

def orderplace_view(request):
    user = User.get(authenticated_userid(request))
    cart = Cart.get_by_user(user)

    if cart.itemtypes == None:  # cat is empty
        request.session.flash(u'Empty cart')
        raise HTTPFound(location = request.route_url('cart'))

    placeorderform = PlaceOrderForm(request.POST)
    placeorderform.address.query = UserAddress.query_by_user(user)

    if request.POST and placeorderform.validate():
        # create order
        order = Order()
        order.address = placeorderform.address.data

        # fill order with other attributes...
        user.orders.append(order)

        # IMPORTANT LINE!!!
        raise HTTPFound(location = request.route_url('order_list'))

    return {'user': user,
        'title': 'place order',
        'cart': cart,
        'placeorderform': placeorderform}

Here’s the strange thing: If I commented out the “raise HTTPFound()” line, everything works fine, a new order would be inserted into database. But if I keep that line which redirect user to Order List page, the order won’t be inserted! Why this happened?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T00:57:44+00:00Added an answer on June 12, 2026 at 12:57 am

    If Pyramid transaction middleware is in use, it will abort the containing transaction when view function raises an exception: http://docs.pylonsproject.org/projects/pyramid_tm/en/latest/#transaction-usage

    Commit explicitly with transaction.commit(), or, better yet, return HTTPFound instead of raising it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

(From the point of view of a user, not how it's built or which
I’ve got a CursorAdapter that's built from a database Cursor and if a View
I have a view which I built in Interface builder with a tableview and
I'm trying to fit a 20x20 table into a view using a programmatically built
I'm trying to build a view that operators something similar to this: The user
I have built a custom view component that displays a timeline of events. The
I have a first view which is the log in screen. After the user
Built a custom app that will allow users to add jobs to a system.
I've built a Backbone-powered library that allows a user to add/remove items, much like
I'd like to build a view that allows the user to get a list

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.