Andrew,
I took what you gave me and built an application called ecomm. Three
table definitions were missing so I faked it to get it working then
loaded in a bit of data. I have something working displaying data in
the individual product view.
Things to check.
1) The user_products result passed to the view is the result of a join
in the db. To address an element in the result
{{for row in user_products:}}
{{=row.table_name.field_name}} is required e.g.
{{=row.product.description}} not just row.description in this case.
This avoids the possibility of name collisions on fields between
tables e.g. all tables have a field called id.
2) The controller name.py function_name() maps to view/name/
function_name.html
I blindly copied the content from the post to indv_ptrdouct.html as
noted in the message and then could not see anything change. Turns out
the generic html file was used because the view/display/
indv_product.html file could not be found. Oops. It had me fooled
because both had a generic response._vars output which shows the data
from the database result.
I presume the logo field is somewhere such as in the product_extended
table which I didn't have the definition for so I switched to a
different field name to display in the view.
Hope that helps, I can wrap up the app I have here and send it to you
but I don't think you will need it - if you do just let me know.
Ron
On Oct 17, 11:09 am, Andrew Evans <[email protected]> wrote:
> what more of the application do you need to see, which parts?
>
> OS is Debian Lenny, Python 2.5 and the database is the default with web2py
> SQLite I believe.
>
> Will post my controller and views maybe that will help solve this
>
> Controller
>
> ###Display.py###
> ###########################
> # Display Indiviual Product
> ###########################
>
> #def indv_product():
> # this_page = request.args(0)
>
> # user_products = db((db.product.id == this_page) &
> (db.product_extended.product == this_page) & #(db.user_extended.userinfo ==
> db.product.userinfo)).select()
> # return dict(user_products=user_products)
>
> def indv_product():
> this_page = request.args(0)
> user_products = db((db.product.id == this_page) & (db.product.id ==
> db.product_extended.product) & (db.product.userinfo ==
> db.user_extended.userinfo)).select()
> #product_e=db(db.product_extended.product ==
> this_page).select(db.product_extended.ALL)
> return dict(user_products=user_products)
>
> This is my view index.html where I pass args to where I am calling the
> function... I never posted the whole html file
>
> {{=A(row.product_name,
> _href=URL('display', 'indv_product', args=row.id))}}
>
> and here is the is the indv_ptrdouct.html
>
> {{for row in user_products:}}
>
> and example of data
>
> <div id="logo">
> <h1></h1>
> <p>{{=row.logo}}</p>
> </div>
>
> {{pass}}
>
> You can see the site @www.em-ecommerce.com/Working/display/indexto see
> whats happening
>
> *cheers
>
> Andrew
>
> On Sun, Oct 17, 2010 at 1:58 AM, ron_m <[email protected]> wrote:
> > After rereading the posts I realize you might be running the db calls
> > in the view so the controller comment would be incorrect. Bottom line,
> > there is no data to display from what you are telling me about the
> > result of the last test. Is it possible to check the database and look
> > at the data in the tables for a particular product id you are using
> > for testing to be sure all the foreign keys are in place in the
> > related tables. What environment are you running on? OS, Python
> > version, database used? It is difficult to figure out the problem
> > without seeing more of the application.
>
> > Ron
>
> > On Oct 16, 11:02 am, Andrew Evans <[email protected]> wrote:
> > > Hello ty for the continued help. I did as you suggested and I saw the
> > table
> > > headers but none of the Data. I tried the function you suggested also.
>
> > > Does that mean its a controller problem
>
> > > Any ideas
>
> > > *cheers
>
> > > On Sat, Oct 16, 2010 at 12:14 AM, ron_m <[email protected]> wrote:
> > > > A couple of things
>
> > > > Put this in for the view html file temporarily
>
> > > > {{extend 'layout.html'}}
> > > > <hr />
> > > > {{=H2('Results')}}
> > > > {{=SQLTABLE(user_products,
> > > > headers='fieldname:capitalize',
> > > > truncate=100)
> > > > }}
>
> > > > and you should see a nicely formatted table of the results of the
> > > > query with the column names in the table header.
>
> > > > This will prove whether or not you are getting data in user_products.
> > > > If you see the expected results in the table then it is a view
> > > > problem. If the table is blank it is a controller problem.
>
> > > > Did you put a {{pass}} line at the point where the {{for row in
> > > > user_products:}} iteration loop should end? Indentation follows HTML
> > > > not Python rules in the {{}} code segments so pass is used to signal
> > > > the end of a block in this case "for".
>
> > > >http://web2py.com/book/default/chapter/05
>
> > > > Ron
>
> > > > On Oct 15, 11:29 pm, Andrew Evans <[email protected]> wrote:
> > > > > Hi ty for replying to my problem but I am a bit confused. I tried
> > doing
> > > > the
> > > > > query you suggested and tried doing it another way
>
> > > > > it seems my loop is never executed cause what appears there is a
> > blank
> > > > page.
>
> > > > > Not sure what I am doing wrong
>
> > > > > Those are the two I tried
>
> > > > > def indv_product():
> > > > > this_page = request.args(0)
>
> > > > > user_products = db((db.product.id == this_page) &
> > > > > (db.product_extended.product == this_page) &
> > (db.user_extended.userinfo
> > > > ==
> > > > > db.product.userinfo)).select()
> > > > > return dict(user_products=user_products)
>
> > > > > def indv_product():
> > > > > this_page = request.args(0)
> > > > > user_products = db((db.product.id == this_page) & (db.product.id==
> > > > > db.product_extended.product) & (db.product.userinfo ==
> > > > > db.user_extended.userinfo)).select()
> > > > > return dict(user_products=user_products)
>
> > > > > But it seems the loop doesn't work any idea
>
> > > > > this is what I am using
>
> > > > > {{for row in user_products:}}
>
> > > > > and an example of how I am using row
> > > > > <p><img src="{{= URL('default','download', args=row.image)}}"
> > > > > alt="{{=row.product_name}}" width="400" height="425"
> > > > > />{{=row.description}}</p>
>
> > > > > The html doesn't even appear in the view source of my browser so I am
> > > > doing
> > > > > something wrong
>
> > > > > *cheers
>
>