Hi There

the "error" kinda says it all.

"<built-in method title of str object at 0x7fbe302ae4e0>"

That means, that "product" in your context is not the name of a
table/row of a table in your database, but its a string object and
youre displaying its title-method's string representation.

Any python string has a method "title", so you can do this:

>>> somestring = "hey there"
>>> somestring.title()
'Hey There'
>>>
>>> somestring.title
<built-in method title of str object at 0x00B60958>
>>>

Basically you tell python to display infos about a method, instead of
calling it. Seems that in your code, product.title() would actually
work, which means the error is buried elsewhere. Your product variable
holds a string, which it shouldnt.

I dont really know why it is acting like this, because your
DBSession.query looks fine to me, which is a little creepy to me,
because it shouldnt be doing this. If i were you, i'd try what happens
when you change the name of the column to something other than title,
but actually this has to work with title.

I am confused because calling "type(product)" is supposed to output
something like an SQLAlchemyMappedClass but in your class its type
string.


Hope that helps a little bit even if I cant spot the real error right now.

Greets,

Tom

On Tue, Oct 27, 2009 at 1:13 AM, KurtB <[email protected]> wrote:
>
> 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