Hi guys,

I'm creating a really basic ordering system and
am trying to use to use sprox to create an order form
using the 'SalesOrder' model, *and* I want to
fill some fields using results from a query
on the 'Products' model.

I'm attempting to pass product_id and title
values in the controller. When rendering
the template the product field gets nothing, and
the title field renders:
"<built-in method title of str object at 0x7fbe302ae4e0>"

I'm sure I'm missing something.

I looked at EditFormFiller but it's not clear to me
how to wedge it in. I'd appreciate any suggestions
on either how to get this working or how you think
I should better approach this. I'm not averse
to throwing it all aout and coming at it from
another angle.

Here's what I'm trying (obviously not working):

#From root.py
#######################################
# place_order_form
class PlaceOrder(AddRecordForm):
  __model__ = SalesOrder
  __omit_fields__ = ['id', 'purch_datetime', 'display_date']

place_order_form = PlaceOrder(DBSession)


class RootController(BaseController):
  """There's other stuff between here and placeorder."""
  #placeorder
  @expose('tgdeal.templates.placeorder')
  def placeorder(self):
    """Displays the placeorder form using
    the product for 'cdate'."""
    cdate = datetime.datetime(2009, 10, 31)
    product = DBSession.query(Product).filter_by(
      display_date = cdate).one()
    tmpl_context.place_order_form = place_order_form
    values = { 'product_id':product.id, 'title': product.title }
    return dict(product = product,
                values = values,
                page='placeorder')


  #place_order_form
  @expose()
  @validate(
    form=place_order_form,
    error_handler=placeorder,
    )


# from placeorder.html
################################################################
    <h2>Place Your Order for - ${product.title}</h2>
    ${tmpl_context.place_order_form(
        action = 'place_order',
        value='values',
        )}

################################################################



This is my first TG project, and I'm just
figuring most of this out. A judicious
application of the clue bat would be most
appreciated.

Thanks,

  -KurtB


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"TurboGears" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to