Well, I don't see a "supplier" field in the db.product model. On Wednesday, July 10, 2013 8:52:04 AM UTC-4, greenpoise wrote: > > sorry. This is the error I get: > > File "/home/xyz/Applications/web2py/gluon/sqlhtml.py", line 3122, in __init__ > r = represent(field, r, record) > File "/home/xyz/Applications/web2py/gluon/sqlhtml.py", line 66, in represent > return f(value, record) > File "/home/xyz/Applications/web2py/applications/MOS/models/db_catalog.py" > <http://127.0.0.1:8000/admin/default/edit/MOSAIC_POSx2/models/db_catalog.py>, > line 102, in <lambda> > Field('supptile',represent=lambda id, r: '%s%s'% > (r.supplier.suppliercode,r.product.tilename)), > AttributeError: 'Row' object has no attribute 'supplier' > > > On Wednesday, July 10, 2013 5:13:55 AM UTC-7, Anthony wrote: >> >> Hard to help without knowing what the error is. >> >> On Wednesday, July 10, 2013 1:35:01 AM UTC-4, greenpoise wrote: >>> >>> AGh..tilename was in it, I just didnt include it in this thread: >>> >>> >>> db.define_table('supplier', >>> Field('suppliercode'), >>> Field('suppliername'), >>> format='%(suppliercode)s') >>> db.supplier.suppliercode.requires = IS_NOT_IN_DB(db,db.supplier. >>> suppliercode) >>> db.supplier.suppliername.requires = IS_NOT_IN_DB(db,db.supplier. >>> suppliername) >>> >>> >>> >>> db.define_table('series', >>> Field('supplier','reference supplier'), >>> Field('seriesname'), >>> Field('seriesdescription'), >>> Field('description')) >>> >>> >>> db.define_table('product', >>> Field('series', 'reference series'), >>> Field('supptile',represent=lambda id, r: '%s%s'% (r.supplier. >>> suppliercode,r.tilename)), >>> Field('tilename'), >>> Field('description'), >>> Field('conversiontype'), >>> Field('inactive','boolean')) >>> >>> >>> controller function: >>> >>> grid = SQLFORM >>> <http://127.0.0.1:8000/examples/global/vars/SQLFORM>.grid(db.series,left >>> =[db.series.on(db.series.id==db.product.series),db.supplier.on(db.supplier.id==db.series.supplier)],fields=[db.supplier.suppliercode,db.product.supptile,db.product.tilename], >>> headers = {'supplier.suppliercode': >>> 'SUPPLIERCODE','series.supptile':'ITEMCODE','product.tilename':'REORDER#'}) >>> >>> >>> >>> As it is, the grid works as I want. I get the supptile which is a >>> concatenation of the suppliercode and tilename. When I go to database >>> administration, which I use, the product table prompts me an error. Agh!!! >>> Thanks so much Anthony! >>> >>> **I hope I didnt miss anything** >>> >>> >>> >>> On Tuesday, July 9, 2013 10:02:00 PM UTC-7, Anthony wrote: >>>> >>>> Can you show your new code? So far, all we see is r.product.tilename, >>>> which won't work because r.product is a LazySet object -- you have to do >>>> r.product.select().first().tilename, or something along those lines >>>> (though >>>> that will just give you the tilename of the first product that references >>>> the record). Also, in the models you have shown, there is no tilename >>>> field >>>> in the db.product table. >>>> >>>> Anthony >>>> >>>> On Tuesday, July 9, 2013 11:34:27 PM UTC-4, greenpoise wrote: >>>>> >>>>> I re-opened this as I keep getting the same error. >>>>> >>>>> >>>>> >>>>> >>>>> On Tuesday, July 9, 2013 4:12:49 PM UTC-7, greenpoise wrote: >>>>>> >>>>>> I think I got it by reading the recursive select section. THanks!!! >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> On Tuesday, July 9, 2013 3:55:04 PM UTC-7, Anthony wrote: >>>>>>> >>>>>>> Would help if you showed your data models. Presumably the db.product >>>>>>> table includes a reference field that references this table. That >>>>>>> allows >>>>>>> you to do a recursive select in reverse (see the last part of this >>>>>>> section<http://web2py.com/books/default/chapter/29/06#Recursive-selects>). >>>>>>> >>>>>>> When you select a record from this table (let's call the record "r"), >>>>>>> then >>>>>>> r.product is a LazySet object that refers to all the records in >>>>>>> db.product >>>>>>> that have a reference to this particular record. You can then use that >>>>>>> as >>>>>>> any DAL Set object. If you need to further filter the set, you can add >>>>>>> a >>>>>>> condition by doing r.product(some_query), and if you want to select the >>>>>>> records, you can do r.product.select(). Assuming there are potentially >>>>>>> multiple product records that reference a given record in this table, >>>>>>> it's >>>>>>> not clear how you would want to use those records to construct the >>>>>>> "represent" output for the field. >>>>>>> >>>>>>> Anthony >>>>>>> >>>>>>> On Tuesday, July 9, 2013 6:32:33 PM UTC-4, greenpoise wrote: >>>>>>>> >>>>>>>> I am getting this error. My grid works fine but when I try to log >>>>>>>> into the database administration tool, I get this error. Any clue? >>>>>>>> >>>>>>>> File >>>>>>>> "/home/xxx/Applications/web2py/applications/APPLICACION/models/db_catalog.py" >>>>>>>> >>>>>>>> <http://127.0.0.1:8000/admin/default/edit/MOSAIC_POSx2/models/db_catalog.py>, >>>>>>>> line 72, in <lambda> >>>>>>>> Field('supptile',represent=lambda id, r: '%s%s'% >>>>>>>> (r.supplier.suppliercode,r.product.tilename)), >>>>>>>> AttributeError: 'LazySet' object has no attribute 'tilename' >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>>
-- --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/groups/opt_out.

