Massimo
Thanks for the reply. Yes, I know I can do it the second way, I'm trying
to a generic function working that will work with any field with the
represent value set. When I try the first suggestion I get the following:
Traceback (most recent call last):
File "C:\dev\miscellaneous\playground\dalOutside.py", line 28, in <module>
print db.formulaImportLine.formulaImportId.represent(x.formulaImportLineId)
TypeError: <lambda>() takes exactly 2 arguments (1 given)
I'm kinda lost here now...
-Jim
On Wednesday, September 12, 2012 3:02:44 PM UTC-5, Massimo Di Pierro wrote:
>
> Given your model you can do:
>
> for x in db(db.formulaImportLine.formulaImportLineId==63901).select():
> print db.formulaImportLine.formulaImportId.represent(x.formul
> aImportLineId)
>
> or more simply
>
> for x in db(db.formulaImportLine.formulaImportLineId==63901).select():
> print x.productNumber
>
> On Wednesday, 12 September 2012 14:10:50 UTC-5, Jim S wrote:
>>
>> Given the following tables:
>>
>> formulaImport = db.define_table('formulaImport',
>> Field('formulaImportId', 'id', readable=False),
>> Field('fileName', length=256, required=True, label='File'),
>> Field('sweptOn', 'date', required=True, label='Swept',
>> default=datetime.datetime.today()),
>> Field('importedOn', 'date', label='Imported'),
>> Field('brillPlant', length=5, required=True, label='Plant'),
>> Field('productNumber', length=30, required=True,
>> label='Product'),
>> Field('productName', length=75, required=True,
>> label='Name'),
>> format = '%(productNumber)s')
>> formulaImport._plural = 'Formula Imports'
>>
>> formulaImport.fileName.requires = IS_NOT_EMPTY()
>> formulaImport.brillPlant.requires = IS_NOT_EMPTY()
>> formulaImport.sweptOn.requires = IS_DATE('%m/%d/%Y')
>> formulaImport.productNumber.requires = IS_NOT_EMPTY()
>> formulaImport.productName.requires = IS_NOT_EMPTY()
>> formulaImport.importedOn.requires = IS_NULL_OR(IS_DATE('%m/%d/%Y'))
>>
>> formulaImportLine = db.define_table('formulaImportLine',
>> Field('formulaImportLineId', 'id', readable=False),
>> Field('formulaImportId', db.formulaImport, required=True,
>> label='Formula Import'),
>> Field('sequence', 'integer', required=True),
>> Field('productNumber', length=30, required=True, label='Product Number'
>> ),
>> Field('quantity', 'decimal(13,5)', required=True),
>> format=('%(productNumber)s'))
>> formulaImportLine.formulaImportId.required = IS_IN_DB(db, db.
>> formulaImport,
>> '$(fileName)s',
>> '.choose.')
>> formulaImportLine.sequence.requires = [IS_INT_IN_RANGE(0,9999999),
>> IS_NOT_EMPTY()]
>> formulaImportLine.productNumber.requires = IS_NOT_EMPTY()
>> formulaImportLine.quantity.requires = [IS_FLOAT_IN_RANGE(0,2000),
>> IS_NOT_EMPTY()]
>> db.formulaImportLine.formulaImportId.represent = lambda p, r: r.
>> productNumber
>>
>>
>> Given a specific formulaImportLine I want to be able to display the
>> associate formulaLine.productNumber.
>>
>> Running this code:
>> for x in db(db.formulaImportLine.formulaImportLineId==63901).select():
>> print x.formulaImportId.represent()
>>
>> ...I get the following traceback:
>>
>> Traceback (most recent call last):
>> File "C:\dev\miscellaneous\playground\dalOutside.py", line 26, in
>> <module>
>> print x.formulaImportId.represent()
>> TypeError: 'NoneType' object is not callable
>>
>> Is there a way for me to reference a 'parent' record and display either
>> for 'format' for the table or the 'represent' for the specific field?
>>
>>
>>
--