I just started using web2py and am using it with mongodb.  There have been 
a few hiccups along the way that seem related to the relative immaturity of 
the DAL for mongo.  I am scratching my head over trying to use virtual 
fields and am now wondering if this could be related to the same thing.

db.py:
db.define_table('dealers',
    Field('name', type='string', notnull=True,label=T('Dealer Name')),
    Field('contacts'),
    Field('timezone')
    )


class DealerSummaryVirtualFields(object):
    def new_field(self):
        #for simplicity, i am just going to return a 1
        return 1

controllers/default.py
def dealers():
    rows=db(db.dealers).select(orderby=db.dealers.name)
    rows.setvirtualfields(dealers=DealerSummaryVirtualFields())
    print rows.colnames
    return dict(dealers=rows)

When I do this, I do not see the new_field in the result.

I have also tried the other method before calling .select():
    db.dealers.virtualfields.append(DealerSummaryVirtualFields())

Same basic result.

Is there something elementary that I am missing?  Or is this actually an 
issue?

Thanks


Reply via email to