I have tables which linked as a one to many relationship:

user ---(one to many)---> order --(many to one)-->product

Product has been populated and served as a lookup table.

class User:
      member_id
      purchase_total

      order = relationship(Order....)

      def add_product(self, orderObj):
         session = DBSession()

         session.add(orderObj)
         session.flush()

         self.purchase_total += orderObj.product.price

         self.order.append(orderObj)
         transaction.commit()

class Product:
      product_id
      price

class Order:
      order_id
      product_id (FK)
      member_id (FK)

      product = relationship(Product.....)

# user purchasing product
user = session.query(User).get(id)
newOrder = Order()
newOrder.product_id = 1
user.add_product(newOrder)

I'm wondering if the above coding is safe in a multi-thread
application such as web app.  Especially for the flush and session
method.



-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.

Reply via email to